zscaler-sdk-python 0.5.0__tar.gz → 0.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/PKG-INFO +5 -3
  2. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/README.md +4 -2
  3. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/pyproject.toml +1 -1
  4. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/__init__.py +1 -1
  5. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/utils.py +4 -2
  6. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/firewall.py +41 -58
  7. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/zpa_gateway.py +3 -3
  8. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/LICENSE.md +0 -0
  9. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/cache/__init__.py +0 -0
  10. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/cache/cache.py +0 -0
  11. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/cache/no_op_cache.py +0 -0
  12. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/cache/zscaler_cache.py +0 -0
  13. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/constants.py +0 -0
  14. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/errors/__init__.py +0 -0
  15. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/errors/error.py +0 -0
  16. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/errors/http_error.py +0 -0
  17. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/errors/zscaler_api_error.py +0 -0
  18. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/exceptions/__init__.py +0 -0
  19. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/exceptions/exceptions.py +0 -0
  20. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/logger.py +0 -0
  21. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/ratelimiter/__init__.py +0 -0
  22. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/ratelimiter/ratelimiter.py +0 -0
  23. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/user_agent.py +0 -0
  24. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/__init__.py +0 -0
  25. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/activate.py +0 -0
  26. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/admin_and_role_management.py +0 -0
  27. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/apptotal.py +0 -0
  28. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/audit_logs.py +0 -0
  29. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/authentication_settings.py +0 -0
  30. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/client.py +0 -0
  31. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/cloud_apps.py +0 -0
  32. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/device_management.py +0 -0
  33. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/dlp.py +0 -0
  34. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/errors.py +0 -0
  35. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/forwarding_control.py +0 -0
  36. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/isolation_profile.py +0 -0
  37. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/labels.py +0 -0
  38. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/locations.py +0 -0
  39. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/sandbox.py +0 -0
  40. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/security.py +0 -0
  41. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/ssl_inspection.py +0 -0
  42. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/traffic.py +0 -0
  43. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/url_categories.py +0 -0
  44. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/url_filtering.py +0 -0
  45. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/users.py +0 -0
  46. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/web_dlp.py +0 -0
  47. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zia/workload_groups.py +0 -0
  48. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/README.md +0 -0
  49. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/__init__.py +0 -0
  50. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/app_segments.py +0 -0
  51. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/app_segments_inspection.py +0 -0
  52. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/app_segments_pra.py +0 -0
  53. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/authdomains.py +0 -0
  54. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/certificates.py +0 -0
  55. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/client.py +0 -0
  56. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/cloud_connector_groups.py +0 -0
  57. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/connectors.py +0 -0
  58. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/emergency_access.py +0 -0
  59. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/errors.py +0 -0
  60. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/idp.py +0 -0
  61. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/inspection.py +0 -0
  62. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/isolation.py +0 -0
  63. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/lss.py +0 -0
  64. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/machine_groups.py +0 -0
  65. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/microtenants.py +0 -0
  66. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/policies.py +0 -0
  67. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/posture_profiles.py +0 -0
  68. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/privileged_remote_access.py +0 -0
  69. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/provisioning.py +0 -0
  70. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/saml_attributes.py +0 -0
  71. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/scim_attributes.py +0 -0
  72. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/scim_groups.py +0 -0
  73. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/segment_groups.py +0 -0
  74. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/server_groups.py +0 -0
  75. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/servers.py +0 -0
  76. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/service_edges.py +0 -0
  77. {zscaler_sdk_python-0.5.0 → zscaler_sdk_python-0.5.2}/zscaler/zpa/trusted_networks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zscaler-sdk-python
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Official Python SDK for the Zscaler Products (Beta)
5
5
  Home-page: https://github.com/zscaler/zscaler-sdk-python
6
6
  License: MIT
@@ -337,8 +337,10 @@ Contributors
337
337
  - Eddie Parra - [eparra](https://github.com/eparra)
338
338
  - Paul Abbot - [abbottp](https://github.com/abbottp)
339
339
 
340
- ## License
341
- MIT License
340
+ Thank you to [Mitch Kelly](https://github.com/mitchos/pyZscaler), creator of the [PyZscaler](https://github.com/mitchos/pyZscaler) SDK,
341
+ which this SDK was inspired on.
342
+
343
+ ## MIT License
342
344
 
343
345
  =======
344
346
 
@@ -287,8 +287,10 @@ Contributors
287
287
  - Eddie Parra - [eparra](https://github.com/eparra)
288
288
  - Paul Abbot - [abbottp](https://github.com/abbottp)
289
289
 
290
- ## License
291
- MIT License
290
+ Thank you to [Mitch Kelly](https://github.com/mitchos/pyZscaler), creator of the [PyZscaler](https://github.com/mitchos/pyZscaler) SDK,
291
+ which this SDK was inspired on.
292
+
293
+ ## MIT License
292
294
 
293
295
  =======
294
296
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "zscaler-sdk-python"
3
- version = "0.5.0"
3
+ version = "0.5.2"
4
4
  description = "Official Python SDK for the Zscaler Products (Beta)"
5
5
  authors = ["Zscaler, Inc. <devrel@zscaler.com>"]
6
6
  license = "MIT"
@@ -29,7 +29,7 @@ __license__ = "MIT"
29
29
  __contributors__ = [
30
30
  "William Guilherme",
31
31
  ]
32
- __version__ = "0.5.0"
32
+ __version__ = "0.5.2"
33
33
 
34
34
  from zscaler.zia import ZIAClientHelper # noqa
35
35
  from zscaler.zpa import ZPAClientHelper # noqa
@@ -166,6 +166,7 @@ def add_id_groups(id_groups: list, kwargs: dict, payload: dict):
166
166
  # payload[payload_key] = [{"id": int(item)} if isinstance(item, str) and item.isdigit() else item for item in value]
167
167
  # return
168
168
 
169
+
169
170
  def transform_common_id_fields(id_groups: list, kwargs: dict, payload: dict):
170
171
  for entry in id_groups:
171
172
  key, payload_key = entry
@@ -174,7 +175,9 @@ def transform_common_id_fields(id_groups: list, kwargs: dict, payload: dict):
174
175
  if key in ["zpa_gateway", "proxy_gateway", "zpa_server_group"]:
175
176
  # Handle zpa_gateway, proxy_gateway, and zpa_server_group
176
177
  if isinstance(value, dict):
177
- payload[payload_key] = {snake_to_camel(k): v for k, v in value.items() if k in ['id', 'name', 'external_id']}
178
+ payload[payload_key] = {
179
+ snake_to_camel(k): v for k, v in value.items() if k in ["id", "name", "external_id"]
180
+ }
178
181
  elif key in ["zpa_app_segments", "zpa_application_segments", "zpa_application_segment_groups"]:
179
182
  # Handle zpa_app_segments, zpa_application_segments, and zpa_application_segment_groups
180
183
  if isinstance(value, list):
@@ -575,4 +578,3 @@ def dump_response(
575
578
  log_lines.append(f"\n{response_body}")
576
579
  log_lines.append("-" * 68)
577
580
  logger.info("\n".join(log_lines))
578
-
@@ -513,11 +513,8 @@ class FirewallPolicyAPI:
513
513
  ... ip_addresses=['192.0.2.0/29', '192.0.2.8/29', '192.0.2.128/25'])
514
514
 
515
515
  """
516
-
517
- # Set payload to value of existing record
518
516
  payload = {snake_to_camel(k): v for k, v in self.get_ip_source_group(group_id).items()}
519
517
 
520
- # Update payload
521
518
  for key, value in kwargs.items():
522
519
  payload[snake_to_camel(key)] = value
523
520
 
@@ -554,30 +551,12 @@ class FirewallPolicyAPI:
554
551
 
555
552
  Returns:
556
553
  :obj:`Box`: The Network Application Group resource record.
554
+
555
+ Examples:
556
+ >>> pprint(zia.firewall.get_network_app_group('287342'))
557
+
557
558
  """
558
- response = self.rest.get(f"networkApplicationGroups/{group_id}")
559
-
560
- # If 'response' is a Box, it should contain the response data directly
561
- # If 'response' is an HTTP response, it should have a 'status_code' attribute
562
- if hasattr(response, "status_code"):
563
- # Check if the response is successful and the content is not empty
564
- if response.status_code == 200 and response.content:
565
- # Convert to Box for consistent return type
566
- return Box(response.json())
567
- else:
568
- # Handle non-200 responses
569
- response.raise_for_status()
570
- else:
571
- # Assume 'response' is a Box and contains the desired data
572
- if "ok" in response and response.ok:
573
- # 'response' is a Box with the expected data
574
- return response
575
- else:
576
- # Handle cases where the response Box does not contain the expected data
577
- # For example, you might want to check for an 'error' or 'message' field
578
- # and raise an exception or handle the situation as needed
579
- # Example: raise ValueError("Failed to retrieve the network application group.")
580
- return Box() # An empty Box indicates no data was found or an error occurred.
559
+ return self.rest.get(f"networkApplicationGroups/{group_id}")
581
560
 
582
561
  def delete_network_app_group(self, group_id: str) -> int:
583
562
  """
@@ -595,7 +574,7 @@ class FirewallPolicyAPI:
595
574
  """
596
575
  return self.rest.delete(f"networkApplicationGroups/{group_id}").status_code
597
576
 
598
- def add_network_app_group(self, name: str, network_applications: list, description: str = None) -> Box:
577
+ def add_network_app_group(self, name: str, network_applications: list, **kwargs) -> Box:
599
578
  """
600
579
  Adds a new Network Application Group.
601
580
 
@@ -615,22 +594,16 @@ class FirewallPolicyAPI:
615
594
  ... description='Additional information about the Network Application Group.')
616
595
 
617
596
  """
618
-
619
597
  payload = {
620
598
  "name": name,
621
599
  "networkApplications": network_applications,
622
- "description": description,
623
600
  }
624
601
 
625
- response = self.rest.post("networkApplicationGroups", json=payload)
626
- if isinstance(response, Response):
627
- # this is only true when the creation failed (status code is not 2xx)
628
- status_code = response.status_code
629
- # Handle error response
630
- raise Exception(f"API call failed with status {status_code}: {response.json()}")
631
- return response
602
+ # Add optional parameters to payload
603
+ for key, value in kwargs.items():
604
+ payload[snake_to_camel(key)] = value
632
605
 
633
- # return self.rest.post("networkApplicationGroups", json=payload)
606
+ return self.rest.post("networkApplicationGroups", json=payload)
634
607
 
635
608
  def update_network_app_group(self, group_id: str, **kwargs) -> Box:
636
609
  """
@@ -672,8 +645,6 @@ class FirewallPolicyAPI:
672
645
  payload[snake_to_camel(key)] = value
673
646
 
674
647
  resp = self.rest.put(f"networkApplicationGroups/{group_id}", json=payload).status_code
675
-
676
- # Return the object if it was updated successfully
677
648
  if not isinstance(resp, Response):
678
649
  return self.get_network_app_group(group_id)
679
650
 
@@ -938,10 +909,10 @@ class FirewallPolicyAPI:
938
909
  # Convert tuple list to dict and add to payload
939
910
  if ports is not None:
940
911
  for items in ports:
941
- port_range = [{"start": items[2]}]
912
+ port_dict = {"start": int(items[2])}
942
913
  if len(items) == 4:
943
- port_range.append({"end": items[3]})
944
- payload.setdefault(f"{items[0]}{items[1].title()}Ports", []).extend(port_range)
914
+ port_dict["end"] = int(items[3])
915
+ payload.setdefault(f"{items[0]}{items[1].title()}Ports", []).append(port_dict)
945
916
 
946
917
  # Add optional parameters to payload
947
918
  for key, value in kwargs.items():
@@ -949,13 +920,11 @@ class FirewallPolicyAPI:
949
920
 
950
921
  response = self.rest.post("networkServices", json=payload)
951
922
  if isinstance(response, Response):
952
- # this is only true when the creation failed (status code is not 2xx)
953
923
  status_code = response.status_code
954
- # Handle error response
955
924
  raise Exception(f"API call failed with status {status_code}: {response.json()}")
956
925
  return response
957
926
 
958
- def update_network_service(self, service_id: str, ports: list = None, **kwargs) -> Box:
927
+ def update_network_service(self, service_id: str, ports: list = None, **kwargs) -> dict:
959
928
  """
960
929
  Updates the specified Network Service.
961
930
 
@@ -981,7 +950,7 @@ class FirewallPolicyAPI:
981
950
  description (str): Additional information on the Network Service.
982
951
 
983
952
  Returns:
984
- :obj:`Box`: The newly created Network Service resource record.
953
+ :obj:`dict`: The updated Network Service resource record.
985
954
 
986
955
  Examples:
987
956
  Update the name and description for a Network Service:
@@ -992,33 +961,47 @@ class FirewallPolicyAPI:
992
961
 
993
962
  Updates the ports for a Network Service, leaving other fields intact:
994
963
 
995
- >>> zia.firewall.add_network_service('959093',
964
+ >>> zia.firewall.update_network_service('959093',
996
965
  ... ports=[
997
966
  ... ('dest', 'tcp', '500', '510')])
998
967
 
999
-
1000
968
  """
1001
- payload = {snake_to_camel(k): v for k, v in self.get_network_service(service_id).items()}
969
+ # Fetch the existing network service details
970
+ existing_service = self.get_network_service(service_id).to_dict()
971
+
972
+ # Build the payload
973
+ payload = {
974
+ "id": service_id,
975
+ "name": existing_service["name"],
976
+ "description": existing_service.get("description", ""),
977
+ "type": existing_service.get("type", "CUSTOM"),
978
+ }
1002
979
 
1003
980
  # Convert tuple list to dict and add to payload
1004
981
  if ports is not None:
1005
- # Clear existing ports and set new values
1006
982
  for items in ports:
1007
- port_key = f"{items[0]}{items[1].title()}Ports"
1008
- payload[port_key] = []
1009
- payload[port_key].append({"start": items[2]})
983
+ port_dict = {"start": int(items[2])}
1010
984
  if len(items) == 4:
1011
- payload[port_key].append({"end": items[3]})
985
+ port_dict["end"] = int(items[3])
986
+ payload.setdefault(f"{items[0]}{items[1].title()}Ports", []).append(port_dict)
987
+ else:
988
+ # Use existing ports if not provided
989
+ for key in ["src_tcp_ports", "dest_tcp_ports", "src_udp_ports", "dest_udp_ports"]:
990
+ if key in existing_service:
991
+ payload[snake_to_camel(key)] = existing_service[key]
1012
992
 
1013
993
  # Add optional parameters to payload
1014
994
  for key, value in kwargs.items():
1015
995
  payload[snake_to_camel(key)] = value
1016
996
 
1017
- resp = self.rest.put(f"networkServices/{service_id}", json=payload).status_code
997
+ # Remove invalid attributes from the payload
998
+ payload.pop("creator_context", None)
999
+ payload.pop("is_name_l10n_tag", None)
1018
1000
 
1019
- # Return the object if it was updated successfully
1020
- if not isinstance(resp, Response):
1021
- return self.get_network_service(service_id)
1001
+ response = self.rest.put(f"networkServices/{service_id}", json=payload)
1002
+ if isinstance(response, Response) and not response.ok:
1003
+ raise Exception(f"API call failed with status {response.status_code}: {response.json()}")
1004
+ return self.get_network_service(service_id)
1022
1005
 
1023
1006
  def list_time_windows(self) -> Box:
1024
1007
  """
@@ -97,7 +97,7 @@ class ZPAGatewayAPI:
97
97
  # Add zpa_server_group to kwargs
98
98
  if zpa_server_group:
99
99
  kwargs["zpa_server_group"] = zpa_server_group
100
-
100
+
101
101
  # Define the id groups specific to this function
102
102
  zpa_gateway_id_groups = [
103
103
  ("zpa_server_group", "zpaServerGroup"),
@@ -148,7 +148,7 @@ class ZPAGatewayAPI:
148
148
  ]
149
149
 
150
150
  transform_common_id_fields(zpa_gateway_id_groups, kwargs, payload)
151
-
151
+
152
152
  for key, value in kwargs.items():
153
153
  payload[snake_to_camel(key)] = value
154
154
 
@@ -156,7 +156,7 @@ class ZPAGatewayAPI:
156
156
  if isinstance(response, Response) and not response.ok:
157
157
  raise Exception(f"API call failed with status {response.status_code}: {response.json()}")
158
158
  return self.get_gateway(gateway_id)
159
-
159
+
160
160
  def delete_gateway(self, gateway_id):
161
161
  """
162
162
  Deletes the specified ZPA Gateway.