Skip to content

Commit

Permalink
Merge pull request #10 from HealthITAU/0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshify authored Aug 22, 2023
2 parents e7571e6 + 6961425 commit a95135f
Show file tree
Hide file tree
Showing 2,151 changed files with 22,213 additions and 28,399 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,5 @@ automate_json/automate_tickets.json
/automate_json/
/Out/
/merged_spec.json
merged_spec1.json
postprocess.py
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/pywise-datamodels.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/watcherTasks.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions generate_models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
source venv/scripts/activate

echo Enter JSON path
read jsonPath
echo Enter output filename/directory
read output

datamodel-codegen --input ${jsonPath} --output ${output} --target-python-version 3.10 --collapse-root-models --reuse-model --output-model-type pydantic_v2.BaseModel --base-class pyconnectwise.models.base.connectwise_model.ConnectWiseModel --use-union-operator --use-field-description --use-default --snake-case-field --disable-timestamp --use-standard-collections --use-schema-description --remove-special-field-name-prefix --capitalise-enum-members --set-default-enum-member --enum-field-as-literal all --use-default-kwarg --field-constraints
Binary file modified requirements.txt
Binary file not shown.
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())
Loading

0 comments on commit a95135f

Please sign in to comment.