Skip to content

Commit

Permalink
⚡️💥 regenned endpoints
Browse files Browse the repository at this point in the history
Endpoints now use new model names
Added support for void methods (like most DELETE requests) as they have no return type.
  • Loading branch information
Yoshify committed Aug 22, 2023
1 parent 5d934a7 commit e967f50
Show file tree
Hide file tree
Showing 1,993 changed files with 2,409 additions and 4,893 deletions.
8 changes: 4 additions & 4 deletions src/pyconnectwise/clients/automate_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __init__(
username (str): Your ConnectWise Automate API username.
password (str): Your ConnectWise Automate API password.
"""
self.client_id = client_id
self.automate_url = automate_url
self.username = username
self.password = password
self.client_id: str = client_id
self.automate_url: str = automate_url
self.username: str = username
self.password: str = password
self.token_expiry_time: datetime = datetime.utcnow()

# Grab first access token
Expand Down
12 changes: 6 additions & 6 deletions src/pyconnectwise/clients/manage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def __init__(
private_key (str): Your ConnectWise Manage API Private key.
codebase (str, optional): Your ConnectWise Manage Codebase. If not provided, it will be fetched from the API. Defaults to None.
"""
self.client_id = client_id
self.company_name = company_name
self.manage_url = manage_url
self.public_key = public_key
self.private_key = private_key
self.client_id: str = client_id
self.company_name: str = company_name
self.manage_url: str = manage_url
self.public_key: str = public_key
self.private_key: str = private_key

# Retrieve codebase from the API if not provided
if not codebase:
Expand All @@ -60,7 +60,7 @@ def __init__(
if codebase_request is None:
# we need to except here
raise Exception("Could not retrieve codebase from API.")
self.codebase = codebase_request
self.codebase: str = codebase_request

# Initializing endpoints
self.company = CompanyEndpoint(self)
Expand Down
15 changes: 7 additions & 8 deletions src/pyconnectwise/endpoints/automate/ApitokenEndpoint.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.Automate.Api.Domain.Contracts.Security import AuthInformation
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import AutomateAuthInformation, AutomateTokenResult
from pyconnectwise.responses.paginated_response import PaginatedResponse


class ApitokenEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "Apitoken", parent_endpoint=parent_endpoint)

def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> AuthInformation:
def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> AutomateAuthInformation:
"""
Performs a GET request against the /Apitoken endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
AuthInformation: The parsed response data.
AutomateAuthInformation: The parsed response data.
"""
return self._parse_one(AuthInformation, super()._make_request("GET", data=data, params=params).json())
return self._parse_one(AutomateAuthInformation, super()._make_request("GET", data=data, params=params).json())

def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> TokenResult:
def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> AutomateTokenResult:
"""
Performs a POST request against the /Apitoken endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
TokenResult: The parsed response data.
AutomateTokenResult: The parsed response data.
"""
return self._parse_one(TokenResult, super()._make_request("POST", data=data, params=params).json())
return self._parse_one(AutomateTokenResult, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.responses.paginated_response import PaginatedResponse


Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import AVTemplatePolicy
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechAVTemplatePolicy
from pyconnectwise.responses.paginated_response import PaginatedResponse


class AvtemplatepoliciesEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "Avtemplatepolicies", parent_endpoint=parent_endpoint)

def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> AVTemplatePolicy:
def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> LabTechAVTemplatePolicy:
"""
Performs a POST request against the /Avtemplatepolicies endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
AVTemplatePolicy: The parsed response data.
LabTechAVTemplatePolicy: The parsed response data.
"""
return self._parse_one(AVTemplatePolicy, super()._make_request("POST", data=data, params=params).json())
return self._parse_one(LabTechAVTemplatePolicy, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import AVTemplatePolicyData
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechAVTemplatePolicyData
from pyconnectwise.responses.paginated_response import PaginatedResponse


class AvtemplatepolicydataEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "Avtemplatepolicydata", parent_endpoint=parent_endpoint)

def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> AVTemplatePolicyData:
def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> LabTechAVTemplatePolicyData:
"""
Performs a POST request against the /Avtemplatepolicydata endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
AVTemplatePolicyData: The parsed response data.
LabTechAVTemplatePolicyData: The parsed response data.
"""
return self._parse_one(AVTemplatePolicyData, super()._make_request("POST", data=data, params=params).json())
return self._parse_one(
LabTechAVTemplatePolicyData, super()._make_request("POST", data=data, params=params).json()
)
23 changes: 12 additions & 11 deletions src/pyconnectwise/endpoints/automate/ClientsEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from pyconnectwise.endpoints.automate.ClientsIdEndpoint import ClientsIdEndpoint
from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import Client
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechClient
from pyconnectwise.responses.paginated_response import PaginatedResponse


Expand All @@ -24,7 +23,9 @@ def id(self, id: int) -> ClientsIdEndpoint:
child._id = id
return child

def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}) -> PaginatedResponse[Client]:
def paginated(
self, page: int, page_size: int, params: dict[str, int | str] = {}
) -> PaginatedResponse[LabTechClient]:
"""
Performs a GET request against the /Clients endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -33,38 +34,38 @@ def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}
page_size (int): The number of results to return per page.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
PaginatedResponse[Client]: The initialized PaginatedResponse object.
PaginatedResponse[LabTechClient]: The initialized PaginatedResponse object.
"""
params["page"] = page
params["pageSize"] = page_size
return PaginatedResponse(
super()._make_request("GET", params=params),
Client,
LabTechClient,
self,
page,
page_size,
)

def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[Client]:
def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[LabTechClient]:
"""
Performs a GET request against the /Clients endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
list[Client]: The parsed response data.
list[LabTechClient]: The parsed response data.
"""
return self._parse_many(Client, super()._make_request("GET", data=data, params=params).json())
return self._parse_many(LabTechClient, super()._make_request("GET", data=data, params=params).json())

def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> Client:
def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> LabTechClient:
"""
Performs a POST request against the /Clients endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
Client: The parsed response data.
LabTechClient: The parsed response data.
"""
return self._parse_one(Client, super()._make_request("POST", data=data, params=params).json())
return self._parse_one(LabTechClient, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import Document
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechDocument
from pyconnectwise.responses.paginated_response import PaginatedResponse


class ClientsIdDocumentsEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "Documents", parent_endpoint=parent_endpoint)

def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}) -> PaginatedResponse[Document]:
def paginated(
self, page: int, page_size: int, params: dict[str, int | str] = {}
) -> PaginatedResponse[LabTechDocument]:
"""
Performs a GET request against the /Clients/{id}/Documents endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -19,26 +20,26 @@ def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}
page_size (int): The number of results to return per page.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
PaginatedResponse[Document]: The initialized PaginatedResponse object.
PaginatedResponse[LabTechDocument]: The initialized PaginatedResponse object.
"""
params["page"] = page
params["pageSize"] = page_size
return PaginatedResponse(
super()._make_request("GET", params=params),
Document,
LabTechDocument,
self,
page,
page_size,
)

def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[Document]:
def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[LabTechDocument]:
"""
Performs a GET request against the /Clients/{id}/Documents endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
list[Document]: The parsed response data.
list[LabTechDocument]: The parsed response data.
"""
return self._parse_many(Document, super()._make_request("GET", data=data, params=params).json())
return self._parse_many(LabTechDocument, super()._make_request("GET", data=data, params=params).json())
21 changes: 11 additions & 10 deletions src/pyconnectwise/endpoints/automate/ClientsIdEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
from pyconnectwise.endpoints.automate.ClientsIdPermissionsEndpoint import ClientsIdPermissionsEndpoint
from pyconnectwise.endpoints.automate.ClientsIdProductkeysEndpoint import ClientsIdProductkeysEndpoint
from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import Client
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechClient
from pyconnectwise.responses.paginated_response import PaginatedResponse


class ClientsIdEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "{id}", parent_endpoint=parent_endpoint)

self.productkeys = self._register_child_endpoint(ClientsIdProductkeysEndpoint(client, parent_endpoint=self))
self.licenses = self._register_child_endpoint(ClientsIdLicensesEndpoint(client, parent_endpoint=self))
self.permissions = self._register_child_endpoint(ClientsIdPermissionsEndpoint(client, parent_endpoint=self))
self.documents = self._register_child_endpoint(ClientsIdDocumentsEndpoint(client, parent_endpoint=self))
self.licenses = self._register_child_endpoint(ClientsIdLicensesEndpoint(client, parent_endpoint=self))
self.productkeys = self._register_child_endpoint(ClientsIdProductkeysEndpoint(client, parent_endpoint=self))

def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}) -> PaginatedResponse[Client]:
def paginated(
self, page: int, page_size: int, params: dict[str, int | str] = {}
) -> PaginatedResponse[LabTechClient]:
"""
Performs a GET request against the /Clients/{id} endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -28,26 +29,26 @@ def paginated(self, page: int, page_size: int, params: dict[str, int | str] = {}
page_size (int): The number of results to return per page.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
PaginatedResponse[Client]: The initialized PaginatedResponse object.
PaginatedResponse[LabTechClient]: The initialized PaginatedResponse object.
"""
params["page"] = page
params["pageSize"] = page_size
return PaginatedResponse(
super()._make_request("GET", params=params),
Client,
LabTechClient,
self,
page,
page_size,
)

def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> Client:
def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> LabTechClient:
"""
Performs a GET request against the /Clients/{id} endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
Client: The parsed response data.
LabTechClient: The parsed response data.
"""
return self._parse_one(Client, super()._make_request("GET", data=data, params=params).json())
return self._parse_one(LabTechClient, super()._make_request("GET", data=data, params=params).json())
21 changes: 10 additions & 11 deletions src/pyconnectwise/endpoints/automate/ClientsIdLicensesEndpoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Any

from pyconnectwise.endpoints.base.connectwise_endpoint import ConnectWiseEndpoint
from pyconnectwise.models.automate.LabTech.Models import ManagedLicense
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.models.automate import LabTechManagedLicense
from pyconnectwise.responses.paginated_response import PaginatedResponse


Expand All @@ -12,7 +11,7 @@ def __init__(self, client, parent_endpoint=None):

def paginated(
self, page: int, page_size: int, params: dict[str, int | str] = {}
) -> PaginatedResponse[ManagedLicense]:
) -> PaginatedResponse[LabTechManagedLicense]:
"""
Performs a GET request against the /Clients/{id}/Licenses endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -21,38 +20,38 @@ def paginated(
page_size (int): The number of results to return per page.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
PaginatedResponse[ManagedLicense]: The initialized PaginatedResponse object.
PaginatedResponse[LabTechManagedLicense]: The initialized PaginatedResponse object.
"""
params["page"] = page
params["pageSize"] = page_size
return PaginatedResponse(
super()._make_request("GET", params=params),
ManagedLicense,
LabTechManagedLicense,
self,
page,
page_size,
)

def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[ManagedLicense]:
def get(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> list[LabTechManagedLicense]:
"""
Performs a GET request against the /Clients/{id}/Licenses endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
list[ManagedLicense]: The parsed response data.
list[LabTechManagedLicense]: The parsed response data.
"""
return self._parse_many(ManagedLicense, super()._make_request("GET", data=data, params=params).json())
return self._parse_many(LabTechManagedLicense, super()._make_request("GET", data=data, params=params).json())

def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> ManagedLicense:
def post(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> LabTechManagedLicense:
"""
Performs a POST request against the /Clients/{id}/Licenses endpoint.
Parameters:
data (dict[str, Any]): The data to send in the request body.
params (dict[str, int | str]): The parameters to send in the request query string.
Returns:
ManagedLicense: The parsed response data.
LabTechManagedLicense: The parsed response data.
"""
return self._parse_one(ManagedLicense, super()._make_request("POST", data=data, params=params).json())
return self._parse_one(LabTechManagedLicense, super()._make_request("POST", data=data, params=params).json())
Loading

0 comments on commit e967f50

Please sign in to comment.