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,75 @@
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 Box, BoxList
19
+ from requests import Response
20
+
21
+ from zscaler.zpa.client import ZPAClient
22
+
23
+
24
+ class CloudConnectorGroupsAPI:
25
+ def __init__(self, client: ZPAClient):
26
+ self.rest = client
27
+
28
+ def list_groups(self, **kwargs) -> BoxList:
29
+ """
30
+ Returns a list of all configured cloud connector groups.
31
+
32
+ Keyword Args:
33
+ **max_items (int):
34
+ The maximum number of items to request before stopping iteration.
35
+ **max_pages (int):
36
+ The maximum number of pages to request before stopping iteration.
37
+ **pagesize (int):
38
+ Specifies the page size. The default size is 20, but the maximum size is 500.
39
+ **search (str, optional):
40
+ The search string used to match against features and fields.
41
+
42
+ Returns:
43
+ :obj:`BoxList`: A list of all configured cloud connector groups.
44
+
45
+ Examples:
46
+ >>> for cloud_connector_group in zpa.cloud_connector_groups.list_groups():
47
+ ... pprint(cloud_connector_group)
48
+
49
+ """
50
+ list, _ = self.rest.get_paginated_data(
51
+ path="/cloudConnectorGroup",
52
+ )
53
+ return list
54
+
55
+ def get_group(self, group_id: str) -> Box:
56
+ """
57
+ Returns information on the specified cloud connector group.
58
+
59
+ Args:
60
+ group_id (str):
61
+ The unique identifier for the cloud connector group.
62
+
63
+ Returns:
64
+ :obj:`Box`: The resource record for the cloud connector group.
65
+
66
+ Examples:
67
+ >>> pprint(zpa.cloud_connector_groups.get_group('99999'))
68
+
69
+ """
70
+ response = self.rest.get("/cloudConnectorGroup/%s" % (group_id))
71
+ if isinstance(response, Response):
72
+ status_code = response.status_code
73
+ if status_code != 200:
74
+ return None
75
+ return response
@@ -0,0 +1,518 @@
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 Box, BoxList
19
+ from requests import Response
20
+
21
+ from zscaler.utils import add_id_groups, pick_version_profile, snake_to_camel
22
+ from zscaler.zpa.client import ZPAClient
23
+
24
+
25
+ class AppConnectorControllerAPI:
26
+ reformat_params = [
27
+ ("connector_ids", "connectors"),
28
+ ("server_group_ids", "serverGroups"),
29
+ ]
30
+
31
+ def __init__(self, client: ZPAClient):
32
+ self.rest = client
33
+
34
+ def list_connectors(self, **kwargs) -> BoxList:
35
+ """
36
+ Returns a list of all configured App Connectors.
37
+
38
+ Args:
39
+ **kwargs: Optional keyword args.
40
+
41
+ Keyword Args:
42
+ **max_items (int, optional):
43
+ The maximum number of items to request before stopping iteration.
44
+ **max_pages (int, optional):
45
+ The maximum number of pages to request before stopping iteration.
46
+ **pagesize (int, optional):
47
+ Specifies the page size. The default size is 100, but the maximum size is 1000.
48
+ **search (str, optional):
49
+ The search string used to match against a department's name or comments attributes.
50
+
51
+ Returns:
52
+ :obj:`BoxList`: List containing all configured ZPA App Connectors.
53
+
54
+ Examples:
55
+ List all configured App Connectors:
56
+
57
+ >>> for connector in zpa.connectors.list_connectors():
58
+ ... print(connector)
59
+
60
+ """
61
+ list, _ = self.rest.get_paginated_data(
62
+ path="/connector", **kwargs, api_version="v1"
63
+ )
64
+ return list
65
+
66
+ def get_connector(self, connector_id: str) -> Box:
67
+ """
68
+ Returns information on the specified App Connector.
69
+
70
+ Args:
71
+ connector_id (str): The unique id for the ZPA App Connector.
72
+
73
+ Returns:
74
+ :obj:`Box`: The specified App Connector resource record.
75
+
76
+ Examples:
77
+ >>> app_connector = zpa.connectors.get_connector('99999')
78
+
79
+ """
80
+ response = self.rest.get("/connector/%s" % (connector_id))
81
+ if isinstance(response, Response):
82
+ status_code = response.status_code
83
+ if status_code != 200:
84
+ return None
85
+ return response
86
+
87
+ def get_connector_by_name(self, name):
88
+ apps = self.list_connectors()
89
+ for app in apps:
90
+ if app.get("name") == name:
91
+ return app
92
+ return None
93
+
94
+ def update_connector(self, connector_id: str, **kwargs):
95
+ """
96
+ Updates an existing ZPA App Connector.
97
+
98
+ Args:
99
+ connector_id (str): The unique id of the ZPA App Connector.
100
+ **kwargs: Optional keyword args.
101
+
102
+ Keyword Args:
103
+ **description (str): Additional information about the App Connector.
104
+ **enabled (bool): True if the App Connector is enabled.
105
+ **name (str): The name of the App Connector.
106
+
107
+ Returns:
108
+ :obj:`Box`: The updated App Connector resource record.
109
+
110
+ Examples:
111
+ Update an App Connector name and disable it.
112
+
113
+ >>> app_connector = zpa.connectors.update_connector('999999',
114
+ ... name="Updated App Connector Name",
115
+ ... enabled=False)
116
+
117
+ """
118
+ # Set payload to equal existing record
119
+ payload = {
120
+ snake_to_camel(k): v for k, v in self.get_connector(connector_id).items()
121
+ }
122
+
123
+ # Perform formatting on simplified params
124
+ add_id_groups(self.reformat_params, kwargs, payload)
125
+
126
+ # Add optional parameters to payload
127
+ for key, value in kwargs.items():
128
+ payload[snake_to_camel(key)] = value
129
+
130
+ resp = self.rest.put("/connector/%s" % (connector_id), json=payload).status_code
131
+ if not isinstance(resp, Response):
132
+ return self.get_connector(connector_id)
133
+
134
+ def delete_connector(self, connector_id: str) -> int:
135
+ """
136
+ Deletes the specified App Connector from ZPA.
137
+
138
+ Args:
139
+ connector_id (str): The unique id for the ZPA App Connector that will be deleted.
140
+
141
+ Returns:
142
+ :obj:`int`: The status code for the operation.
143
+
144
+ Examples:
145
+ >>> zpa.connectors.delete_connector('999999')
146
+
147
+ """
148
+ return self.rest.delete(f"connector/{connector_id}").status_code
149
+
150
+ def bulk_delete_connectors(self, connector_ids: list) -> int:
151
+ """
152
+ Deletes all specified App Connectors from ZPA.
153
+
154
+ Args:
155
+ connector_ids (list): The list of unique ids for the ZPA App Connectors that will be deleted.
156
+
157
+ Returns:
158
+ :obj:`int`: The status code for the operation.
159
+
160
+ Examples:
161
+ >>> zpa.connectors.bulk_delete_connectors(['111111', '222222', '333333'])
162
+
163
+ """
164
+ payload = {"ids": connector_ids}
165
+ return self.rest.post("connector/bulkDelete", json=payload).status_code
166
+
167
+ def list_connector_groups(self, **kwargs) -> BoxList:
168
+ """
169
+ Returns a list of all connector groups.
170
+
171
+ Keyword Args:
172
+ **max_items (int, optional):
173
+ The maximum number of items to request before stopping iteration.
174
+ **max_pages (int, optional):
175
+ The maximum number of pages to request before stopping iteration.
176
+ **pagesize (int, optional):
177
+ Specifies the page size. The default size is 100, but the maximum size is 1000.
178
+ **search (str, optional):
179
+ The search string used to match against a department's name or comments attributes.
180
+
181
+ Returns:
182
+ :obj:`BoxList`: List of all configured connector groups.
183
+
184
+ Examples:
185
+ >>> connector_groups = zpa.connectors.list_connector_groups()
186
+
187
+ """
188
+ list, _ = self.rest.get_paginated_data(
189
+ path="/appConnectorGroup", **kwargs, api_version="v1"
190
+ )
191
+ return list
192
+
193
+ def get_connector_group(self, group_id: str) -> Box:
194
+ """
195
+ Gets information for a specified connector group.
196
+
197
+ Args:
198
+ group_id (str):
199
+ The unique identifier for the connector group.
200
+
201
+ Returns:
202
+ :obj:`Box`:
203
+ The connector group resource record.
204
+
205
+ Examples:
206
+ >>> connector_group = zpa.connectors.get_connector_group('99999')
207
+
208
+ """
209
+ response = self.rest.get("/appConnectorGroup/%s" % (group_id))
210
+ if isinstance(response, Response):
211
+ status_code = response.status_code
212
+ if status_code != 200:
213
+ return None
214
+ return response
215
+
216
+ def get_connector_group_by_name(self, name):
217
+ groups = self.list_connector_groups()
218
+ for group in groups:
219
+ if group.get("name") == name:
220
+ return group
221
+ return None
222
+
223
+ def add_connector_group(
224
+ self, name: str, latitude: int, location: str, longitude: int, **kwargs
225
+ ) -> Box:
226
+ """
227
+ Adds a new ZPA App Connector Group.
228
+
229
+ Args:
230
+ name (str): The name of the App Connector Group.
231
+ latitude (int): The latitude representing the App Connector's physical location.
232
+ location (str): The name of the location that the App Connector Group represents.
233
+ longitude (int): The longitude representing the App Connector's physical location.
234
+ **kwargs: Optional keyword args.
235
+
236
+ Keyword Args:
237
+ **connector_ids (list):
238
+ The unique ids for the App Connectors that will be added to this App Connector Group.
239
+ **city_country (str):
240
+ The City and Country for where the App Connectors are located. Format is:
241
+
242
+ ``<City>, <Country Code>`` e.g. ``Sydney, AU``
243
+ **country_code (str):
244
+ The ISO<std> Country Code that represents the country where the App Connectors are located.
245
+ **description (str):
246
+ Additional information about the App Connector Group.
247
+ **dns_query_type (str):
248
+ The type of DNS queries that are enabled for this App Connector Group. Accepted values are:
249
+ ``IPV4_IPV6``, ``IPV4`` and ``IPV6``
250
+ **enabled (bool):
251
+ Is the App Connector Group enabled? Defaults to ``True``.
252
+ **override_version_profile (bool):
253
+ Override the local App Connector version according to ``version_profile``. Defaults to ``False``.
254
+ **server_group_ids (list):
255
+ The unique ids of the Server Groups that are associated with this App Connector Group
256
+ **lss_app_connector_group (bool):
257
+ **upgrade_day (str):
258
+ The day of the week that upgrades will be pushed to the App Connector.
259
+ **upgrade_time_in_secs (str):
260
+ The time of the day that upgrades will be pushed to the App Connector.
261
+ **version_profile (str):
262
+ The version profile to use. This will automatically set ``override_version_profile`` to True.
263
+ Accepted values are:
264
+ ``default``, ``previous_default`` and ``new_release``
265
+
266
+ Returns:
267
+ :obj:`Box`: The resource record of the newly created App Connector Group.
268
+
269
+ Examples:
270
+ Add a new ZPA App Connector Group with parameters.
271
+
272
+ >>> group = zpa.connectors.add_connector_group(name="New App Connector Group",
273
+ ... location="Sydney",
274
+ ... latitude="33.8688",
275
+ ... longitude="151.2093",
276
+ ... version_profile="default")
277
+
278
+ """
279
+ payload = {
280
+ "name": name,
281
+ "latitude": latitude,
282
+ "location": location,
283
+ "longitude": longitude,
284
+ }
285
+
286
+ # Perform formatting on simplified params
287
+ add_id_groups(self.reformat_params, kwargs, payload)
288
+ pick_version_profile(kwargs, payload)
289
+
290
+ # Add optional parameters to payload
291
+ for key, value in kwargs.items():
292
+ payload[snake_to_camel(key)] = value
293
+
294
+ response = self.rest.post("appConnectorGroup", json=payload)
295
+ if isinstance(response, Response):
296
+ # this is only true when the creation failed (status code is not 2xx)
297
+ status_code = response.status_code
298
+ # Handle error response
299
+ raise Exception(
300
+ f"API call failed with status {status_code}: {response.json()}"
301
+ )
302
+ return response
303
+
304
+ def update_connector_group(self, group_id: str, **kwargs) -> Box:
305
+ """
306
+ Updates an existing ZPA App Connector Group.
307
+
308
+ Args:
309
+ group_id (str): The unique id for the App Connector Group in ZPA.
310
+ **kwargs: Optional keyword args.
311
+
312
+ Keyword Args:
313
+ **connector_ids (list):
314
+ The unique ids for the App Connectors that will be added to this App Connector Group.
315
+ **city_country (str):
316
+ The City and Country for where the App Connectors are located. Format is:
317
+
318
+ ``<City>, <Country Code>`` e.g. ``Sydney, AU``
319
+ **country_code (str):
320
+ The ISO<std> Country Code that represents the country where the App Connectors are located.
321
+ **description (str):
322
+ Additional information about the App Connector Group.
323
+ **dns_query_type (str):
324
+ The type of DNS queries that are enabled for this App Connector Group. Accepted values are:
325
+ ``IPV4_IPV6``, ``IPV4`` and ``IPV6``
326
+ **enabled (bool):
327
+ Is the App Connector Group enabled? Defaults to ``True``.
328
+ **name (str): The name of the App Connector Group.
329
+ **latitude (int): The latitude representing the App Connector's physical location.
330
+ **location (str): The name of the location that the App Connector Group represents.
331
+ **longitude (int): The longitude representing the App Connector's physical location.
332
+ **override_version_profile (bool):
333
+ Override the local App Connector version according to ``version_profile``. Defaults to ``False``.
334
+ **server_group_ids (list):
335
+ The unique ids of the Server Groups that are associated with this App Connector Group
336
+ **lss_app_connector_group (bool):
337
+ **upgrade_day (str):
338
+ The day of the week that upgrades will be pushed to the App Connector.
339
+ **upgrade_time_in_secs (str):
340
+ The time of the day that upgrades will be pushed to the App Connector.
341
+ **version_profile (str):
342
+ The version profile to use. This will automatically set ``override_version_profile`` to True.
343
+ Accepted values are:
344
+
345
+ ``default``, ``previous_default`` and ``new_release``
346
+
347
+ Returns:
348
+ :obj:`Box`: The updated ZPA App Connector Group resource record.
349
+
350
+ Examples:
351
+ Update the name of an App Connector Group in ZPA, change the version profile to new releases and disable
352
+ the group.
353
+
354
+ >>> group = zpa.connectors.update_connector_group('99999',
355
+ ... name="Updated App Connector Group",
356
+ ... version_profile="new_release",
357
+ ... enabled=False)
358
+
359
+ """
360
+
361
+ # Set payload to equal existing record
362
+ payload = {
363
+ snake_to_camel(k): v for k, v in self.get_connector_group(group_id).items()
364
+ }
365
+
366
+ # Perform formatting on simplified params
367
+ add_id_groups(self.reformat_params, kwargs, payload)
368
+ pick_version_profile(kwargs, payload)
369
+
370
+ # Add optional parameters to payload
371
+ for key, value in kwargs.items():
372
+ payload[snake_to_camel(key)] = value
373
+
374
+ resp = self.rest.put(f"appConnectorGroup/{group_id}", json=payload).status_code
375
+
376
+ # Return the object if it was updated successfully
377
+ if not isinstance(resp, Response):
378
+ return self.get_connector_group(group_id)
379
+
380
+ def delete_connector_group(self, group_id: str) -> int:
381
+ """
382
+ Deletes the specified App Connector Group from ZPA.
383
+
384
+ Args:
385
+ group_id (str): The unique identifier for the App Connector Group.
386
+
387
+ Returns:
388
+ :obj:`int`: The status code for the operation.
389
+
390
+ Examples:
391
+ >>> zpa.connectors.delete_connector_group('1876541121')
392
+
393
+ """
394
+ return self.rest.delete(f"appConnectorGroup/{group_id}").status_code
395
+
396
+ def get_connector_schedule(self) -> Box:
397
+ """
398
+ Returns the configured App Connector Schedule frequency.
399
+
400
+ Args:
401
+ id (str): Unique identifier for the App Connector auto deletion config.
402
+ Required for the PUT request to update the App Connector Settings frequency.
403
+ customer_id (str): Unique identifier of the ZPA tenant.
404
+ delete_disabled (bool): If true, includes App Connectors for deletion if
405
+ they are disconnected, based on frequencyInterval and frequency values.
406
+ enabled (bool): If true, the deletion of App Connectors setting is enabled.
407
+ frequency (str): Frequency at which disconnected App Connectors are deleted.
408
+ frequency_interval (str): Interval for the frequency value, minimum is 5.
409
+
410
+ Returns:
411
+ :obj:`Box`: The Auto Delete frequency of the App Connector for the specified customer.
412
+
413
+ Examples:
414
+ >>> pprint(zpa.connectors.get_connector_schedule)
415
+ """
416
+
417
+ response = self.rest.get("/assistantSchedule")
418
+ if isinstance(response, Response):
419
+ return None
420
+ return response
421
+
422
+ def add_connector_schedule(self, frequency, interval, disabled, **kwargs) -> Box:
423
+ """
424
+ Configure an App Connector schedule frequency to delete inactive connectors based on
425
+ the configured frequency.
426
+
427
+ Args:
428
+ frequency (str): Frequency at which disconnected App Connectors are deleted.
429
+ interval (str): Interval for the frequency value, minimum supported is 5.
430
+ disabled (bool): If true, includes connectors for deletion if disconnected.
431
+ **kwargs: Optional keyword arguments.
432
+
433
+ Keyword Args:
434
+ name (str): Name of the schedule.
435
+ customer_id (str): Unique identifier of the ZPA tenant.
436
+ delete_disabled (bool): Includes App Connectors for deletion if they are
437
+ disconnected, based on frequency and interval values.
438
+ enabled (bool): Enables or disables the deletion setting for App Connectors.
439
+ description (str): Additional information about the Connector Schedule.
440
+
441
+ Returns:
442
+ :obj:`Box`: Auto Delete frequency of the App Connector for the specified customer.
443
+
444
+ Examples:
445
+ >>> schedule = zpa.connectors.add_connector_schedule(
446
+ ... frequency='weekly',
447
+ ... interval='5',
448
+ ... disabled=False,
449
+ ... name='Weekly Deletion',
450
+ ... description='Deletes disconnected connectors weekly.'
451
+ )
452
+ """
453
+ payload = {
454
+ "frequency": frequency,
455
+ "frequencyInterval": interval,
456
+ "deleteDisabled": disabled,
457
+ }
458
+
459
+ # Add optional parameters to payload
460
+ for key, value in kwargs.items():
461
+ payload[snake_to_camel(key)] = value
462
+
463
+ response = self.rest.post("assistantSchedule", json=payload)
464
+ if isinstance(response, Response):
465
+ status_code = response.status_code
466
+ if status_code >= 400: # Check if status code indicates an error
467
+ raise Exception(
468
+ f"API call failed with status {status_code}: {response.json()}"
469
+ )
470
+ return response
471
+
472
+ def update_schedule(self, scheduler_id: str, **kwargs) -> bool:
473
+ """
474
+ Updates App Connector schedule frequency to delete the inactive connectors based on
475
+ the configured frequency.
476
+
477
+ Args:
478
+ scheduler_id (str): Unique identifier for the scheduler.
479
+ customer_id (str): Unique identifier of the ZPA tenant.
480
+ delete_disabled (bool): Include App Connectors for deletion if disconnected,
481
+ based on frequencyInterval and frequency values.
482
+ enabled (bool): Enable or disable deletion of App Connectors.
483
+ frequency (str): Frequency at which disconnected App Connectors are deleted.
484
+ frequency_interval (str): Interval for the frequency value, minimum is 5.
485
+ Supported: 5, 7, 14, 30, 60, 90.
486
+
487
+ Keyword Args:
488
+ description (str): Additional information about the Connector Schedule.
489
+
490
+ Returns:
491
+ bool: True if update was successful, False otherwise.
492
+
493
+ Examples:
494
+ Updating connector schedule:
495
+
496
+ >>> result = zpa.connectors.update_schedule('10', frequency_interval='10')
497
+ >>> print(result) # True if successful, False otherwise
498
+ """
499
+ # Get the current schedule
500
+ current_schedule = self.get_connector_schedule(scheduler_id=scheduler_id)
501
+
502
+ # Update the schedule with provided arguments
503
+ for key, value in kwargs.items():
504
+ # Check for customer_id and convert it to int if it's a string
505
+ if key == "customer_id":
506
+ value = (
507
+ int(value) if isinstance(value, str) and value.isdigit() else value
508
+ )
509
+
510
+ current_schedule[snake_to_camel(key)] = value
511
+
512
+ # Send the updated schedule to the server
513
+ response = self.rest.put(
514
+ f"assistantSchedule/{scheduler_id}", json=current_schedule
515
+ )
516
+
517
+ # Return True if the update was successful (204 No Content), False otherwise
518
+ return response.status_code == 204