zscaler-sdk-python 1.0.0__py2.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 +34 -0
  2. zscaler/cache/__init__.py +0 -0
  3. zscaler/cache/cache.py +105 -0
  4. zscaler/cache/no_op_cache.py +68 -0
  5. zscaler/cache/zscaler_cache.py +161 -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 +24 -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 +39 -0
  16. zscaler/user_agent.py +23 -0
  17. zscaler/utils.py +577 -0
  18. zscaler/zia/__init__.py +657 -0
  19. zscaler/zia/activate.py +52 -0
  20. zscaler/zia/admin_and_role_management.py +344 -0
  21. zscaler/zia/apptotal.py +71 -0
  22. zscaler/zia/audit_logs.py +95 -0
  23. zscaler/zia/authentication_settings.py +98 -0
  24. zscaler/zia/client.py +88 -0
  25. zscaler/zia/cloud_apps.py +406 -0
  26. zscaler/zia/device_management.py +90 -0
  27. zscaler/zia/dlp.py +784 -0
  28. zscaler/zia/errors.py +37 -0
  29. zscaler/zia/firewall.py +1104 -0
  30. zscaler/zia/forwarding_control.py +271 -0
  31. zscaler/zia/isolation_profile.py +83 -0
  32. zscaler/zia/labels.py +180 -0
  33. zscaler/zia/locations.py +661 -0
  34. zscaler/zia/sandbox.py +180 -0
  35. zscaler/zia/security.py +236 -0
  36. zscaler/zia/ssl_inspection.py +175 -0
  37. zscaler/zia/traffic.py +853 -0
  38. zscaler/zia/url_categories.py +442 -0
  39. zscaler/zia/url_filtering.py +310 -0
  40. zscaler/zia/users.py +386 -0
  41. zscaler/zia/web_dlp.py +295 -0
  42. zscaler/zia/workload_groups.py +58 -0
  43. zscaler/zia/zpa_gateway.py +187 -0
  44. zscaler/zpa/__init__.py +683 -0
  45. zscaler/zpa/app_segments.py +331 -0
  46. zscaler/zpa/app_segments_inspection.py +311 -0
  47. zscaler/zpa/app_segments_pra.py +310 -0
  48. zscaler/zpa/certificates.py +234 -0
  49. zscaler/zpa/client.py +113 -0
  50. zscaler/zpa/cloud_connector_groups.py +75 -0
  51. zscaler/zpa/connectors.py +518 -0
  52. zscaler/zpa/emergency_access.py +178 -0
  53. zscaler/zpa/errors.py +37 -0
  54. zscaler/zpa/idp.py +83 -0
  55. zscaler/zpa/inspection.py +1012 -0
  56. zscaler/zpa/isolation_profile.py +85 -0
  57. zscaler/zpa/lss.py +568 -0
  58. zscaler/zpa/machine_groups.py +79 -0
  59. zscaler/zpa/policies.py +848 -0
  60. zscaler/zpa/posture_profiles.py +122 -0
  61. zscaler/zpa/privileged_remote_access.py +862 -0
  62. zscaler/zpa/provisioning.py +271 -0
  63. zscaler/zpa/saml_attributes.py +100 -0
  64. zscaler/zpa/scim_attributes.py +117 -0
  65. zscaler/zpa/scim_groups.py +146 -0
  66. zscaler/zpa/segment_groups.py +191 -0
  67. zscaler/zpa/server_groups.py +217 -0
  68. zscaler/zpa/servers.py +202 -0
  69. zscaler/zpa/service_edges.py +404 -0
  70. zscaler/zpa/trusted_networks.py +127 -0
  71. zscaler_sdk_python-1.0.0.dist-info/LICENSE.md +21 -0
  72. zscaler_sdk_python-1.0.0.dist-info/METADATA +59 -0
  73. zscaler_sdk_python-1.0.0.dist-info/RECORD +75 -0
  74. zscaler_sdk_python-1.0.0.dist-info/WHEEL +6 -0
  75. zscaler_sdk_python-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,406 @@
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
+ from zscaler.utils import convert_keys
18
+ from zscaler.zia import ZIAClient
19
+
20
+
21
+ class CloudAppsAPI:
22
+ def __init__(self, client: ZIAClient):
23
+ self.rest = client
24
+
25
+ @staticmethod
26
+ def _convert_ids_to_dict_list(id_list):
27
+ """Helper function to convert a list of IDs into a list of dictionaries.
28
+
29
+ Args:
30
+ id_list (list): A list of IDs (str).
31
+
32
+ Returns:
33
+ list: A list of dictionaries, each with an 'id' key.
34
+ """
35
+ return [{"id": str(id)} for id in id_list]
36
+
37
+ def bulk_update(self, sanction_state: str, **kwargs):
38
+ """
39
+ Updates application status and tag information for predefined or custom cloud applications based on the
40
+ IDs specified.
41
+
42
+ Args:
43
+ sanction_state (str): The sanction state to apply to the cloud applications.
44
+
45
+ Accepted values are:
46
+
47
+ ``sanctioned``: The cloud application is sanctioned.
48
+ ``unsanctioned``: The cloud application is unsanctioned.
49
+ ``any``: The cloud application is either sanctioned or unsanctioned.
50
+
51
+ **kwargs:
52
+ Optional keyword args
53
+
54
+ Keyword Args:
55
+ application_ids (list): A list of cloud application IDs to update.
56
+ custom_tag_ids (list): A list of custom tag IDs to apply to the cloud applications.
57
+
58
+ Returns:
59
+ :obj:`dict`: The response from the ZIA API.
60
+
61
+ Examples:
62
+ Update the sanction state of a cloud application::
63
+
64
+ zia.cloud_apps.bulk_update("sanctioned", application_ids=["12345"])
65
+
66
+ Update the sanction state and custom tags of a cloud application::
67
+
68
+ zia.cloud_apps.bulk_update("sanctioned", application_ids=["12345"], custom_tag_ids=["67890"])
69
+
70
+ """
71
+ # Mapping for user-friendly sanction state values to API-expected values
72
+ sanction_state_mapping = {
73
+ "sanctioned": "SANCTIONED",
74
+ "unsanctioned": "UN_SANCTIONED",
75
+ "any": "ANY",
76
+ }
77
+
78
+ # Convert user-friendly sanction state to ZIA API-expected value
79
+ api_sanction_state = sanction_state_mapping.get(sanction_state.lower())
80
+ if not api_sanction_state:
81
+ raise ValueError(
82
+ f"Invalid sanction state: {sanction_state}. Accepted values are 'sanctioned', 'unsanctioned', or 'any'."
83
+ )
84
+
85
+ payload = {"sanctionedState": api_sanction_state}
86
+
87
+ # Process application_ids if provided in kwargs
88
+ application_ids = kwargs.pop("application_ids", None)
89
+ if application_ids is not None:
90
+ payload["applicationIds"] = application_ids
91
+
92
+ # Process custom_tag_ids if provided in kwargs
93
+ custom_tag_ids = kwargs.pop("custom_tag_ids", None)
94
+ if custom_tag_ids is not None:
95
+ payload["customTags"] = self._convert_ids_to_dict_list(custom_tag_ids)
96
+
97
+ return self.rest.put("cloudApplications/bulkUpdate", json=payload).status_code
98
+
99
+ def export_shadow_it_report(self, duration: str = "LAST_1_DAYS", **kwargs) -> str:
100
+ """
101
+ Export the Shadow IT Report (in CSV format) for the cloud applications recognized by Zscaler
102
+ based on their usage in your organisation.
103
+
104
+ Args:
105
+ duration (str):
106
+ Filters the data by using predefined time frames. Defaults to last day.
107
+
108
+ Possible values: ``LAST_1_DAYS``, ``LAST_7_DAYS``, ``LAST_15_DAYS``, ``LAST_MONTH``, ``LAST_QUARTER``
109
+ **kwargs:
110
+ Arbitrary keyword arguments for filtering the report.
111
+
112
+ Keyword Args:
113
+ app_name (str): Filters the data based on the cloud application name that matches the specified string.
114
+ order (dict):
115
+ Sorts the list in increasing or decreasing order based on the specified attribute.
116
+
117
+ Example format for this parameter:
118
+
119
+ ``order={"on": "RISK_SCORE", "by": "INCREASING"}``
120
+
121
+ Possible values for ``on``:
122
+
123
+ ``RISK_SCORE``, ``APPLICATION``, ``APPLICATION_CATEGORY``,
124
+ ``SANCTIONED_STATE``, ``TOTAL_BYTES``, ``UPLOAD_BYTES``, ``DOWNLOAD_BYTES``, ``AUTHENTICATED_USERS``,
125
+ ``TRANSACTION_COUNT``, ``UNAUTH_LOCATION``, ``LAST_ACCESSED``.
126
+
127
+ Possible values for ``by``:
128
+
129
+ ``INCREASING``, ``DECREASING``.
130
+ application_category (str): Filters the data based on the cloud application category.
131
+
132
+ Possible values: ``ANY``, ``NONE``, ``WEB_MAIL``, ``SOCIAL_NETWORKING``, ``STREAMING``, ``P2P``,
133
+ ``INSTANT_MESSAGING``, ``WEB_SEARCH``, ``GENERAL_BROWSING``, ``ADMINISTRATION``, ``ENTERPRISE_COLLABORATION``,
134
+ ``BUSINESS_PRODUCTIVITY``, ``SALES_AND_MARKETING``, ``SYSTEM_AND_DEVELOPMENT``, ``CONSUMER``, ``FILE_SHARE``,
135
+ ``HOSTING_PROVIDER``, ``IT_SERVICES``, ``DNS_OVER_HTTPS``, ``HUMAN_RESOURCES``, ``LEGAL``, ``HEALTH_CARE``,
136
+ ``FINANCE``, ``CUSTOM_CAPP``
137
+ data_consumed (dict):
138
+ Filters the data by cloud application usage in terms of total data uploaded and downloaded.
139
+
140
+ Example format for this parameter:
141
+
142
+ data_consumed={"min": 100, "max": 1000}
143
+
144
+ ``min`` and ``max`` fields specify the range respectively.
145
+ risk_index (int):
146
+ Filters the data based on the risk index assigned to cloud applications.
147
+
148
+ Possible values: ``1``, ``2``, ``3``, ``4``, ``5``
149
+ sanctioned_state (str):
150
+ Filters the data based on the status of cloud applications.
151
+
152
+ Possible values: ``UN_SANCTIONED``, ``SANCTIONED``, ``ANY``
153
+ employees (str):
154
+ Filters the data based on the employee count of the cloud application vendor.
155
+
156
+ Possible values: ``NONE``, ``RANGE_1_100``, ``RANGE_100_1000``, ``RANGE_1000_10000``,
157
+ ``RANGE_10000_INF``
158
+ supported_certifications (dict): Filters the cloud applications by security certifications.
159
+
160
+ Example format for this parameter:
161
+
162
+ ``supported_certifications={"operation": "INCLUDE", "value": ["ISO_27001", "HIPAA"]}``
163
+
164
+ Possible values for ``operation`` field: ``INCLUDE`` and ``EXCLUDE``.
165
+
166
+ Possible values for ``value`` field: ``NONE``, ``CSA_STAR``, ``ISO_27001``, ``HIPAA``, ``FISMA``,
167
+ ``FEDRAMP``, ``SOC2``, ``ISO_27018``, ``PCI_DSS``, ``ISO_27017``, ``SOC1``, ``SOC3``, ``GDPR``,
168
+ ``CCPA``, ``FERPA``, ``COPPA``, ``HITECH``, ``EU_US_SWISS_PRIVACY_SHIELD``,
169
+ ``EU_US_PRIVACY_SHIELD_FRAMEWORK``, ``CISP``, ``AICPA``, ``FIPS``, ``SAFE_BIOPHARMA``, ``ISAE_3000``,
170
+ ``SSAE_18``, ``NIST``, ``ISO_14001``, ``SOC``, ``TRUSTE``, ``ISO_26262``, ``ISO_20252``, ``RGPD``,
171
+ ``ISO_20243``, ``ISO_10002``, ``JIS_Q_15001_2017``, ``ISMAP``.
172
+ source_ip_restriction (str):
173
+ Filters the cloud applications based on whether they have source IP restrictions.
174
+
175
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
176
+ mfa_support (str): Filters the cloud applications based on whether they support multi-factor authentication.
177
+
178
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
179
+ admin_audit_logs (str): Filters the cloud applications based on whether they support admin audit logging.
180
+
181
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
182
+ had_breach_in_last_3_years (str):
183
+ Filters the cloud applications based on data breaches in the last three years.
184
+
185
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
186
+ have_poor_items_of_service (str): Filters the cloud applications based on their terms of service.
187
+
188
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
189
+ password_strength (str): Filters the cloud applications based on whether they require strong passwords.
190
+
191
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
192
+ ssl_pinned (str): Filters the cloud applications based on whether they use SSL Pinning.
193
+
194
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
195
+ evasive (str): Filters the cloud applications based on their capability to bypass traditional firewalls.
196
+
197
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
198
+ have_http_security_header_support (str): Filters the cloud applications by the presence of security headers.
199
+
200
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
201
+ dns_caa_policy (str): Filters the cloud applications by the presence of DNS CAA policy.
202
+
203
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
204
+ have_weak_cipher_support (str): Filters the cloud applications based on the cryptographic keys used.
205
+
206
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
207
+ ssl_certification_validity (str): Filters the cloud applications based on SSL certificate validity.
208
+
209
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
210
+ file_sharing (str): Filters the cloud applications based on whether they include file-sharing provision.
211
+
212
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
213
+ malware_scanning_content (str):
214
+ Filters the cloud applications based on whether they include malware content.
215
+
216
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
217
+ remote_access_screen_sharing (str):
218
+ Filters the cloud applications based on whether they support remote access and screen sharing.
219
+
220
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
221
+ sender_policy_framework (str):
222
+ Filters the cloud applications based on whether they support Sender Policy Framework.
223
+
224
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
225
+ domain_keys_identified_mail (str):
226
+ Filters the cloud applications based on whether they support DomainKeys Identified Mail.
227
+
228
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
229
+ domain_based_message_authentication (str):
230
+ Filters the cloud applications based on whether they support Domain-based Message Authentication.
231
+
232
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
233
+ vulnerable_disclosure_program (str):
234
+ Filters the cloud applications based on whether they support Vulnerability Disclosure Policy.
235
+
236
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
237
+ waf_support (str): Filters the cloud applications based on whether WAF is enabled for the applications.
238
+
239
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
240
+ vulnerability (str):
241
+ Filters the cloud applications based on whether they have published Common Vulnerabilities and
242
+ Exposures (CVE).
243
+
244
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
245
+ valid_ssl_certificate (str):
246
+ Filters the cloud applications based on whether they have a valid SSL certificate.
247
+
248
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
249
+ data_encryption_in_transit (str):
250
+ Filters the cloud applications based on whether they support data encryption in transit.
251
+
252
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
253
+ vulnerable_to_heart_bleed (str):
254
+ Filters the cloud applications based on whether they are vulnerable to Heartbleed attack.
255
+
256
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
257
+ vulnerable_to_poodle (str):
258
+ Filters the cloud applications based on whether they are vulnerable to Poodle attack.
259
+
260
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
261
+ vulnerable_to_log_jam (str):
262
+ Filters the cloud applications based on whether they are vulnerable to Logjam attack.
263
+
264
+ Possible values: ``YES``, ``NO``, ``UNKNOWN``.
265
+ cert_key_size (dict):
266
+ Filters the data by the size of the SSL certificate public keys used by the cloud applications.
267
+
268
+ Example format for this parameter:
269
+
270
+ ``cert_key_size={"operation": "INCLUDE", "value": ["BITS_2048", "BITS_256"]}``
271
+
272
+ Possible values for ``operation`` field:
273
+
274
+ ``INCLUDE``, ``EXCLUDE``.
275
+
276
+ Possible values for ``value`` field:
277
+
278
+ ``NONE``, ``UN_KNOWN``, ``BITS_2048``, ``BITS_256``,
279
+ ``BITS_3072``, ``BITS_384``, ``BITS_4096``, ``BITS_1024``.
280
+
281
+ Returns:
282
+ :obj:`str`: The Shadow IT Report in CSV format.
283
+
284
+ Examples:
285
+ Export the Shadow IT Report for the last 7 days::
286
+
287
+ report = zia.shadow_it.export_shadow_it_report('LAST_7_DAYS')
288
+
289
+ Notes:
290
+ Zscaler has a rate limit of 1 report per-minute, ensure you take this into account when calling this method.
291
+
292
+ """
293
+ payload = {"duration": duration}
294
+ convert_keys(payload.update(kwargs))
295
+
296
+ return self.rest.post("shadowIT/applications/export", json=payload).text
297
+
298
+ def export_shadow_it_csv(
299
+ self, application: str, entity: str, duration: str = "LAST_1_DAYS", **kwargs
300
+ ):
301
+ """
302
+ Export the Shadow IT Report (in CSV format) for the list of users or known locations
303
+ identified with using the cloud applications specified in the request. The report
304
+ includes details such as user interactions, application category, application usage,
305
+ number of transactions, last accessed time, etc.
306
+
307
+ You can customize the report using various filters.
308
+
309
+ Args:
310
+ application (str): The cloud application for which user or location data must be retrieved.
311
+ Note: Only one cloud application can be specified at a time.
312
+ duration (str): Filters the data using predefined timeframes. Defaults to last day.
313
+
314
+ Possible values: ``LAST_1_DAYS``, ``LAST_7_DAYS``, ``LAST_15_DAYS``, ``LAST_MONTH``, ``LAST_QUARTER``.
315
+ entity (str): The entity type that the Shadow IT Report will be generated for.
316
+
317
+ Possible values: ``USER``, ``LOCATION``.
318
+
319
+ Keyword Args:
320
+ order (dict): Sorts the list in increasing or decreasing order based on the specified attribute.
321
+
322
+ Example format for this parameter:
323
+
324
+ ``order={"on": "RISK_SCORE", "by": "INCREASING"}``
325
+
326
+ Possible values for ``on``:
327
+
328
+ ``RISK_SCORE``, ``APPLICATION``, ``APPLICATION_CATEGORY``,
329
+ ``SANCTIONED_STATE``, ``TOTAL_BYTES``, ``UPLOAD_BYTES``, ``DOWNLOAD_BYTES``, ``AUTHENTICATED_USERS``,
330
+ ``TRANSACTION_COUNT``, ``UNAUTH_LOCATION``, ``LAST_ACCESSED``.
331
+
332
+ Possible values for ``by``:
333
+
334
+ ``INCREASING``, ``DECREASING``.
335
+ download_bytes (dict): Filters by the amount of data (in bytes) downloaded from the application.
336
+ ``min`` and ``max`` fields specify the range.
337
+ upload_bytes (dict): Filters by the amount of data (in bytes) uploaded to the application.
338
+ ``min`` and ``max`` fields specify the range.
339
+ data_consumed (dict): Filters by the total amount of data uploaded and downloaded from the application.
340
+ ``min`` and ``max`` fields specify the range.
341
+ users (dict): Filters by user.
342
+ ``id`` and ``name`` fields specify the user information.
343
+ locations (dict): Filters by location.
344
+ ``id`` and ``name`` fields specify the location information.
345
+ departments (dict): Filters by department.
346
+ ``id`` and ``name`` fields specify the department information.
347
+
348
+ Returns:
349
+ :obj:`str`: The Shadow IT Report in CSV format.
350
+
351
+ Examples:
352
+ Export the Shadow IT Report for GitHub the last 15 days::
353
+
354
+ report = zia.shadow_it.export_shadow_it_report(application="Github", duration="LAST_15_DAYS")
355
+
356
+ Notes:
357
+ Zscaler has a rate limit of 1 report per-minute, ensure you take this into account when calling this method.
358
+ """
359
+
360
+ payload = {"application": application, "duration": duration}
361
+
362
+ # Process user_ids, location_ids, and department_ids if provided in kwargs
363
+ for key in ["users", "locations", "departments"]:
364
+ id_list = kwargs.pop(key, None)
365
+ if id_list is not None:
366
+ payload[key] = self._convert_ids_to_dict_list(id_list)
367
+
368
+ convert_keys(payload.update(kwargs))
369
+
370
+ return self.rest.post(
371
+ f"shadowIT/applications/{entity}/exportCsv", json=payload
372
+ ).text
373
+
374
+ def list_apps(self):
375
+ """
376
+ List all predefined and custom cloud applications by name and id.
377
+
378
+ Returns:
379
+ :obj:`BoxList` of :obj:`Box`: A list of cloud applications.
380
+
381
+ Examples:
382
+ List all cloud applications::
383
+
384
+ apps = zia.cloud_apps.list_apps()
385
+ for app in apps:
386
+ print(app.name)
387
+
388
+ """
389
+ return self.rest.get("cloudApplications/lite")
390
+
391
+ def list_custom_tags(self):
392
+ """
393
+ List all custom tags by name and id.
394
+
395
+ Returns:
396
+ :obj:`BoxList` of :obj:`Box`: A list of custom tags available to assign to cloud applications.
397
+
398
+ Examples:
399
+ List all custom tags::
400
+
401
+ tags = zia.cloud_apps.list_custom_tags()
402
+ for tag in tags:
403
+ print(tag.name)
404
+
405
+ """
406
+ return self.rest.get("customTags")
@@ -0,0 +1,90 @@
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 box import BoxList
19
+
20
+ from zscaler.zia import ZIAClient
21
+
22
+
23
+ class DeviceManagementAPI:
24
+ def __init__(self, client: ZIAClient):
25
+ self.rest = client
26
+
27
+ def list_device_groups(self, query: str = None) -> BoxList:
28
+ """
29
+ Returns the list of ZIA Device Groups.
30
+
31
+ Args:
32
+ query (str): A search string used to match against a Device Group's name or description attributes.
33
+
34
+ Returns:
35
+ :obj:`BoxList`: A list containing ZIA Device Groups.
36
+
37
+ Examples:
38
+ Print all device groups
39
+
40
+ >>> for device group in zia.device_groups.list_device_groups():
41
+ ... pprint(device)
42
+
43
+ Print Device Groups that match the name or description 'Windows'
44
+
45
+ >>> pprint(zia.device_groups.list_device_groups('Windows'))
46
+
47
+ """
48
+ payload = {"search": query}
49
+ return self.rest.get("deviceGroups", params=payload)
50
+
51
+ def list_devices(self, query: str = None) -> BoxList:
52
+ """
53
+ Returns the list of Devices.
54
+
55
+ Args:
56
+ query (str): A search string used to match against a Device's name or description attributes.
57
+
58
+ Returns:
59
+ :obj:`BoxList`: A list containing Device.
60
+
61
+ Examples:
62
+ Print all devices
63
+
64
+ >>> for dlp idm in zia.device_groups.list_devices():
65
+ ... pprint(idm)
66
+
67
+ Print IDM profiles that match the name or description 'WINDOWS_OS'
68
+
69
+ >>> pprint(zia.device_groups.list_devices('WINDOWS_OS'))
70
+
71
+ """
72
+ payload = {"search": query}
73
+ return self.rest.get("deviceGroups/devices", params=payload)
74
+
75
+ def list_device_lite(self) -> BoxList:
76
+ """
77
+ Returns the list of devices that includes device ID, name, and owner name.
78
+
79
+ Returns:
80
+ :obj:`BoxList`: List of Device/ids.
81
+
82
+ Examples:
83
+ Get Device Lite results
84
+
85
+ >>> results = zia.device.list_device_lite()
86
+ ... for item in results:
87
+ ... print(item)
88
+
89
+ """
90
+ return self.rest.get("deviceGroups/devices/lite")