Skip to content

Commit

Permalink
[pre-commit.ci] automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 9, 2023
1 parent e1fc7e1 commit e07773d
Show file tree
Hide file tree
Showing 278 changed files with 1,165 additions and 3,412 deletions.
4 changes: 1 addition & 3 deletions src/pyconnectwise/clients/automate_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def _get_access_token(self) -> str:
)
auth_resp_json = auth_response.json()
token = auth_resp_json["AccessToken"]
self.token_expiry_time = datetime.fromisoformat(
auth_resp_json["ExpirationDate"]
)
self.token_expiry_time = datetime.fromisoformat(auth_resp_json["ExpirationDate"])
return token

def _refresh_access_token_if_necessary(self): # noqa: ANN202
Expand Down
12 changes: 3 additions & 9 deletions src/pyconnectwise/clients/connectwise_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def _make_request( # noqa: C901
if not response.ok:
with contextlib.suppress(json.JSONDecodeError):
details: dict = response.json()
if ( # noqa: SIM102 (Expecting to handle other codes in the future)
response.status_code == 400
):
if response.status_code == 400: # noqa: SIM102 (Expecting to handle other codes in the future)
if details.get("code") == "InvalidObject":
errors = details.get("errors", [])
if len(errors) > 1:
Expand All @@ -100,9 +98,7 @@ def _make_request( # noqa: C901
for error in errors:
if error.get("code") == "ObjectExists":
error.pop("code") # Don't need code in message
raise ObjectExistsError(
response, extra_message=json.dumps(error, indent=4)
)
raise ObjectExistsError(response, extra_message=json.dumps(error, indent=4))

if response.status_code == 400:
raise MalformedRequestException(response)
Expand All @@ -124,9 +120,7 @@ def _make_request( # noqa: C901
if "timeout" in (response.text + response.reason).lower():
if retry_count < self.config.max_retries:
retry_count += 1
return self._make_request(
method, url, data, params, headers, retry_count
)
return self._make_request(method, url, data, params, headers, retry_count)
raise Timeout(response=response)
raise ServerError(response)

Expand Down
4 changes: 1 addition & 3 deletions src/pyconnectwise/endpoints/automate/ApitokenEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class ApitokenEndpoint(
IPostable[AutomateTokenResult, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Apitoken", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Apitoken", parent_endpoint=parent_endpoint)
IGettable.__init__(self, AutomateAuthInformation)
IPostable.__init__(self, AutomateTokenResult)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

class ApprovalpoliciesEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Approvalpolicies", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Approvalpolicies", parent_endpoint=parent_endpoint)
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class AvtemplatepoliciesEndpoint(
IPostable[LabTechAVTemplatePolicy, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Avtemplatepolicies", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Avtemplatepolicies", parent_endpoint=parent_endpoint)
IPostable.__init__(self, LabTechAVTemplatePolicy)

def post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class AvtemplatepolicydataEndpoint(
IPostable[LabTechAVTemplatePolicyData, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Avtemplatepolicydata", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Avtemplatepolicydata", parent_endpoint=parent_endpoint)
IPostable.__init__(self, LabTechAVTemplatePolicyData)

def post(
Expand Down
8 changes: 2 additions & 6 deletions src/pyconnectwise/endpoints/automate/ClientsEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class ClientsEndpoint(
IPaginateable[LabTechClient, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Clients", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Clients", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechClient])
IPostable.__init__(self, LabTechClient)
IPaginateable.__init__(self, LabTechClient)
Expand Down Expand Up @@ -84,9 +82,7 @@ def get(
Returns:
list[LabTechClient]: The parsed response data.
"""
return self._parse_many(
LabTechClient, 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ClientsIdDocumentsEndpoint(
IPaginateable[LabTechDocument, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Documents", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Documents", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechDocument])
IPaginateable.__init__(self, LabTechDocument)

Expand Down
24 changes: 6 additions & 18 deletions src/pyconnectwise/endpoints/automate/ClientsIdEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,14 @@ class ClientsIdEndpoint(
IPaginateable[LabTechClient, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "{id}", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
IGettable.__init__(self, LabTechClient)
IPaginateable.__init__(self, LabTechClient)

self.permissions = self._register_child_endpoint(
ClientsIdPermissionsEndpoint(client, parent_endpoint=self)
)
self.licenses = self._register_child_endpoint(
ClientsIdLicensesEndpoint(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.licenses = self._register_child_endpoint(ClientsIdLicensesEndpoint(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))

def paginated(
self,
Expand Down Expand Up @@ -92,6 +82,4 @@ def get(
Returns:
LabTechClient: The parsed response data.
"""
return self._parse_one(
LabTechClient, super()._make_request("GET", data=data, params=params).json()
)
return self._parse_one(LabTechClient, super()._make_request("GET", data=data, params=params).json())
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ClientsIdLicensesEndpoint(
IPaginateable[LabTechManagedLicense, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Licenses", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Licenses", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechManagedLicense])
IPostable.__init__(self, LabTechManagedLicense)
IPaginateable.__init__(self, LabTechManagedLicense)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

class ClientsIdPermissionsEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Permissions", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Permissions", parent_endpoint=parent_endpoint)

def id(self, id: int) -> ClientsIdPermissionsIdEndpoint: # noqa: A002
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

class ClientsIdPermissionsIdEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "{id}", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)

def delete(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ClientsIdProductkeysEndpoint(
IPaginateable[LabTechProductKey, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Productkeys", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Productkeys", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechProductKey])
IPostable.__init__(self, LabTechProductKey)
IPaginateable.__init__(self, LabTechProductKey)
Expand Down
4 changes: 1 addition & 3 deletions src/pyconnectwise/endpoints/automate/CommandsEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ class CommandsEndpoint(
IPaginateable[LabTechCommand, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Commands", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Commands", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechCommand])
IPaginateable.__init__(self, LabTechCommand)

Expand Down
4 changes: 1 addition & 3 deletions src/pyconnectwise/endpoints/automate/CommandsIdEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class CommandsIdEndpoint(
IPaginateable[LabTechCommand, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "{id}", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "{id}", parent_endpoint=parent_endpoint)
IGettable.__init__(self, LabTechCommand)
IPaginateable.__init__(self, LabTechCommand)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ComputermenusEndpoint(
IPaginateable[LabTechComputerMenu, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Computermenus", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Computermenus", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerMenu])
IPostable.__init__(self, LabTechComputerMenu)
IPaginateable.__init__(self, LabTechComputerMenu)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersChassisEndpoint(
IPaginateable[LabTechComputerChassis, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Chassis", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Chassis", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerChassis])
IPaginateable.__init__(self, LabTechComputerChassis)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersDrivesEndpoint(
IPaginateable[LabTechComputerDrive, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Drives", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Drives", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerDrive])
IPaginateable.__init__(self, LabTechComputerDrive)

Expand Down
20 changes: 5 additions & 15 deletions src/pyconnectwise/endpoints/automate/ComputersEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,14 @@ class ComputersEndpoint(
IPaginateable[LabTechComputer, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Computers", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Computers", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputer])
IPaginateable.__init__(self, LabTechComputer)

self.memoryslots = self._register_child_endpoint(
ComputersMemoryslotsEndpoint(client, parent_endpoint=self)
)
self.software = self._register_child_endpoint(
ComputersSoftwareEndpoint(client, parent_endpoint=self)
)
self.drives = self._register_child_endpoint(
ComputersDrivesEndpoint(client, parent_endpoint=self)
)
self.chassis = self._register_child_endpoint(
ComputersChassisEndpoint(client, parent_endpoint=self)
)
self.memoryslots = self._register_child_endpoint(ComputersMemoryslotsEndpoint(client, parent_endpoint=self))
self.software = self._register_child_endpoint(ComputersSoftwareEndpoint(client, parent_endpoint=self))
self.drives = self._register_child_endpoint(ComputersDrivesEndpoint(client, parent_endpoint=self))
self.chassis = self._register_child_endpoint(ComputersChassisEndpoint(client, parent_endpoint=self))
self.maintenancemodes = self._register_child_endpoint(
ComputersMaintenancemodesEndpoint(client, parent_endpoint=self)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

class ComputersIdAlertsEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Alerts", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Alerts", parent_endpoint=parent_endpoint)
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@

class ComputersIdAlertsuspensionsEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Alertsuspensions", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Alertsuspensions", parent_endpoint=parent_endpoint)

self.templatediversion = self._register_child_endpoint(
ComputersIdAlertsuspensionsTemplatediversionEndpoint(
client, parent_endpoint=self
)
ComputersIdAlertsuspensionsTemplatediversionEndpoint(client, parent_endpoint=self)
)
self.maintenancewindow = self._register_child_endpoint(
ComputersIdAlertsuspensionsMaintenancewindowEndpoint(
client, parent_endpoint=self
)
ComputersIdAlertsuspensionsMaintenancewindowEndpoint(client, parent_endpoint=self)
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

class ComputersIdAlertsuspensionsMaintenancewindowEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Maintenancewindow", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Maintenancewindow", parent_endpoint=parent_endpoint)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

class ComputersIdAlertsuspensionsTemplatediversionEndpoint(ConnectWiseEndpoint):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Templatediversion", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Templatediversion", parent_endpoint=parent_endpoint)
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersIdBiosEndpoint(
IPaginateable[LabTechComputerBios, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Bios", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Bios", parent_endpoint=parent_endpoint)
IGettable.__init__(self, LabTechComputerBios)
IPaginateable.__init__(self, LabTechComputerBios)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ComputersIdCommandexecuteEndpoint(
IPaginateable[LabTechCommandExecute, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Commandexecute", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Commandexecute", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechCommandExecute])
IPostable.__init__(self, LabTechCommandExecute)
IPaginateable.__init__(self, LabTechCommandExecute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersIdCommandhistoryEndpoint(
IPaginateable[AutomateCommandHistory, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Commandhistory", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Commandhistory", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[AutomateCommandHistory])
IPaginateable.__init__(self, AutomateCommandHistory)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersIdComputerpatchingpoliciesEndpoint(
IPaginateable[LabTechComputerPatchingPolicy, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Computerpatchingpolicies", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Computerpatchingpolicies", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerPatchingPolicy])
IPaginateable.__init__(self, LabTechComputerPatchingPolicy)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersIdDevicesEndpoint(
IPaginateable[LabTechComputerDevice, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Devices", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Devices", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerDevice])
IPaginateable.__init__(self, LabTechComputerDevice)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ComputersIdDriversEndpoint(
IPaginateable[LabTechComputerDriver, ConnectWiseAutomateRequestParams],
):
def __init__(self, client, parent_endpoint=None) -> None: # noqa: ANN001
ConnectWiseEndpoint.__init__(
self, client, "Drivers", parent_endpoint=parent_endpoint
)
ConnectWiseEndpoint.__init__(self, client, "Drivers", parent_endpoint=parent_endpoint)
IGettable.__init__(self, list[LabTechComputerDriver])
IPaginateable.__init__(self, LabTechComputerDriver)

Expand Down
Loading

0 comments on commit e07773d

Please sign in to comment.