Skip to content

Commit ec1c0ca

Browse files
authored
fix: Added New VZEN and Delete Alert Endpoints and Documentation Fixes (#299)
* fix: Added New VZEN and Delete Alert Endpoints and Documentation Fixes * fix: Added ZIA Alert and vZEN Tests
1 parent f515ffe commit ec1c0ca

30 files changed

+1183
-182
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
- master
88
- develop
99
pull_request:
10+
11+
permissions:
12+
contents: write
13+
1014
jobs:
1115
format:
1216
name: Check Code Format

.github/workflows/zcc-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
- cron: '0 14 * * 1-5' # UTC
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
1418
jobs:
1519
zcc-beta-tenants:
1620
runs-on: ubuntu-latest

.github/workflows/zdx-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
- cron: '0 14 * * 1-5' # UTC
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
1418
jobs:
1519
zdx-prod-tenants:
1620
runs-on: ubuntu-latest

.github/workflows/zia-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
- cron: "0 14 * * 1-5" # UTC
1616
workflow_dispatch:
1717

18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
1822
jobs:
1923
zia-beta-tenants:
2024
runs-on: ubuntu-latest

.github/workflows/zpa_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
- cron: '0 14 * * 1-5' # UTC
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
1418
jobs:
1519
zpa-beta-tenants:
1620
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Zscaler Python SDK Changelog
22

3+
## 1.4.4 (June 6, 2025)
4+
5+
### Notes
6+
7+
- Python Versions: **v3.8, v3.9, v3.10, v3.11**
8+
9+
### New ZIA Endpoint - Virtual ZEN Clusters:
10+
11+
* [PR #299](https://github.com/zscaler/zscaler-sdk-python/pull/299) - Added the following new ZIA API Endpoints:
12+
- Added `GET /virtualZenClusters` Retrieves a list of ZIA Virtual Service Edge clusters.
13+
- Added `GET /virtualZenClusters/{cluster_id}` Retrieves the Virtual Service Edge cluster based on the specified ID
14+
- Added `POST /virtualZenClusters` Adds a new Virtual Service Edge cluster.
15+
- Added `PUT /virtualZenClusters/{cluster_id}` Updates the Virtual Service Edge cluster based on the specified ID
16+
- Added `DELETE /virtualZenClusters/{cluster_id}` Deletes the Virtual Service Edge cluster based on the specified ID
17+
18+
### New ZIA Endpoint - Alert Subscription
19+
20+
* [PR #299](https://github.com/zscaler/zscaler-sdk-python/pull/299) - Added the following new ZIA API Endpoints:
21+
- Added `DELETE /alertSubscriptions/{subscription_id}` Deletes the Alert Subscription based on the specified ID
22+
23+
### Documentation
24+
25+
* [PR #299](https://github.com/zscaler/zscaler-sdk-python/pull/299) - Fixed and added several documentations and included examples.
26+
327
## 1.4.3 (June 3, 2025)
428

529
### Notes

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ You can provide credentials via the `ZDX_CLIENT_ID`, `ZDX_CLIENT_SECRET` environ
941941
|--------------|-------------|-------------------|
942942
| `key_id` | _(String)_ A string that contains the key_id for the ZDX Portal.| `ZDX_CLIENT_ID` |
943943
| `key_secret` | _(String)_ A string that contains the key_secret key for the ZDX Portal.| `ZDX_CLIENT_SECRET` |
944+
| `cloud` | _(String)_ The cloud name prefix that identifies the correct API endpoint.| `ZDX_CLOUD` |
944945

945946
### ZDX Legacy Client Initialization
946947

docsrc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
html_title = ""
2929

3030
# The short X.Y version
31-
version = "1.4.3"
31+
version = "1.4.4"
3232
# The full version, including alpha/beta/rc tags
33-
release = "1.4.3"
33+
release = "1.4.4"
3434

3535
# -- General configuration ---------------------------------------------------
3636

docsrc/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,13 @@ You can provide credentials via the ``ZDX_CLIENT_ID``,
13541354
| | for the ZDX | |
13551355
| | Portal. | |
13561356
+--------------------+-------------------+----------------------------+
1357+
| ``cloud`` | *(String)* The | ``ZDX_CLOUD`` |
1358+
| | cloud name | |
1359+
| | prefix that | |
1360+
| | identifies the | |
1361+
| | correct API | |
1362+
| | endpoint. | |
1363+
+--------------------+-------------------+----------------------------+
13571364

13581365
ZDX Legacy Client Initialization
13591366
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docsrc/zs/guides/release_notes.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ Release Notes
66
Zscaler Python SDK Changelog
77
----------------------------
88

9+
1.4.4 (June, 5 2025)
10+
-------------------------
11+
12+
Notes
13+
-----
14+
15+
- Python Versions: **v3.8, v3.9, v3.10, v3.11**
16+
17+
New ZIA Endpoint - Virtual ZEN Clusters
18+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
20+
* (`#299 <https://github.com/zscaler/zscaler-sdk-python/pull/299>`_) - Added the following new ZIA API Endpoints:
21+
- Added `GET /virtualZenClusters` Retrieves a list of ZIA Virtual Service Edge clusters.
22+
- Added `GET /virtualZenClusters/{cluster_id}` Retrieves the Virtual Service Edge cluster based on the specified ID
23+
- Added `POST /virtualZenClusters` Adds a new Virtual Service Edge cluster.
24+
- Added `PUT /virtualZenClusters/{cluster_id}` Updates the Virtual Service Edge cluster based on the specified ID
25+
- Added `DELETE /virtualZenClusters/{cluster_id}` Deletes the Virtual Service Edge cluster based on the specified ID
26+
27+
New ZIA Endpoint - Alert Subscription
28+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29+
30+
* (`#299 <https://github.com/zscaler/zscaler-sdk-python/pull/299>`_) - Added the following new ZIA API Endpoints:
31+
- Added `DELETE /alertSubscriptions/{subscription_id}` Deletes the Alert Subscription based on the specified ID
32+
33+
Documentation
34+
^^^^^^^^^^^^^^
35+
36+
* (`#299 <https://github.com/zscaler/zscaler-sdk-python/pull/299>`_) - Fixed and added several documentations and included examples.
37+
938
1.4.3 (June, 3 2025)
1039
-------------------------
1140

@@ -61,7 +90,7 @@ Notes
6190
Zscaler OneAPI Support for Cloud & Branch Connector API
6291
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6392

64-
* (`#287 <https://github.com/zscaler/zscaler-sdk-python/pull/287>`_): Cloud & Branch Connector API are now supported via (`OneAPI<https://help.zscaler.com/oneapi/understanding-oneapi>`_) with Oauth2 authentication support through (`Zidentity<https://help.zscaler.com/zidentity/what-zidentity>`_)
93+
* (`#287 <https://github.com/zscaler/zscaler-sdk-python/pull/287>`_): Cloud & Branch Connector API are now supported via (`OneAPI <https://help.zscaler.com/zidentity/what-zidentity>`_) Oauth2 authentication support through (`Zidentity <https://help.zscaler.com/zidentity/what-zidentity>`_)
6594

6695
ZPA Application Segment Provision
6796
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

docsrc/zs/zia/vzen_clusters.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
vzen_clusters
2+
-----------------
3+
4+
The following methods allow for interaction with the ZIA
5+
ZIA Virtual Service Edge clusters API endpoints.
6+
7+
Methods are accessible via ``zia.vzen_clusters``
8+
9+
.. _zia-vzen_clusters:
10+
11+
.. automodule:: zscaler.zia.vzen_clusters
12+
:members:
13+
:undoc-members:
14+
:show-inheritance:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "zscaler-sdk-python"
3-
version = "1.4.3"
3+
version = "1.4.4"
44
description = "Official Python SDK for the Zscaler Products"
55
authors = ["Zscaler, Inc. <devrel@zscaler.com>"]
66
license = "MIT"

tests/integration/zia/sweep/run_sweep.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,28 @@ def sweep_nat_control_policy(self):
771771
logging.error(f"An error occurred while sweeping nat control rules: {str(e)}")
772772
raise
773773

774+
@suppress_warnings
775+
def sweep_vzen_clusters(self):
776+
logging.info("Starting to sweep vzen clusters")
777+
try:
778+
vzen_clusters, _, error = self.client.zia.vzen_clusters.list_vzen_clusters()
779+
if error:
780+
raise Exception(f"Error listing vzen clusters: {error}")
781+
782+
test_vzen = [vzen for vzen in vzen_clusters if hasattr(vzen, "name") and vzen.name.startswith("tests")]
783+
logging.info(f"Found {len(test_vzen)} vzen cluster to delete.")
784+
785+
for vzen in test_vzen:
786+
logging.info(f"sweep_nss_servers: Attempting to delete vzen cluster: Name='{vzen.name}', ID='{vzen.id}'")
787+
_, _, error = self.client.zia.vzen_clusters.delete_vzen_cluster(nss_id=vzen.id)
788+
if error:
789+
logging.error(f"Failed to delete vzen cluster ID={vzen.id}{error}")
790+
else:
791+
logging.info(f"Successfully deleted vzen cluster ID={vzen.id}")
792+
793+
except Exception as e:
794+
logging.error(f"An error occurred while sweeping vzen clusters: {str(e)}")
795+
raise
774796

775797
if __name__ == "__main__":
776798
logging.basicConfig(level=logging.INFO)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
import pytest
19+
20+
from tests.integration.zia.conftest import MockZIAClient
21+
import random
22+
23+
24+
@pytest.fixture
25+
def fs():
26+
yield
27+
28+
29+
class TestAlertSubscription:
30+
"""
31+
Integration Tests for the Alert Subscription
32+
"""
33+
34+
def test_alert_subscription(self, fs):
35+
client = MockZIAClient(fs)
36+
errors = []
37+
subscription_id = None
38+
update_subscription = None
39+
40+
try:
41+
try:
42+
create_alert, _, error = client.zia.alert_subscriptions.add_alert_subscription(
43+
description =f"AddedAlertSubscription_{random.randint(1000, 10000)}",
44+
email = 'alert@acme.com',
45+
pt0_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
46+
secure_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
47+
manage_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
48+
comply_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
49+
system_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
50+
)
51+
assert error is None, f"Add Alert Subscription Error: {error}"
52+
assert create_alert is not None, "Subscription creation failed."
53+
subscription_id = create_alert.id
54+
except Exception as e:
55+
errors.append(f"Exception during add_alert_subscription: {str(e)}")
56+
57+
try:
58+
if subscription_id:
59+
update_subscription, _, error = client.zia.alert_subscriptions.update_alert_subscription(
60+
subscription_id=subscription_id,
61+
description =f"UpdateAlertSubscription_{random.randint(1000, 10000)}",
62+
email = 'alert@acme.com',
63+
pt0_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
64+
secure_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
65+
manage_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
66+
comply_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
67+
system_severities = ["CRITICAL", "MAJOR", "INFO", "MINOR", "DEBUG"],
68+
)
69+
assert error is None, f"Update Alert Subscription Error: {error}"
70+
assert update_subscription is not None, "Subscription update returned None."
71+
except Exception as e:
72+
errors.append(f"Exception during update_alert_subscription: {str(e)}")
73+
74+
try:
75+
if update_subscription:
76+
subscription, _, error = client.zia.alert_subscriptions.get_alert_subscription(update_subscription.id)
77+
assert error is None, f"Get Alert Subscription Error: {error}"
78+
assert subscription.id == subscription_id, "Retrieved subscription ID mismatch."
79+
except Exception as e:
80+
errors.append(f"Exception during get_alert_subscription: {str(e)}")
81+
82+
try:
83+
subscriptions, _, error = client.zia.alert_subscriptions.list_alert_subscriptions()
84+
assert error is None, f"Error listing Alert Subscriptions: {error}"
85+
assert subscriptions is not None, "Alert Subscriptions list is None"
86+
assert any(alert.id == subscription_id for alert in subscriptions), "Newly created alert not found in the list of subscriptions."
87+
except Exception as exc:
88+
errors.append(f"Listing Alert Subscriptions failed: {exc}")
89+
90+
91+
finally:
92+
try:
93+
if update_subscription:
94+
_, _, error = client.zia.alert_subscriptions.delete_alert_subscription(update_subscription.id)
95+
assert error is None, f"Delete Alert Subscription Error: {error}"
96+
except Exception as e:
97+
errors.append(f"Exception during delete_alert_subscription: {str(e)}")
98+
99+
if errors:
100+
raise AssertionError(f"Integration Test Errors:\n{chr(10).join(errors)}")

0 commit comments

Comments
 (0)