zscaler-sdk-python 0.1.3__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.
Files changed (75) hide show
  1. zscaler/__init__.py +35 -0
  2. zscaler/cache/__init__.py +0 -0
  3. zscaler/cache/cache.py +105 -0
  4. zscaler/cache/no_op_cache.py +66 -0
  5. zscaler/cache/zscaler_cache.py +159 -0
  6. zscaler/constants.py +26 -0
  7. zscaler/errors/__init__.py +0 -0
  8. zscaler/errors/error.py +10 -0
  9. zscaler/errors/http_error.py +20 -0
  10. zscaler/errors/zscaler_api_error.py +21 -0
  11. zscaler/exceptions/__init__.py +1 -0
  12. zscaler/exceptions/exceptions.py +101 -0
  13. zscaler/logger.py +57 -0
  14. zscaler/ratelimiter/__init__.py +0 -0
  15. zscaler/ratelimiter/ratelimiter.py +37 -0
  16. zscaler/user_agent.py +21 -0
  17. zscaler/utils.py +546 -0
  18. zscaler/zia/__init__.py +629 -0
  19. zscaler/zia/activate.py +51 -0
  20. zscaler/zia/admin_and_role_management.py +336 -0
  21. zscaler/zia/apptotal.py +71 -0
  22. zscaler/zia/audit_logs.py +93 -0
  23. zscaler/zia/authentication_settings.py +94 -0
  24. zscaler/zia/client.py +88 -0
  25. zscaler/zia/cloud_apps.py +402 -0
  26. zscaler/zia/device_management.py +90 -0
  27. zscaler/zia/dlp.py +772 -0
  28. zscaler/zia/errors.py +37 -0
  29. zscaler/zia/firewall.py +1064 -0
  30. zscaler/zia/forwarding_control.py +267 -0
  31. zscaler/zia/isolation_profile.py +83 -0
  32. zscaler/zia/labels.py +178 -0
  33. zscaler/zia/locations.py +645 -0
  34. zscaler/zia/sandbox.py +201 -0
  35. zscaler/zia/security.py +232 -0
  36. zscaler/zia/ssl_inspection.py +169 -0
  37. zscaler/zia/traffic.py +819 -0
  38. zscaler/zia/url_categories.py +422 -0
  39. zscaler/zia/url_filtering.py +306 -0
  40. zscaler/zia/users.py +378 -0
  41. zscaler/zia/web_dlp.py +291 -0
  42. zscaler/zia/workload_groups.py +58 -0
  43. zscaler/zia/zpa_gateway.py +179 -0
  44. zscaler/zpa/README.md +40 -0
  45. zscaler/zpa/__init__.py +655 -0
  46. zscaler/zpa/app_segments.py +317 -0
  47. zscaler/zpa/app_segments_inspection.py +295 -0
  48. zscaler/zpa/app_segments_pra.py +296 -0
  49. zscaler/zpa/certificates.py +230 -0
  50. zscaler/zpa/client.py +113 -0
  51. zscaler/zpa/cloud_connector_groups.py +75 -0
  52. zscaler/zpa/connectors.py +500 -0
  53. zscaler/zpa/emergency_access.py +170 -0
  54. zscaler/zpa/errors.py +37 -0
  55. zscaler/zpa/idp.py +83 -0
  56. zscaler/zpa/inspection.py +968 -0
  57. zscaler/zpa/isolation_profile.py +85 -0
  58. zscaler/zpa/lss.py +544 -0
  59. zscaler/zpa/machine_groups.py +79 -0
  60. zscaler/zpa/policies.py +824 -0
  61. zscaler/zpa/posture_profiles.py +120 -0
  62. zscaler/zpa/privileged_remote_access.py +827 -0
  63. zscaler/zpa/provisioning.py +262 -0
  64. zscaler/zpa/saml_attributes.py +96 -0
  65. zscaler/zpa/scim_attributes.py +115 -0
  66. zscaler/zpa/scim_groups.py +133 -0
  67. zscaler/zpa/segment_groups.py +183 -0
  68. zscaler/zpa/server_groups.py +211 -0
  69. zscaler/zpa/servers.py +198 -0
  70. zscaler/zpa/service_edges.py +388 -0
  71. zscaler/zpa/trusted_networks.py +125 -0
  72. zscaler_sdk_python-0.1.3.dist-info/LICENSE.md +21 -0
  73. zscaler_sdk_python-0.1.3.dist-info/METADATA +362 -0
  74. zscaler_sdk_python-0.1.3.dist-info/RECORD +75 -0
  75. zscaler_sdk_python-0.1.3.dist-info/WHEEL +4 -0
@@ -0,0 +1,629 @@
1
+ import datetime
2
+ import logging
3
+ import os
4
+ import re
5
+ import time
6
+ import uuid
7
+ from time import sleep
8
+
9
+ import requests
10
+ from box import Box, BoxList
11
+
12
+ from zscaler import __version__
13
+ from zscaler.cache.no_op_cache import NoOpCache
14
+ from zscaler.cache.zscaler_cache import ZscalerCache
15
+ from zscaler.errors.http_error import HTTPError, ZscalerAPIError
16
+ from zscaler.exceptions.exceptions import HTTPException, ZscalerAPIException
17
+ from zscaler.logger import setup_logging
18
+ from zscaler.ratelimiter.ratelimiter import RateLimiter
19
+ from zscaler.user_agent import UserAgent
20
+ from zscaler.utils import (
21
+ convert_keys_to_snake,
22
+ dump_request,
23
+ dump_response,
24
+ format_json_response,
25
+ obfuscate_api_key,
26
+ retry_with_backoff,
27
+ )
28
+ from zscaler.zia.client import ZIAClient
29
+ from zscaler.zia.activate import ActivationAPI
30
+ from zscaler.zia.admin_and_role_management import AdminAndRoleManagementAPI
31
+ from zscaler.zia.apptotal import AppTotalAPI
32
+ from zscaler.zia.audit_logs import AuditLogsAPI
33
+ from zscaler.zia.authentication_settings import AuthenticationSettingsAPI
34
+ from zscaler.zia.device_management import DeviceManagementAPI
35
+ from zscaler.zia.dlp import DLPAPI
36
+ from zscaler.zia.firewall import FirewallPolicyAPI
37
+ from zscaler.zia.forwarding_control import ForwardingControlAPI
38
+ from zscaler.zia.isolation_profile import IsolationProfileAPI
39
+ from zscaler.zia.labels import RuleLabelsAPI
40
+ from zscaler.zia.locations import LocationsAPI
41
+ from zscaler.zia.sandbox import CloudSandboxAPI
42
+ from zscaler.zia.security import SecurityPolicyAPI
43
+ from zscaler.zia.ssl_inspection import SSLInspectionAPI
44
+ from zscaler.zia.traffic import TrafficForwardingAPI
45
+ from zscaler.zia.url_categories import URLCategoriesAPI
46
+ from zscaler.zia.url_filtering import URLFilteringAPI
47
+ from zscaler.zia.users import UserManagementAPI
48
+ from zscaler.zia.web_dlp import WebDLPAPI
49
+ from zscaler.zia.workload_groups import WorkloadGroupsAPI
50
+ from zscaler.zia.zpa_gateway import ZPAGatewayAPI
51
+
52
+ # Setup the logger
53
+ setup_logging(logger_name="zscaler-sdk-python")
54
+ logger = logging.getLogger("zscaler-sdk-python")
55
+
56
+
57
+ class ZIAClientHelper(ZIAClient):
58
+ """
59
+ A Controller to access Endpoints in the Zscaler Internet Access (ZIA) API.
60
+
61
+ The ZIA object stores the session token and simplifies access to CRUD options within the ZIA platform.
62
+
63
+ Attributes:
64
+ api_key (str): The ZIA API key generated from the ZIA console.
65
+ username (str): The ZIA administrator username.
66
+ password (str): The ZIA administrator password.
67
+ cloud (str): The Zscaler cloud for your tenancy, accepted values are:
68
+
69
+ * ``zscaler``
70
+ * ``zscloud``
71
+ * ``zscalerbeta``
72
+ * ``zspreview``
73
+ * ``zscalerone``
74
+ * ``zscalertwo``
75
+ * ``zscalerthree``
76
+ * ``zscalergov``
77
+ * ``zscalerten``
78
+
79
+ override_url (str):
80
+ If supplied, this attribute can be used to override the production URL that is derived
81
+ from supplying the `cloud` attribute. Use this attribute if you have a non-standard tenant URL
82
+ (e.g. internal test instance etc). When using this attribute, there is no need to supply the `cloud`
83
+ attribute. The override URL will be prepended to the API endpoint suffixes. The protocol must be included
84
+ i.e. http:// or https://.
85
+
86
+ """
87
+
88
+ _vendor = "Zscaler"
89
+ _product = "Zscaler Internet Access"
90
+ _build = __version__
91
+ _env_base = "ZIA"
92
+ url = "https://zsapi.zscaler.net/api/v1"
93
+ env_cloud = "zscaler"
94
+
95
+ def __init__(self, cloud, timeout=240, cache=None, fail_safe=False, **kw):
96
+ self.api_key = kw.get("api_key", os.getenv(f"{self._env_base}_API_KEY"))
97
+ self.username = kw.get("username", os.getenv(f"{self._env_base}_USERNAME"))
98
+ self.password = kw.get("password", os.getenv(f"{self._env_base}_PASSWORD"))
99
+ # The 'cloud' parameter should have precedence over environment variables
100
+ self.env_cloud = cloud or kw.get("cloud") or os.getenv(f"{self._env_base}_CLOUD")
101
+ if not self.env_cloud:
102
+ raise ValueError(
103
+ f"Cloud environment must be set via the 'cloud' argument or the {self._env_base}_CLOUD environment variable."
104
+ )
105
+
106
+ # URL construction
107
+ if cloud == "zspreview":
108
+ self.url = f"https://admin.{self.env_cloud}.net/api/v1"
109
+ else:
110
+ # Use override URL if provided, else construct the URL
111
+ self.url = (
112
+ kw.get("override_url")
113
+ or os.getenv(f"{self._env_base}_OVERRIDE_URL")
114
+ or f"https://zsapi.{self.env_cloud}.net/api/v1"
115
+ )
116
+
117
+ self.conv_box = True
118
+ self.sandbox_token = kw.get("sandbox_token") or os.getenv(f"{self._env_base}_SANDBOX_TOKEN")
119
+ self.timeout = timeout
120
+ self.fail_safe = fail_safe
121
+ cache_enabled = os.environ.get("ZSCALER_CLIENT_CACHE_ENABLED", "true").lower() == "true"
122
+ if cache is None:
123
+ if cache_enabled:
124
+ ttl = int(os.environ.get("ZSCALER_CLIENT_CACHE_DEFAULT_TTL", 3600))
125
+ tti = int(os.environ.get("ZSCALER_CLIENT_CACHE_DEFAULT_TTI", 1800))
126
+ self.cache = ZscalerCache(ttl=ttl, tti=tti)
127
+ else:
128
+ self.cache = NoOpCache()
129
+ else:
130
+ self.cache = cache
131
+ # Initialize user-agent
132
+ ua = UserAgent()
133
+ self.user_agent = ua.get_user_agent_string()
134
+ # Initialize rate limiter
135
+ # You may want to adjust these parameters as per your rate limit configuration
136
+ self.rate_limiter = RateLimiter(
137
+ get_limit=2, # Adjust as per actual limit
138
+ post_put_delete_limit=2, # Adjust as per actual limit
139
+ get_freq=2, # Adjust as per actual frequency (in seconds)
140
+ post_put_delete_freq=2, # Adjust as per actual frequency (in seconds)
141
+ )
142
+ self.headers = {
143
+ "Content-Type": "application/json",
144
+ "Accept": "application/json",
145
+ "User-Agent": self.user_agent,
146
+ }
147
+ self.session_timeout_offset = datetime.timedelta(minutes=5)
148
+ self.session_refreshed = None
149
+ self.auth_details = None
150
+ self.session_id = None
151
+ self.authenticate()
152
+
153
+ def extractJSessionIDFromHeaders(self, header):
154
+ session_id_str = header.get("Set-Cookie", "")
155
+
156
+ if not session_id_str:
157
+ raise ValueError("no Set-Cookie header received")
158
+
159
+ regex = re.compile(r"JSESSIONID=(.*?);")
160
+ result = regex.search(session_id_str)
161
+
162
+ if not result:
163
+ raise ValueError("couldn't find JSESSIONID in header value")
164
+
165
+ return result.group(1)
166
+
167
+ def is_session_expired(self):
168
+ if self.auth_details is None:
169
+ return True
170
+ now = datetime.datetime.now()
171
+ if self.auth_details["passwordExpiryTime"] > 0 and (
172
+ self.session_refreshed + datetime.timedelta(seconds=-self.session_timeout_offset) < now
173
+ ):
174
+ return True
175
+ return False
176
+
177
+ @retry_with_backoff(retries=5)
178
+ def authenticate(self) -> Box:
179
+ """
180
+ Creates a ZIA authentication session.
181
+ """
182
+ api_key_chars = list(self.api_key)
183
+ api_obf = obfuscate_api_key(api_key_chars)
184
+
185
+ payload = {
186
+ "apiKey": api_obf["key"],
187
+ "username": self.username,
188
+ "password": self.password,
189
+ "timestamp": api_obf["timestamp"],
190
+ }
191
+ resp = requests.request(
192
+ "POST",
193
+ self.url + "/authenticatedSession",
194
+ json=payload,
195
+ headers=self.headers,
196
+ timeout=self.timeout,
197
+ )
198
+ if resp.status_code > 299:
199
+ return resp
200
+ self.session_refreshed = datetime.datetime.now()
201
+ self.session_id = self.extractJSessionIDFromHeaders(resp.headers)
202
+ self.auth_details = resp.json()
203
+ return resp
204
+
205
+ def deauthenticate(self):
206
+ """
207
+ Ends the ZIA authentication session.
208
+ """
209
+ logout_url = self.url + "/authenticatedSession"
210
+
211
+ headers = self.headers.copy()
212
+ headers.update({"Cookie": f"JSESSIONID={self.session_id}"})
213
+
214
+ try:
215
+ response = requests.delete(logout_url, headers=headers, timeout=self.timeout)
216
+ if response.status_code == 204:
217
+ self.session_id = None
218
+ self.auth_details = None
219
+ return True
220
+ else:
221
+ return False
222
+ except requests.RequestException as e:
223
+ return False
224
+
225
+ def send(self, method, path, json=None, params=None, data=None, headers=None):
226
+ """
227
+ Send a request to the ZIA API.
228
+
229
+ Parameters:
230
+ - method (str): The HTTP method.
231
+ - path (str): API endpoint path.
232
+ - json (dict, optional): Request payload. Defaults to None.
233
+ Returns:
234
+ - Response: Response object from the request.
235
+ """
236
+ is_sandbox = "zscsb" in path
237
+ api = self.url
238
+ if is_sandbox:
239
+ api = f"https://csbapi.{self.env_cloud}.net"
240
+ url = f"{api}/{path.lstrip('/')}"
241
+ start_time = time.time()
242
+ # Update headers to include the user agent
243
+ headers_with_user_agent = self.headers.copy()
244
+ headers_with_user_agent["User-Agent"] = self.user_agent
245
+ # Generate a unique UUID for this request
246
+ request_uuid = uuid.uuid4()
247
+ if headers is not None:
248
+ headers_with_user_agent.update(headers)
249
+ dump_request(
250
+ logger,
251
+ url,
252
+ method,
253
+ json,
254
+ params,
255
+ headers_with_user_agent,
256
+ request_uuid,
257
+ body=not is_sandbox,
258
+ )
259
+ # Check cache before sending request
260
+ cache_key = self.cache.create_key(url, params)
261
+ if method == "GET" and self.cache.contains(cache_key):
262
+ resp = self.cache.get(cache_key)
263
+ dump_response(
264
+ logger=logger,
265
+ url=url,
266
+ method=method,
267
+ params=params,
268
+ resp=resp,
269
+ request_uuid=request_uuid,
270
+ start_time=start_time,
271
+ from_cache=True,
272
+ )
273
+ return resp
274
+
275
+ attempts = 0
276
+ while attempts < 5: # Trying a maximum of 5 times
277
+ try:
278
+ # If the token is None or expired, fetch a new token
279
+ if self.is_session_expired():
280
+ logger.warning("The provided sesion expired. Refreshing...")
281
+ self.authenticate()
282
+ resp = requests.request(
283
+ method=method,
284
+ url=url,
285
+ json=json,
286
+ data=data,
287
+ params=params,
288
+ headers=headers_with_user_agent,
289
+ timeout=self.timeout,
290
+ cookies={"JSESSIONID": self.session_id},
291
+ )
292
+ dump_response(
293
+ logger=logger,
294
+ url=url,
295
+ params=params,
296
+ method=method,
297
+ resp=resp,
298
+ request_uuid=request_uuid,
299
+ start_time=start_time,
300
+ )
301
+ if resp.status_code == 429: # HTTP Status code 429 indicates "Too Many Requests"
302
+ sleep_time = int(
303
+ resp.headers.get("Retry-After", 2)
304
+ ) # Default to 60 seconds if 'Retry-After' header is missing
305
+ logger.warning(f"Rate limit exceeded. Retrying in {sleep_time} seconds.")
306
+ sleep(sleep_time)
307
+ attempts += 1
308
+ continue
309
+ else:
310
+ break
311
+ except requests.RequestException as e:
312
+ if attempts == 4: # If it's the last attempt, raise the exception
313
+ logger.error(f"Failed to send {method} request to {url} after 5 attempts. Error: {str(e)}")
314
+ raise e
315
+ else:
316
+ logger.warning(f"Failed to send {method} request to {url}. Retrying... Error: {str(e)}")
317
+ attempts += 1
318
+ sleep(5) # Sleep for 5 seconds before retrying
319
+
320
+ # If Non-GET call, clear the
321
+ if method != "GET":
322
+ self.cache.delete(cache_key)
323
+
324
+ # Detailed logging for request and response
325
+ try:
326
+ response_data = resp.json()
327
+ except ValueError: # Using ValueError for JSON decoding errors
328
+ response_data = resp.text
329
+ # check if call was succesful
330
+ if 200 > resp.status_code or resp.status_code > 299:
331
+ # create errors
332
+ try:
333
+ error = ZscalerAPIError(url, resp, response_data)
334
+ if self.fail_safe:
335
+ raise ZscalerAPIException(url, resp, response_data)
336
+ except ZscalerAPIException:
337
+ raise
338
+ except Exception:
339
+ error = HTTPError(url, resp, response_data)
340
+ if self.fail_safe:
341
+ logger.error(response_data)
342
+ raise HTTPException(url, resp, response_data)
343
+ logger.error(error)
344
+ # Cache the response if it's a successful GET request
345
+ if method == "GET" and resp.status_code == 200:
346
+ self.cache.add(cache_key, resp)
347
+ return resp
348
+
349
+ def get(self, path, json=None, params=None):
350
+ """
351
+ Send a GET request to the ZIA API.
352
+
353
+ Parameters:
354
+ - path (str): API endpoint path.
355
+ - data (dict, optional): Request payload. Defaults to None.
356
+ Returns:
357
+ - Response: Response object from the request.
358
+ """
359
+
360
+ # Use rate limiter before making a request
361
+ should_wait, delay = self.rate_limiter.wait("GET")
362
+ if should_wait:
363
+ time.sleep(delay)
364
+
365
+ # Now proceed with sending the request
366
+ resp = self.send("GET", path, json, params)
367
+ formatted_resp = format_json_response(resp, box_attrs=dict())
368
+ return formatted_resp
369
+
370
+ def put(self, path, json=None, params=None):
371
+ should_wait, delay = self.rate_limiter.wait("PUT")
372
+ if should_wait:
373
+ time.sleep(delay)
374
+ resp = self.send("PUT", path, json, params)
375
+ formatted_resp = format_json_response(resp, box_attrs=dict())
376
+ return formatted_resp
377
+
378
+ def post(self, path, json=None, params=None, data=None, headers=None):
379
+ should_wait, delay = self.rate_limiter.wait("POST")
380
+ if should_wait:
381
+ time.sleep(delay)
382
+ resp = self.send("POST", path, json, params, data=data, headers=headers)
383
+ formatted_resp = format_json_response(resp, box_attrs=dict())
384
+ return formatted_resp
385
+
386
+ def delete(self, path, json=None, params=None):
387
+ should_wait, delay = self.rate_limiter.wait("DELETE")
388
+ if should_wait:
389
+ time.sleep(delay)
390
+ return self.send("DELETE", path, json, params)
391
+
392
+ ERROR_MESSAGES = {
393
+ "UNEXPECTED_STATUS": "Unexpected status code {status_code} received for page {page}.",
394
+ "MISSING_DATA_KEY": "The key '{data_key_name}' was not found in the response for page {page}.",
395
+ "EMPTY_RESULTS": "No results found for page {page}.",
396
+ }
397
+
398
+ def get_paginated_data(self, path=None, data_key_name=None, data_per_page=5, expected_status_code=200):
399
+ """
400
+ Fetch paginated data from the ZIA API.
401
+ ...
402
+
403
+ Returns:
404
+ - list: List of fetched items.
405
+ - str: Error message, if any occurred.
406
+ """
407
+
408
+ page = 1
409
+ ret_data = []
410
+ error_message = None
411
+
412
+ while True:
413
+ required_url = f"{path}"
414
+ should_wait, delay = self.rate_limiter.wait("GET")
415
+ if should_wait:
416
+ time.sleep(delay)
417
+
418
+ # Now proceed with sending the request
419
+ response = self.send(
420
+ method="GET",
421
+ path=required_url,
422
+ params={"page": page, "pageSize": data_per_page},
423
+ )
424
+
425
+ if response.status_code != expected_status_code:
426
+ error_message = self.ERROR_MESSAGES["UNEXPECTED_STATUS"].format(status_code=response.status_code, page=page)
427
+ logger.error(error_message)
428
+ break
429
+ data_json = response.json()
430
+ if isinstance(data_json, list):
431
+ data = data_json
432
+ else:
433
+ data = data_json.get(data_key_name)
434
+
435
+ if data is None:
436
+ error_message = self.ERROR_MESSAGES["MISSING_DATA_KEY"].format(data_key_name=data_key_name, page=page)
437
+ logger.error(error_message)
438
+ break
439
+
440
+ if not data: # Checks for empty data
441
+ logger.info(self.ERROR_MESSAGES["EMPTY_RESULTS"].format(page=page))
442
+ break
443
+
444
+ ret_data.extend(convert_keys_to_snake(data))
445
+
446
+ # Check for more pages
447
+ if len(data) == 0 or isinstance(data_json, dict) and int(response.json().get("totalPages")) <= page + 1:
448
+ break
449
+
450
+ page += 1
451
+
452
+ return BoxList(ret_data), error_message
453
+
454
+ @property
455
+ def admin_and_role_management(self):
456
+ """
457
+ The interface object for the :ref:`ZIA Admin and Role Management interface <zia-admin_and_role_management>`.
458
+
459
+ """
460
+ return AdminAndRoleManagementAPI(self)
461
+
462
+ @property
463
+ def apptotal(self):
464
+ """
465
+ The interface object for the :ref:`ZIA AppTotal interface <zia-apptotal>`.
466
+
467
+ """
468
+ return AppTotalAPI(self)
469
+
470
+ @property
471
+ def audit_logs(self):
472
+ """
473
+ The interface object for the :ref:`ZIA Admin Audit Logs interface <zia-audit_logs>`.
474
+
475
+ """
476
+ return AuditLogsAPI(self)
477
+
478
+ @property
479
+ def activate(self):
480
+ """
481
+ The interface object for the :ref:`ZIA Activation interface <zia-activate>`.
482
+
483
+ """
484
+ return ActivationAPI(self)
485
+
486
+ @property
487
+ def dlp(self):
488
+ """
489
+ The interface object for the :ref:`ZIA DLP Dictionaries interface <zia-dlp>`.
490
+
491
+
492
+ """
493
+ return DLPAPI(self)
494
+
495
+ @property
496
+ def firewall(self):
497
+ """
498
+ The interface object for the :ref:`ZIA Firewall Policies interface <zia-firewall>`.
499
+
500
+ """
501
+ return FirewallPolicyAPI(self)
502
+
503
+ @property
504
+ def forwarding_control(self):
505
+ """
506
+ The interface object for the :ref:`ZIA Forwarding Control Policies interface <zia-forwarding_control>`.
507
+
508
+ """
509
+ return ForwardingControlAPI(self)
510
+
511
+ @property
512
+ def labels(self):
513
+ """
514
+ The interface object for the :ref:`ZIA Rule Labels interface <zia-labels>`.
515
+
516
+ """
517
+ return RuleLabelsAPI(self)
518
+
519
+ @property
520
+ def device_management(self):
521
+ """
522
+ The interface object for the :ref:`ZIA device interface <zia-device_management>`.
523
+
524
+ """
525
+ return DeviceManagementAPI(self)
526
+
527
+ @property
528
+ def locations(self):
529
+ """
530
+ The interface object for the :ref:`ZIA Locations interface <zia-locations>`.
531
+
532
+ """
533
+ return LocationsAPI(self)
534
+
535
+ @property
536
+ def sandbox(self):
537
+ """
538
+ The interface object for the :ref:`ZIA Cloud Sandbox interface <zia-sandbox>`.
539
+
540
+ """
541
+ return CloudSandboxAPI(self)
542
+
543
+ @property
544
+ def security(self):
545
+ """
546
+ The interface object for the :ref:`ZIA Security Policy Settings interface <zia-security>`.
547
+
548
+ """
549
+ return SecurityPolicyAPI(self)
550
+
551
+ @property
552
+ def authentication_settings(self):
553
+ """
554
+ The interface object for the :ref:`ZIA Authentication Security Settings interface <zia-authentication_settings>`.
555
+
556
+ """
557
+ return AuthenticationSettingsAPI(self)
558
+
559
+ @property
560
+ def ssl(self):
561
+ """
562
+ The interface object for the :ref:`ZIA SSL Inspection interface <zia-ssl_inspection>`.
563
+
564
+ """
565
+ return SSLInspectionAPI(self)
566
+
567
+ @property
568
+ def traffic(self):
569
+ """
570
+ The interface object for the :ref:`ZIA Traffic Forwarding interface <zia-traffic>`.
571
+
572
+ """
573
+ return TrafficForwardingAPI(self)
574
+
575
+ @property
576
+ def url_categories(self):
577
+ """
578
+ The interface object for the :ref:`ZIA URL Categories interface <zia-url_categories>`.
579
+
580
+ """
581
+ return URLCategoriesAPI(self)
582
+
583
+ @property
584
+ def url_filtering(self):
585
+ """
586
+ The interface object for the :ref:`ZIA URL Filtering interface <zia-url_filtering>`.
587
+
588
+ """
589
+ return URLFilteringAPI(self)
590
+
591
+ @property
592
+ def users(self):
593
+ """
594
+ The interface object for the :ref:`ZIA User Management interface <zia-users>`.
595
+
596
+ """
597
+ return UserManagementAPI(self)
598
+
599
+ @property
600
+ def web_dlp(self):
601
+ """
602
+ The interface object for the :ref:`ZIA Web DLP interface <zia-web_dlp>`.
603
+
604
+ """
605
+ return WebDLPAPI(self)
606
+
607
+ @property
608
+ def zpa_gateway(self):
609
+ """
610
+ The interface object for the :ref:`ZPA Gateway <zia-zpa_gateway>`.
611
+
612
+ """
613
+ return ZPAGatewayAPI(self)
614
+
615
+ @property
616
+ def isolation_profile(self):
617
+ """
618
+ The interface object for the :ref:`ZIA Cloud Browser Isolation Profile <zia-isolation_profile>`.
619
+
620
+ """
621
+ return IsolationProfileAPI(self)
622
+
623
+ @property
624
+ def workload_groups(self):
625
+ """
626
+ The interface object for the :ref:`ZIA Workload Groups <zia-workload_groups>`.
627
+
628
+ """
629
+ return WorkloadGroupsAPI(self)
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # Copyright (c) 2023, Zscaler Inc.
4
+ #
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+ #
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+
18
+ from zscaler.zia import ZIAClient
19
+
20
+
21
+ class ActivationAPI:
22
+ def __init__(self, client: ZIAClient):
23
+ self.rest = client
24
+
25
+ def status(self) -> str:
26
+ """
27
+ Returns the activation status for a configuration change.
28
+
29
+ Returns:
30
+ :obj:`str`
31
+ Configuration status.
32
+
33
+ Examples:
34
+ >>> config_status = zia.config.status()
35
+
36
+ """
37
+ return self.rest.get("status").status
38
+
39
+ def activate(self) -> str:
40
+ """
41
+ Activates configuration changes.
42
+
43
+ Returns:
44
+ :obj:`str`
45
+ Configuration status.
46
+
47
+ Examples:
48
+ >>> config_activate = zia.config.activate()
49
+
50
+ """
51
+ return self.rest.post("status/activate").status