zscaler-sdk-python 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
zscaler/__init__.py CHANGED
@@ -29,7 +29,7 @@ __license__ = "MIT"
29
29
  __contributors__ = [
30
30
  "William Guilherme",
31
31
  ]
32
- __version__ = "0.2.0"
32
+ __version__ = "0.3.0"
33
33
 
34
34
  from zscaler.zia import ZIAClientHelper # noqa
35
35
  from zscaler.zpa import ZPAClientHelper # noqa
zscaler/constants.py CHANGED
@@ -9,8 +9,11 @@ ZPA_BASE_URLS = {
9
9
  "PREVIEW": "https://config.zpapreview.net",
10
10
  "QA": "https://config.qa.zpath.net",
11
11
  "QA2": "https://pdx2-zpa-config.qa2.zpath.net",
12
+ "DEV": "https://public-api.dev.zpath.net",
12
13
  }
13
14
 
15
+ DEV_AUTH_URL = "https://authn1.dev.zpath.net/authn/v1/oauth/token"
16
+
14
17
  RETRYABLE_STATUS_CODES = {429, 500, 502, 503, 504}
15
18
  MAX_RETRIES = 5
16
19
  BACKOFF_FACTOR = 1
zscaler/zpa/__init__.py CHANGED
@@ -11,7 +11,7 @@ from box import BoxList
11
11
  from zscaler import __version__
12
12
  from zscaler.cache.no_op_cache import NoOpCache
13
13
  from zscaler.cache.zscaler_cache import ZscalerCache
14
- from zscaler.constants import ZPA_BASE_URLS
14
+ from zscaler.constants import ZPA_BASE_URLS, DEV_AUTH_URL
15
15
  from zscaler.errors.http_error import HTTPError, ZscalerAPIError
16
16
  from zscaler.exceptions.exceptions import HTTPException, ZscalerAPIException
17
17
  from zscaler.logger import setup_logging
@@ -40,6 +40,7 @@ from zscaler.zpa.isolation import IsolationAPI
40
40
  from zscaler.zpa.lss import LSSConfigControllerAPI
41
41
  from zscaler.zpa.machine_groups import MachineGroupsAPI
42
42
  from zscaler.zpa.policies import PolicySetsAPI
43
+ from zscaler.zpa.policiesv2 import PolicySetsV2API
43
44
  from zscaler.zpa.posture_profiles import PostureProfilesAPI
44
45
  from zscaler.zpa.privileged_remote_access import PrivilegedRemoteAccessAPI
45
46
  from zscaler.zpa.provisioning import ProvisioningKeyAPI
@@ -151,7 +152,7 @@ class ZPAClientHelper(ZPAClient):
151
152
  @retry_with_backoff(retries=5)
152
153
  def login(self):
153
154
  """Log in to the ZPA API and set the access token for subsequent requests."""
154
- data = urllib.parse.urlencode({"client_id": self.client_id, "client_secret": self.client_secret})
155
+ params = {"client_id": self.client_id, "client_secret": self.client_secret}
155
156
  headers = {
156
157
  "Content-Type": "application/x-www-form-urlencoded",
157
158
  "Accept": "application/json",
@@ -159,6 +160,9 @@ class ZPAClientHelper(ZPAClient):
159
160
  }
160
161
  try:
161
162
  url = f"{self.baseurl}/signin"
163
+ if self.cloud == "DEV":
164
+ url = DEV_AUTH_URL + "?grant_type=CLIENT_CREDENTIALS"
165
+ data = urllib.parse.urlencode(params)
162
166
  resp = requests.post(url, data=data, headers=headers, timeout=self.timeout)
163
167
  # Avoid logging all data from the response, focus on the status and a summary instead
164
168
  logger.info("Login attempt with status: %d", resp.status_code)
@@ -571,6 +575,14 @@ class ZPAClientHelper(ZPAClient):
571
575
  """
572
576
  return PolicySetsAPI(self)
573
577
 
578
+ @property
579
+ def policiesv2(self):
580
+ """
581
+ The interface object for the :ref:`ZPA Policy Sets V2 interface <zpa-policiesv2>`.
582
+
583
+ """
584
+ return PolicySetsV2API(self)
585
+
574
586
  @property
575
587
  def posture_profiles(self):
576
588
  """
@@ -91,6 +91,40 @@ class ApplicationSegmentAPI:
91
91
  return app
92
92
  return None
93
93
 
94
+ def get_segments_by_type(self, application_type: str, expand_all: bool = False, **kwargs) -> Box:
95
+ """
96
+ Retrieve all configured application segments of a specified type, optionally expanding all related data.
97
+
98
+ Args:
99
+ application_type (str): Type of application segment to retrieve. Must be one of "BROWSER_ACCESS", "INSPECT", "SECURE_REMOTE_ACCESS".
100
+ expand_all (bool, optional): Whether to expand all related data. Defaults to False.
101
+
102
+ Keyword Args:
103
+ max_items (int, optional): The maximum number of items to request before stopping iteration.
104
+ max_pages (int, optional): The maximum number of pages to request before stopping iteration.
105
+ pagesize (int, optional): Specifies the page size. The default size is 20, but the maximum size is 500.
106
+ page (int, optional): Specifies the page number to begin fetching from.
107
+ search (str, optional): The search string used to match against features and fields.
108
+
109
+ Returns:
110
+ BoxList: List of application segments.
111
+
112
+ Examples:
113
+ >>> app_type = 'BROWSER_ACCESS'
114
+ >>> expand_all = True
115
+ >>> search = "ba_server01"
116
+ >>> app_segments = zpa.app_segments.get_segments_by_type(app_type, expand_all, search=search)
117
+ """
118
+ params = {"applicationType": application_type, "expandAll": "true" if expand_all else "false"}
119
+ # Include additional search parameters if specified
120
+ if "search" in kwargs:
121
+ params["search"] = kwargs["search"]
122
+
123
+ result, error = self.rest.get_paginated_data(path="/application/getAppsByType", params=params, **kwargs)
124
+ if error:
125
+ return BoxList([]) # Return an empty BoxList on failure due to the error
126
+ return result
127
+
94
128
  def delete_segment(self, segment_id: str, force_delete: bool = False) -> int:
95
129
  """
96
130
  Delete an application segment.