Skip to content

Commit

Permalink
Fixed additional flake8 linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Mar 29, 2024
1 parent febbc97 commit 9502151
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
12 changes: 9 additions & 3 deletions zscaler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,19 @@ def dump_response(logger, url: str, method: str, resp, params, request_uuid: str
response_body = resp.text

if from_cache:
log_lines.append(f"\n---[ ZSCALER SDK RESPONSE | ID:{request_uuid} | FROM CACHE | DURATION:{duration_ms}ms ]-------------------------------")
log_lines.append(
f"\n---[ ZSCALER SDK RESPONSE | ID:{request_uuid} | "
f"FROM CACHE | DURATION:{duration_ms}ms ]" + "-" * 31
)
else:
log_lines.append(f"\n---[ ZSCALER SDK RESPONSE | ID:{request_uuid} | DURATION:{duration_ms}ms ]-------------------------------")
log_lines.append(
f"\n---[ ZSCALER SDK RESPONSE | ID:{request_uuid} | "
f"DURATION:{duration_ms}ms ]" + "-" * 46
)
log_lines.append(f"{method} {full_url}")
for key, value in response_headers_dict.items():
log_lines.append(f"{key}: {value}")
if response_body and response_body != "" and response_body != "null":
log_lines.append(f"\n{response_body}")
log_lines.append("--------------------------------------------------------------------")
log_lines.append("-" * 68)
logger.info('\n'.join(log_lines))
2 changes: 1 addition & 1 deletion zscaler/zia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __init__(self, cloud, timeout=240, cache=None, fail_safe=False, **kw):
self.env_cloud = cloud or kw.get("cloud") or os.getenv(f"{self._env_base}_CLOUD")
if not self.env_cloud:
raise ValueError(
f"The cloud environment must be set via the 'cloud' argument or the {self._env_base}_CLOUD environment variable."
f"Cloud environment must be set via the 'cloud' argument or the {self._env_base}_CLOUD environment variable."
)

# URL construction
Expand Down
15 changes: 10 additions & 5 deletions zscaler/zpa/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def list_issued_certificates(self, **kwargs) -> BoxList:
**kwargs: Optional keyword args.
Keyword Args:
**max_items (int, optional):
max_items (int, optional):
The maximum number of items to request before stopping iteration.
**max_pages (int, optional):
max_pages (int, optional):
The maximum number of pages to request before stopping iteration.
**pagesize (int, optional):
pagesize (int, optional):
Specifies the page size. The default size is 20, but the maximum size is 500.
**search (str, optional):
search (str, optional):
The search string used to match against features and fields.
Returns:
Expand All @@ -51,7 +51,12 @@ def list_issued_certificates(self, **kwargs) -> BoxList:
... print(cert)
"""
list, _ = self.rest.get_paginated_data(path="/clientlessCertificate/issued", data_key_name="list", **kwargs, api_version="v2")
list, _ = self.rest.get_paginated_data(
path="/clientlessCertificate/issued",
data_key_name="list",
**kwargs,
api_version="v2"
)
return list

def list_all_certificates(self, **kwargs) -> BoxList:
Expand Down
23 changes: 16 additions & 7 deletions zscaler/zpa/provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ def list_provisioning_keys(self, key_type: str, **kwargs) -> BoxList:
Args:
key_type (str): The type of provisioning key, accepted values are:
``connector`` and ``service_edge``.
**kwargs: Optional keyword args.
Keyword Args:
**max_items (int, optional):
max_items (int, optional):
The maximum number of items to request before stopping iteration.
**max_pages (int, optional):
max_pages (int, optional):
The maximum number of pages to request before stopping iteration.
**pagesize (int, optional):
pagesize (int, optional):
Specifies the page size. The default size is 20, but the maximum size is 500.
**search (str, optional):
search (str, optional):
The search string used to match against features and fields.
Returns:
Expand All @@ -70,7 +69,10 @@ def list_provisioning_keys(self, key_type: str, **kwargs) -> BoxList:
... print(key)
"""
list, _ = self.rest.get_paginated_data(path=f"/associationType/{simplify_key_type(key_type)}/provisioningKey", data_key_name="list", **kwargs)
list, _ = self.rest.get_paginated_data(
path=f"/associationType/{simplify_key_type(key_type)}/provisioningKey",
data_key_name="list", **kwargs
)
return list

def get_provisioning_key(self, key_id: str, key_type: str) -> Box:
Expand Down Expand Up @@ -215,7 +217,14 @@ def update_provisioning_key(self, key_id: str, key_type: str, **kwargs) -> Box:
for key, value in kwargs.items():
payload[snake_to_camel(key)] = value

resp = self.rest.put(f"associationType/{simplify_key_type(key_type)}/provisioningKey/{key_id}", json=payload).status_code
resp = self.rest.put(
f"associationType/{simplify_key_type(key_type)}/provisioningKey/{key_id}",
json=payload
).status_code

# Return the object if it was updated successfully
if not isinstance(resp, Response):
return self.get_provisioning_key(key_id, key_type=key_type)

# Return the object if it was updated successfully
if not isinstance(resp, Response):
Expand Down
15 changes: 10 additions & 5 deletions zscaler/zpa/scim_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def list_attributes_by_idp(self, idp_id: str, **kwargs) -> BoxList:
**kwargs: Optional keyword args.
Keyword Args:
**max_items (int):
max_items (int):
The maximum number of items to request before stopping iteration.
**max_pages (int):
max_pages (int):
The maximum number of pages to request before stopping iteration.
**pagesize (int):
pagesize (int):
Specifies the page size. The default size is 20, but the maximum size is 500.
**search (str, optional):
search (str, optional):
The search string used to match against features and fields.
Returns:
Expand All @@ -49,7 +49,12 @@ def list_attributes_by_idp(self, idp_id: str, **kwargs) -> BoxList:
... pprint(scim_attribute)
"""
list, _ = self.rest.get_paginated_data(path=f"/idp/{idp_id}/scimattribute", data_key_name="list", **kwargs, api_version="v1")
list, _ = self.rest.get_paginated_data(
path=f"/idp/{idp_id}/scimattribute",
data_key_name="list",
**kwargs,
api_version="v1"
)
return list

def get_attribute(self, idp_id: str, attribute_id: str) -> Box:
Expand Down

0 comments on commit 9502151

Please sign in to comment.