Skip to content

Commit

Permalink
🚑 Fixed endpoint imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshify committed Jul 24, 2023
1 parent 2c2259f commit 8ab4ec8
Show file tree
Hide file tree
Showing 1,969 changed files with 10,848 additions and 31,444 deletions.
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.

25 changes: 6 additions & 19 deletions src/pyconnectwise/clients/automate_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@
from pyconnectwise.endpoints.automate.CommandsEndpoint import CommandsEndpoint
from pyconnectwise.endpoints.automate.ComputersEndpoint import ComputersEndpoint
from pyconnectwise.endpoints.automate.ContactsEndpoint import ContactsEndpoint
from pyconnectwise.endpoints.automate.DataviewfoldersEndpoint import (
DataviewfoldersEndpoint,
)
from pyconnectwise.endpoints.automate.DataviewfoldersEndpoint import DataviewfoldersEndpoint
from pyconnectwise.endpoints.automate.DataviewsEndpoint import DataviewsEndpoint
from pyconnectwise.endpoints.automate.DrivesEndpoint import DrivesEndpoint
from pyconnectwise.endpoints.automate.ExternalsystemcredentialsEndpoint import (
ExternalsystemcredentialsEndpoint,
)
from pyconnectwise.endpoints.automate.ExternalsystemcredentialsEndpoint import ExternalsystemcredentialsEndpoint
from pyconnectwise.endpoints.automate.GroupsEndpoint import GroupsEndpoint
from pyconnectwise.endpoints.automate.LocationsEndpoint import LocationsEndpoint
from pyconnectwise.endpoints.automate.LookupsEndpoint import LookupsEndpoint
from pyconnectwise.endpoints.automate.MonitorsEndpoint import MonitorsEndpoint
from pyconnectwise.endpoints.automate.NetworkdevicesEndpoint import (
NetworkdevicesEndpoint,
)
from pyconnectwise.endpoints.automate.NetworkdevicesEndpoint import NetworkdevicesEndpoint
from pyconnectwise.endpoints.automate.PatchactionsEndpoint import PatchactionsEndpoint
from pyconnectwise.endpoints.automate.PermissionsEndpoint import PermissionsEndpoint
from pyconnectwise.endpoints.automate.ProbeconfigurationEndpoint import (
ProbeconfigurationEndpoint,
)
from pyconnectwise.endpoints.automate.ProbeconfigurationEndpoint import ProbeconfigurationEndpoint
from pyconnectwise.endpoints.automate.ScriptfoldersEndpoint import ScriptfoldersEndpoint
from pyconnectwise.endpoints.automate.ScriptingEndpoint import ScriptingEndpoint
from pyconnectwise.endpoints.automate.ScriptsEndpoint import ScriptsEndpoint
Expand Down Expand Up @@ -113,15 +105,10 @@ def _get_access_token(self) -> str:
auth_response = requests.post(
f"{self._get_url()}/apitoken",
json={"UserName": self.username, "Password": self.password},
headers={
"Content-Type": "application/json",
"ClientId": self.client_id,
},
headers={"Content-Type": "application/json", "ClientId": self.client_id},
).json()
token = auth_response["AccessToken"]
self.token_expiry_time = datetime.fromisoformat(
auth_response["ExpirationDate"]
)
self.token_expiry_time = datetime.fromisoformat(auth_response["ExpirationDate"])
except Exception as e:
print(e)
return token
Expand Down
8 changes: 2 additions & 6 deletions src/pyconnectwise/clients/manage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def _get_url(self) -> str:
"""
return f"https://{self.manage_url}/{self.codebase.strip('/')}/apis/3.0"

def _try_get_codebase_from_api(
self, manage_url: str, company_name: str, headers: dict[str, str]
) -> str | None:
def _try_get_codebase_from_api(self, manage_url: str, company_name: str, headers: dict[str, str]) -> str | None:
"""
Tries to retrieve the codebase from the API using the provided company url, company name and headers.
Expand All @@ -102,9 +100,7 @@ def _try_get_codebase_from_api(
result = ""
try:
url = f"https://{manage_url}/login/companyinfo/{company_name}"
result = (
requests.request("GET", url, headers=headers).json().get("Codebase")
)
result = requests.request("GET", url, headers=headers).json().get("Codebase")
except:
result = None
return result
Expand Down
21 changes: 5 additions & 16 deletions src/pyconnectwise/endpoints/automate/ApitokenEndpoint.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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.automate.Automate.Api.Domain.Contracts.Security import AuthInformation
from pyconnectwise.models.base.message_model import GenericMessageModel
from pyconnectwise.responses.paginated_response import PaginatedResponse

Expand All @@ -12,9 +10,7 @@ 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] = {}) -> AuthInformation:
"""
Performs a GET request against the /Apitoken endpoint.
Expand All @@ -24,14 +20,9 @@ def get(
Returns:
AuthInformation: The parsed response data.
"""
return self._parse_one(
AuthInformation,
super()._make_request("GET", data=data, params=params).json(),
)
return self._parse_one(AuthInformation, 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] = {}) -> TokenResult:
"""
Performs a POST request against the /Apitoken endpoint.
Expand All @@ -41,6 +32,4 @@ def post(
Returns:
TokenResult: The parsed response data.
"""
return self._parse_one(
TokenResult, super()._make_request("POST", data=data, params=params).json()
)
return self._parse_one(TokenResult, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ 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] = {}) -> AVTemplatePolicy:
"""
Performs a POST request against the /Avtemplatepolicies endpoint.
Expand All @@ -22,7 +20,4 @@ def post(
Returns:
AVTemplatePolicy: The parsed response data.
"""
return self._parse_one(
AVTemplatePolicy,
super()._make_request("POST", data=data, params=params).json(),
)
return self._parse_one(AVTemplatePolicy, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@

class AvtemplatepolicydataEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(
client, "Avtemplatepolicydata", parent_endpoint=parent_endpoint
)
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] = {}) -> AVTemplatePolicyData:
"""
Performs a POST request against the /Avtemplatepolicydata endpoint.
Expand All @@ -24,7 +20,4 @@ def post(
Returns:
AVTemplatePolicyData: The parsed response data.
"""
return self._parse_one(
AVTemplatePolicyData,
super()._make_request("POST", data=data, params=params).json(),
)
return self._parse_one(AVTemplatePolicyData, super()._make_request("POST", data=data, params=params).json())
20 changes: 5 additions & 15 deletions src/pyconnectwise/endpoints/automate/ClientsEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ 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[Client]:
"""
Performs a GET request against the /Clients endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -47,9 +45,7 @@ def paginated(
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[Client]:
"""
Performs a GET request against the /Clients endpoint.
Expand All @@ -59,13 +55,9 @@ def get(
Returns:
list[Client]: The parsed response data.
"""
return self._parse_many(
Client, super()._make_request("GET", data=data, params=params).json()
)
return self._parse_many(Client, 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] = {}) -> Client:
"""
Performs a POST request against the /Clients endpoint.
Expand All @@ -75,6 +67,4 @@ def post(
Returns:
Client: The parsed response data.
"""
return self._parse_one(
Client, super()._make_request("POST", data=data, params=params).json()
)
return self._parse_one(Client, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ 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[Document]:
"""
Performs a GET request against the /Clients/{id}/Documents endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -33,9 +31,7 @@ def paginated(
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[Document]:
"""
Performs a GET request against the /Clients/{id}/Documents endpoint.
Expand All @@ -45,6 +41,4 @@ def get(
Returns:
list[Document]: The parsed response data.
"""
return self._parse_many(
Document, super()._make_request("GET", data=data, params=params).json()
)
return self._parse_many(Document, super()._make_request("GET", data=data, params=params).json())
44 changes: 11 additions & 33 deletions src/pyconnectwise/endpoints/automate/ClientsIdEndpoint.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
from typing import Any

from pyconnectwise.endpoints.automate.ClientsIdDocumentsEndpoint import (
ClientsIdDocumentsEndpoint,
)
from pyconnectwise.endpoints.automate.ClientsIdLicensesEndpoint import (
ClientsIdLicensesEndpoint,
)
from pyconnectwise.endpoints.automate.ClientsIdPermissionsEndpoint import (
ClientsIdPermissionsEndpoint,
)
from pyconnectwise.endpoints.automate.ClientsIdProductkeysEndpoint import (
ClientsIdProductkeysEndpoint,
)
from pyconnectwise.endpoints.automate.ClientsIdDocumentsEndpoint import ClientsIdDocumentsEndpoint
from pyconnectwise.endpoints.automate.ClientsIdLicensesEndpoint import ClientsIdLicensesEndpoint
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
Expand All @@ -22,22 +14,12 @@ class ClientsIdEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "{id}", parent_endpoint=parent_endpoint)

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.productkeys = self._register_child_endpoint(
ClientsIdProductkeysEndpoint(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[Client]:
"""
Performs a GET request against the /Clients/{id} endpoint and returns an initialized PaginatedResponse object.
Expand All @@ -58,9 +40,7 @@ def paginated(
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] = {}) -> Client:
"""
Performs a GET request against the /Clients/{id} endpoint.
Expand All @@ -70,6 +50,4 @@ def get(
Returns:
Client: The parsed response data.
"""
return self._parse_one(
Client, super()._make_request("GET", data=data, params=params).json()
)
return self._parse_one(Client, super()._make_request("GET", data=data, params=params).json())
18 changes: 4 additions & 14 deletions src/pyconnectwise/endpoints/automate/ClientsIdLicensesEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def paginated(
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[ManagedLicense]:
"""
Performs a GET request against the /Clients/{id}/Licenses endpoint.
Expand All @@ -45,14 +43,9 @@ def get(
Returns:
list[ManagedLicense]: The parsed response data.
"""
return self._parse_many(
ManagedLicense,
super()._make_request("GET", data=data, params=params).json(),
)
return self._parse_many(ManagedLicense, 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] = {}) -> ManagedLicense:
"""
Performs a POST request against the /Clients/{id}/Licenses endpoint.
Expand All @@ -62,7 +55,4 @@ def post(
Returns:
ManagedLicense: The parsed response data.
"""
return self._parse_one(
ManagedLicense,
super()._make_request("POST", data=data, params=params).json(),
)
return self._parse_one(ManagedLicense, super()._make_request("POST", data=data, params=params).json())
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import Any

from pyconnectwise.endpoints.automate.ClientsIdPermissionsIdEndpoint import (
ClientsIdPermissionsIdEndpoint,
)
from pyconnectwise.endpoints.automate.ClientsIdPermissionsIdEndpoint import ClientsIdPermissionsIdEndpoint
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
Expand Up @@ -9,9 +9,7 @@ class ClientsIdPermissionsIdEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None):
super().__init__(client, "{id}", parent_endpoint=parent_endpoint)

def delete(
self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}
) -> GenericMessageModel:
def delete(self, data: dict[str, Any] = {}, params: dict[str, int | str] = {}) -> GenericMessageModel:
"""
Performs a DELETE request against the /Clients/{id}/Permissions/{id} endpoint.
Expand All @@ -21,7 +19,4 @@ def delete(
Returns:
GenericMessageModel: The parsed response data.
"""
return self._parse_one(
GenericMessageModel,
super()._make_request("DELETE", data=data, params=params).json(),
)
return self._parse_one(GenericMessageModel, super()._make_request("DELETE", data=data, params=params).json())
Loading

0 comments on commit 8ab4ec8

Please sign in to comment.