zscaler-sdk-python 1.0.0__tar.gz
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_sdk_python-1.0.0/LICENSE +21 -0
- zscaler_sdk_python-1.0.0/PKG-INFO +148 -0
- zscaler_sdk_python-1.0.0/README.md +112 -0
- zscaler_sdk_python-1.0.0/pyproject.toml +80 -0
- zscaler_sdk_python-1.0.0/setup.py +30 -0
- zscaler_sdk_python-1.0.0/zscaler/__init__.py +34 -0
- zscaler_sdk_python-1.0.0/zscaler/utils.py +150 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/__init__.py +238 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/admin_and_role_management.py +284 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/audit_logs.py +89 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/config.py +48 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/dlp.py +295 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/firewall.py +834 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/labels.py +160 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/locations.py +279 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/sandbox.py +98 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/security.py +226 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/session.py +80 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/ssl_inspection.py +165 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/traffic.py +680 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/url_categories.py +393 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/url_filters.py +262 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/users.py +355 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/vips.py +97 -0
- zscaler_sdk_python-1.0.0/zscaler/zia/web_dlp.py +156 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/__init__.py +298 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/app_segments.py +261 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/certificates.py +116 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/cloud_connector_groups.py +65 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/connector_groups.py +73 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/connectors.py +346 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/idp.py +73 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/inspection.py +889 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/isolation_profile.py +65 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/lss.py +514 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/machine_groups.py +65 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/policies.py +474 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/posture_profiles.py +71 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/provisioning.py +256 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/saml_attributes.py +98 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/scim_attributes.py +113 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/scim_groups.py +92 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/segment_groups.py +166 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/server_groups.py +195 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/servers.py +176 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/service_edges.py +344 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/session.py +50 -0
- zscaler_sdk_python-1.0.0/zscaler/zpa/trusted_networks.py +71 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 [Zscaler](https://github.com/zscaler)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: zscaler-sdk-python
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Framework for interacting with Zscaler Cloud via API
|
|
5
|
+
Home-page: https://github.com/zscaler/zscaler-sdk-python
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: zscaler,zpa,zia,zscaler-sdk-python
|
|
8
|
+
Author: Zscaler Technology Alliances
|
|
9
|
+
Author-email: zscaler-partner-labs@z-bd.com
|
|
10
|
+
Requires-Python: >=3.8,<4.0
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
27
|
+
Classifier: Topic :: Security
|
|
28
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
|
+
Requires-Dist: python-box (==7.0.0)
|
|
30
|
+
Requires-Dist: restfly (==1.4.7)
|
|
31
|
+
Project-URL: Bug Tracker, https://github.com/zscaler/zscaler-sdk-python/issues
|
|
32
|
+
Project-URL: Documentation, https://zscaler-sdk-python.readthedocs.io/
|
|
33
|
+
Project-URL: Repository, https://github.com/zscaler/zscaler-sdk-python
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# Zscaler SDK Python for the Zscaler API
|
|
37
|
+
|
|
38
|
+
[](https://github.com/zscaler/zscaler-sdk-python/actions/workflows/build.yml)
|
|
39
|
+
[](https://zscaler.readthedocs.io/?badge=latest)
|
|
40
|
+
[](https://github.com/zscaler/zscaler-sdk-python)
|
|
41
|
+
[](https://www.codacy.com/gh/zscaler/zscaler-sdk-python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=zscaler/zscaler-sdk-python&utm_campaign=Badge_Grade)
|
|
42
|
+
[](https://pypi.org/project/zscaler-sdk-python)
|
|
43
|
+
[](https://pypi.python.org/pypi/zscaler-sdk-python/)
|
|
44
|
+
[](https://github.com/zscaler/zscaler-sdk-python/releases/)
|
|
45
|
+
|
|
46
|
+
Zscaler SDK Python is an SDK that provides a uniform and easy-to-use interface for each of the Zscaler product APIs.
|
|
47
|
+
|
|
48
|
+
## Quick links
|
|
49
|
+
* [Zscaler SDK Python API Documentation](https://zscaler-sdk-python.readthedocs.io)
|
|
50
|
+
|
|
51
|
+
## Overview
|
|
52
|
+
Each Zscaler product has separate developer documentation and authentication methods. This SDK simplifies
|
|
53
|
+
software development using the Zscaler API.
|
|
54
|
+
|
|
55
|
+
This SDK leverages the [RESTfly framework](https://restfly.readthedocs.io/en/latest/index.html) developed
|
|
56
|
+
by Steve McGrath.
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
- Simplified authentication with Zscaler APIs.
|
|
60
|
+
- Uniform interaction with all Zscaler APIs.
|
|
61
|
+
- Uses [python-box](https://github.com/cdgriffith/Box/wiki) to add dot notation access to json data structures.
|
|
62
|
+
- Zscaler API output automatically converted from CamelCase to Snake Case.
|
|
63
|
+
- Various quality of life enhancements for object CRUD methods.
|
|
64
|
+
|
|
65
|
+
## Products
|
|
66
|
+
- Zscaler Private Access (ZPA)
|
|
67
|
+
- Zscaler Internet Access (ZIA)
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
The most recent version can be installed from pypi as per below.
|
|
72
|
+
|
|
73
|
+
$ pip install zscaler-sdk-python
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
Before you can interact with any of the Zscaler APIs, you may need to generate API keys or retrieve tenancy information
|
|
78
|
+
for each product that you are interfacing with. Once you have the requirements and you have installed Zscaler SDK Python, you're ready to go.
|
|
79
|
+
|
|
80
|
+
### Quick ZIA Example
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from zscaler import ZIA
|
|
84
|
+
from pprint import pprint
|
|
85
|
+
|
|
86
|
+
zia = ZIA(api_key='API_KEY', cloud='CLOUD', username='USERNAME', password='PASSWORD')
|
|
87
|
+
for user in zia.users.list_users():
|
|
88
|
+
pprint(user)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Quick ZPA Example
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from zscaler import ZPA
|
|
95
|
+
from pprint import pprint
|
|
96
|
+
|
|
97
|
+
zpa = ZPA(client_id='CLIENT_ID', client_secret='CLIENT_SECRET', customer_id='CUSTOMER_ID')
|
|
98
|
+
for app_segment in zpa.app_segments.list_segments():
|
|
99
|
+
pprint(app_segment)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
### API Documentation
|
|
104
|
+
Zscaler SDK Python's API is fully 100% documented and is hosted at [ReadTheDocs](https://zscaler-sdk-python.readthedocs.io).
|
|
105
|
+
|
|
106
|
+
This documentation should be used when working with Zscaler SDK Python rather than referring to Zscaler's API reference.
|
|
107
|
+
Zscaler SDK Python makes some quality of life improvements to simplify and clarify arguments passed to Zscaler's API.
|
|
108
|
+
|
|
109
|
+
## Is It Tested?
|
|
110
|
+
Yes! Zscaler SDK Python has a complete test suite that fully covers all methods within the ZIA and ZPA modules.
|
|
111
|
+
|
|
112
|
+
## Contributing
|
|
113
|
+
|
|
114
|
+
Contributions to Zscaler SDK Python are absolutely welcome.
|
|
115
|
+
|
|
116
|
+
Please see the [Contribution Guidelines](https://github.com/zscaler/zscaler-sdk-python/blob/main/CONTRIBUTING.md) for more information.
|
|
117
|
+
|
|
118
|
+
[Poetry](https://python-poetry.org/docs/) is currently being used for builds and management. You'll want to have
|
|
119
|
+
poetry installed and available in your environment.
|
|
120
|
+
|
|
121
|
+
## Issues
|
|
122
|
+
Please feel free to open an issue using [Github Issues](https://github.com/zscaler/zscaler-sdk-python/issues) if you run into any problems using Zscaler SDK Python.
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
MIT License
|
|
126
|
+
|
|
127
|
+
=======
|
|
128
|
+
|
|
129
|
+
Copyright (c) 2023 [Zscaler](https://github.com/zscaler)
|
|
130
|
+
|
|
131
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
132
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
133
|
+
in the Software without restriction, including without limitation the rights
|
|
134
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
135
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
136
|
+
furnished to do so, subject to the following conditions:
|
|
137
|
+
|
|
138
|
+
The above copyright notice and this permission notice shall be included in all
|
|
139
|
+
copies or substantial portions of the Software.
|
|
140
|
+
|
|
141
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
142
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
143
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
144
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
145
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
146
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
147
|
+
SOFTWARE.
|
|
148
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Zscaler SDK Python for the Zscaler API
|
|
2
|
+
|
|
3
|
+
[](https://github.com/zscaler/zscaler-sdk-python/actions/workflows/build.yml)
|
|
4
|
+
[](https://zscaler.readthedocs.io/?badge=latest)
|
|
5
|
+
[](https://github.com/zscaler/zscaler-sdk-python)
|
|
6
|
+
[](https://www.codacy.com/gh/zscaler/zscaler-sdk-python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=zscaler/zscaler-sdk-python&utm_campaign=Badge_Grade)
|
|
7
|
+
[](https://pypi.org/project/zscaler-sdk-python)
|
|
8
|
+
[](https://pypi.python.org/pypi/zscaler-sdk-python/)
|
|
9
|
+
[](https://github.com/zscaler/zscaler-sdk-python/releases/)
|
|
10
|
+
|
|
11
|
+
Zscaler SDK Python is an SDK that provides a uniform and easy-to-use interface for each of the Zscaler product APIs.
|
|
12
|
+
|
|
13
|
+
## Quick links
|
|
14
|
+
* [Zscaler SDK Python API Documentation](https://zscaler-sdk-python.readthedocs.io)
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
Each Zscaler product has separate developer documentation and authentication methods. This SDK simplifies
|
|
18
|
+
software development using the Zscaler API.
|
|
19
|
+
|
|
20
|
+
This SDK leverages the [RESTfly framework](https://restfly.readthedocs.io/en/latest/index.html) developed
|
|
21
|
+
by Steve McGrath.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
- Simplified authentication with Zscaler APIs.
|
|
25
|
+
- Uniform interaction with all Zscaler APIs.
|
|
26
|
+
- Uses [python-box](https://github.com/cdgriffith/Box/wiki) to add dot notation access to json data structures.
|
|
27
|
+
- Zscaler API output automatically converted from CamelCase to Snake Case.
|
|
28
|
+
- Various quality of life enhancements for object CRUD methods.
|
|
29
|
+
|
|
30
|
+
## Products
|
|
31
|
+
- Zscaler Private Access (ZPA)
|
|
32
|
+
- Zscaler Internet Access (ZIA)
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
The most recent version can be installed from pypi as per below.
|
|
37
|
+
|
|
38
|
+
$ pip install zscaler-sdk-python
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Before you can interact with any of the Zscaler APIs, you may need to generate API keys or retrieve tenancy information
|
|
43
|
+
for each product that you are interfacing with. Once you have the requirements and you have installed Zscaler SDK Python, you're ready to go.
|
|
44
|
+
|
|
45
|
+
### Quick ZIA Example
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from zscaler import ZIA
|
|
49
|
+
from pprint import pprint
|
|
50
|
+
|
|
51
|
+
zia = ZIA(api_key='API_KEY', cloud='CLOUD', username='USERNAME', password='PASSWORD')
|
|
52
|
+
for user in zia.users.list_users():
|
|
53
|
+
pprint(user)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Quick ZPA Example
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from zscaler import ZPA
|
|
60
|
+
from pprint import pprint
|
|
61
|
+
|
|
62
|
+
zpa = ZPA(client_id='CLIENT_ID', client_secret='CLIENT_SECRET', customer_id='CUSTOMER_ID')
|
|
63
|
+
for app_segment in zpa.app_segments.list_segments():
|
|
64
|
+
pprint(app_segment)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
### API Documentation
|
|
69
|
+
Zscaler SDK Python's API is fully 100% documented and is hosted at [ReadTheDocs](https://zscaler-sdk-python.readthedocs.io).
|
|
70
|
+
|
|
71
|
+
This documentation should be used when working with Zscaler SDK Python rather than referring to Zscaler's API reference.
|
|
72
|
+
Zscaler SDK Python makes some quality of life improvements to simplify and clarify arguments passed to Zscaler's API.
|
|
73
|
+
|
|
74
|
+
## Is It Tested?
|
|
75
|
+
Yes! Zscaler SDK Python has a complete test suite that fully covers all methods within the ZIA and ZPA modules.
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
Contributions to Zscaler SDK Python are absolutely welcome.
|
|
80
|
+
|
|
81
|
+
Please see the [Contribution Guidelines](https://github.com/zscaler/zscaler-sdk-python/blob/main/CONTRIBUTING.md) for more information.
|
|
82
|
+
|
|
83
|
+
[Poetry](https://python-poetry.org/docs/) is currently being used for builds and management. You'll want to have
|
|
84
|
+
poetry installed and available in your environment.
|
|
85
|
+
|
|
86
|
+
## Issues
|
|
87
|
+
Please feel free to open an issue using [Github Issues](https://github.com/zscaler/zscaler-sdk-python/issues) if you run into any problems using Zscaler SDK Python.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
MIT License
|
|
91
|
+
|
|
92
|
+
=======
|
|
93
|
+
|
|
94
|
+
Copyright (c) 2023 [Zscaler](https://github.com/zscaler)
|
|
95
|
+
|
|
96
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
97
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
98
|
+
in the Software without restriction, including without limitation the rights
|
|
99
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
100
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
101
|
+
furnished to do so, subject to the following conditions:
|
|
102
|
+
|
|
103
|
+
The above copyright notice and this permission notice shall be included in all
|
|
104
|
+
copies or substantial portions of the Software.
|
|
105
|
+
|
|
106
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
107
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
108
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
109
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
110
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
111
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
112
|
+
SOFTWARE.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "zscaler-sdk-python"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Framework for interacting with Zscaler Cloud via API"
|
|
5
|
+
authors = ["Zscaler Technology Alliances <zscaler-partner-labs@z-bd.com>"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
keywords = ["zscaler", "zpa", "zia", "zscaler-sdk-python"]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
documentation = "https://zscaler-sdk-python.readthedocs.io/"
|
|
10
|
+
homepage = "https://github.com/zscaler/zscaler-sdk-python"
|
|
11
|
+
repository = "https://github.com/zscaler/zscaler-sdk-python"
|
|
12
|
+
packages = [
|
|
13
|
+
{ include = "zscaler" }
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Information Technology",
|
|
19
|
+
"Intended Audience :: System Administrators",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Natural Language :: English",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.7",
|
|
24
|
+
"Programming Language :: Python :: 3.8",
|
|
25
|
+
"Programming Language :: Python :: 3.9",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Topic :: Security",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules", ]
|
|
29
|
+
include = [
|
|
30
|
+
"LICENSE",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.poetry.urls]
|
|
34
|
+
"Bug Tracker" = "https://github.com/zscaler/zscaler-sdk-python/issues"
|
|
35
|
+
|
|
36
|
+
[tool.poetry.dependencies]
|
|
37
|
+
python = "^3.8"
|
|
38
|
+
restfly = "1.4.7"
|
|
39
|
+
python-box = "7.0.0"
|
|
40
|
+
|
|
41
|
+
[tool.poetry.dev-dependencies]
|
|
42
|
+
python = "^3.8"
|
|
43
|
+
restfly = "1.4.7"
|
|
44
|
+
python-box = "7.0.0"
|
|
45
|
+
sphinx = "6.1.3"
|
|
46
|
+
pytest = "7.2.1"
|
|
47
|
+
requests = "2.28.2"
|
|
48
|
+
pre-commit = "3.0.4"
|
|
49
|
+
responses = "0.22.0"
|
|
50
|
+
toml = "0.10.2"
|
|
51
|
+
bandit = "^1.6.2"
|
|
52
|
+
isort = "^5.12.0"
|
|
53
|
+
m2r = "^0.3.1"
|
|
54
|
+
black = "^23.3.0"
|
|
55
|
+
poetry2setup = "^1.1.0"
|
|
56
|
+
|
|
57
|
+
[build-system]
|
|
58
|
+
requires = ["poetry-core>=1.0.0"]
|
|
59
|
+
build-backend = "poetry.core.masonry.api"
|
|
60
|
+
|
|
61
|
+
[tool.black]
|
|
62
|
+
line-length = 127
|
|
63
|
+
|
|
64
|
+
[tool.pylint.'MESSAGES CONTROL']
|
|
65
|
+
disable=[
|
|
66
|
+
"format",
|
|
67
|
+
"missing-module-docstring",
|
|
68
|
+
"missing-class-docstring",
|
|
69
|
+
"missing-function-docstring",
|
|
70
|
+
"too-many-public-methods",
|
|
71
|
+
"anomalous-backslash-in-string",
|
|
72
|
+
"import-error",
|
|
73
|
+
"redefined-outer-name",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[tool.pylint.'FORMAT']
|
|
77
|
+
max-line-length = 127
|
|
78
|
+
|
|
79
|
+
[tool.isort]
|
|
80
|
+
profile = "black"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
packages = \
|
|
5
|
+
['zscaler', 'zscaler.zia', 'zscaler.zpa']
|
|
6
|
+
|
|
7
|
+
package_data = \
|
|
8
|
+
{'': ['*']}
|
|
9
|
+
|
|
10
|
+
install_requires = \
|
|
11
|
+
['python-box==7.0.0', 'restfly==1.4.7']
|
|
12
|
+
|
|
13
|
+
setup_kwargs = {
|
|
14
|
+
'name': 'zscaler-sdk-python',
|
|
15
|
+
'version': '1.0.0',
|
|
16
|
+
'description': 'Framework for interacting with Zscaler Cloud via API',
|
|
17
|
+
'long_description': '# Zscaler SDK Python for the Zscaler API\n\n[](https://github.com/zscaler/zscaler-sdk-python/actions/workflows/build.yml)\n[](https://zscaler.readthedocs.io/?badge=latest)\n[](https://github.com/zscaler/zscaler-sdk-python)\n[](https://www.codacy.com/gh/zscaler/zscaler-sdk-python/dashboard?utm_source=github.com&utm_medium=referral&utm_content=zscaler/zscaler-sdk-python&utm_campaign=Badge_Grade)\n[](https://pypi.org/project/zscaler-sdk-python)\n[](https://pypi.python.org/pypi/zscaler-sdk-python/)\n[](https://github.com/zscaler/zscaler-sdk-python/releases/)\n\nZscaler SDK Python is an SDK that provides a uniform and easy-to-use interface for each of the Zscaler product APIs.\n\n## Quick links\n* [Zscaler SDK Python API Documentation](https://zscaler-sdk-python.readthedocs.io)\n\n## Overview\nEach Zscaler product has separate developer documentation and authentication methods. This SDK simplifies\nsoftware development using the Zscaler API.\n\nThis SDK leverages the [RESTfly framework](https://restfly.readthedocs.io/en/latest/index.html) developed\nby Steve McGrath.\n\n## Features\n- Simplified authentication with Zscaler APIs.\n- Uniform interaction with all Zscaler APIs.\n- Uses [python-box](https://github.com/cdgriffith/Box/wiki) to add dot notation access to json data structures.\n- Zscaler API output automatically converted from CamelCase to Snake Case.\n- Various quality of life enhancements for object CRUD methods.\n\n## Products\n- Zscaler Private Access (ZPA)\n- Zscaler Internet Access (ZIA)\n\n## Installation\n\nThe most recent version can be installed from pypi as per below.\n\n $ pip install zscaler-sdk-python\n\n## Usage\n\nBefore you can interact with any of the Zscaler APIs, you may need to generate API keys or retrieve tenancy information\nfor each product that you are interfacing with. Once you have the requirements and you have installed Zscaler SDK Python, you\'re ready to go.\n\n### Quick ZIA Example\n\n```python\nfrom zscaler import ZIA\nfrom pprint import pprint\n\nzia = ZIA(api_key=\'API_KEY\', cloud=\'CLOUD\', username=\'USERNAME\', password=\'PASSWORD\')\nfor user in zia.users.list_users():\n pprint(user)\n```\n\n### Quick ZPA Example\n\n```python\nfrom zscaler import ZPA\nfrom pprint import pprint\n\nzpa = ZPA(client_id=\'CLIENT_ID\', client_secret=\'CLIENT_SECRET\', customer_id=\'CUSTOMER_ID\')\nfor app_segment in zpa.app_segments.list_segments():\n pprint(app_segment)\n```\n\n## Documentation\n### API Documentation\nZscaler SDK Python\'s API is fully 100% documented and is hosted at [ReadTheDocs](https://zscaler-sdk-python.readthedocs.io).\n\nThis documentation should be used when working with Zscaler SDK Python rather than referring to Zscaler\'s API reference.\nZscaler SDK Python makes some quality of life improvements to simplify and clarify arguments passed to Zscaler\'s API.\n\n## Is It Tested?\nYes! Zscaler SDK Python has a complete test suite that fully covers all methods within the ZIA and ZPA modules.\n\n## Contributing\n\nContributions to Zscaler SDK Python are absolutely welcome.\n\nPlease see the [Contribution Guidelines](https://github.com/zscaler/zscaler-sdk-python/blob/main/CONTRIBUTING.md) for more information.\n\n[Poetry](https://python-poetry.org/docs/) is currently being used for builds and management. You\'ll want to have\npoetry installed and available in your environment.\n\n## Issues\nPlease feel free to open an issue using [Github Issues](https://github.com/zscaler/zscaler-sdk-python/issues) if you run into any problems using Zscaler SDK Python.\n\n## License\nMIT License\n\n=======\n\nCopyright (c) 2023 [Zscaler](https://github.com/zscaler)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n',
|
|
18
|
+
'author': 'Zscaler Technology Alliances',
|
|
19
|
+
'author_email': 'zscaler-partner-labs@z-bd.com',
|
|
20
|
+
'maintainer': 'None',
|
|
21
|
+
'maintainer_email': 'None',
|
|
22
|
+
'url': 'https://github.com/zscaler/zscaler-sdk-python',
|
|
23
|
+
'packages': packages,
|
|
24
|
+
'package_data': package_data,
|
|
25
|
+
'install_requires': install_requires,
|
|
26
|
+
'python_requires': '>=3.8,<4.0',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
setup(**setup_kwargs)
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
"""Zscaler SDK for Python
|
|
18
|
+
|
|
19
|
+
Zscaler SDK Python is an SDK that provides a uniform and easy-to-use interface for each of the Zscaler product APIs.
|
|
20
|
+
|
|
21
|
+
Documentation available at https://zscaler-sdk-python.readthedocs.io
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__author__ = "Zscaler Inc"
|
|
26
|
+
__email__ = "zscaler-partner-labs@z-bd.com"
|
|
27
|
+
__license__ = "MIT"
|
|
28
|
+
__contributors__ = [
|
|
29
|
+
"William Guilherme",
|
|
30
|
+
]
|
|
31
|
+
__version__ = "1.0.0"
|
|
32
|
+
|
|
33
|
+
from zscaler.zia import ZIA # noqa
|
|
34
|
+
from zscaler.zpa import ZPA # noqa
|
|
@@ -0,0 +1,150 @@
|
|
|
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 time
|
|
19
|
+
|
|
20
|
+
from box import Box, BoxList
|
|
21
|
+
from restfly import APIIterator
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def snake_to_camel(name: str):
|
|
25
|
+
"""Converts Python Snake Case to Zscaler's lower camelCase."""
|
|
26
|
+
if "_" not in name:
|
|
27
|
+
return name
|
|
28
|
+
# Edge-cases where camelCase is breaking
|
|
29
|
+
edge_cases = {
|
|
30
|
+
"routable_ip": "routableIP",
|
|
31
|
+
"is_name_l10n_tag": "isNameL10nTag",
|
|
32
|
+
"name_l10n_tag": "nameL10nTag",
|
|
33
|
+
"surrogate_ip": "surrogateIP",
|
|
34
|
+
"surrogate_ip_enforced_for_known_browsers": "surrogateIPEnforcedForKnownBrowsers",
|
|
35
|
+
}
|
|
36
|
+
return edge_cases.get(name, name[0].lower() + name.title()[1:].replace("_", ""))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def chunker(lst, n):
|
|
40
|
+
"""Yield successive n-sized chunks from lst."""
|
|
41
|
+
for i in range(0, len(lst), n):
|
|
42
|
+
yield lst[i : i + n]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Recursive function to convert all keys and nested keys from snake case
|
|
46
|
+
# to camel case.
|
|
47
|
+
def convert_keys(data):
|
|
48
|
+
if isinstance(data, (list, BoxList)):
|
|
49
|
+
return [convert_keys(inner_dict) for inner_dict in data]
|
|
50
|
+
elif isinstance(data, (dict, Box)):
|
|
51
|
+
new_dict = {}
|
|
52
|
+
for k in data.keys():
|
|
53
|
+
v = data[k]
|
|
54
|
+
new_key = snake_to_camel(k)
|
|
55
|
+
new_dict[new_key] = convert_keys(v) if isinstance(v, (dict, list)) else v
|
|
56
|
+
return new_dict
|
|
57
|
+
else:
|
|
58
|
+
return data
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def keys_exists(element: dict, *keys):
|
|
62
|
+
"""
|
|
63
|
+
Check if *keys (nested) exists in `element` (dict).
|
|
64
|
+
"""
|
|
65
|
+
if not isinstance(element, dict):
|
|
66
|
+
raise AttributeError("keys_exists() expects dict as first argument.")
|
|
67
|
+
if not keys:
|
|
68
|
+
raise AttributeError("keys_exists() expects at least two arguments, one given.")
|
|
69
|
+
|
|
70
|
+
_element = element
|
|
71
|
+
for key in keys:
|
|
72
|
+
try:
|
|
73
|
+
_element = _element[key]
|
|
74
|
+
except KeyError:
|
|
75
|
+
return False
|
|
76
|
+
return True
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# Takes a tuple if id_groups, kwargs and the payload dict; reformat for API call
|
|
80
|
+
def add_id_groups(id_groups: list, kwargs: dict, payload: dict):
|
|
81
|
+
for entry in id_groups:
|
|
82
|
+
if kwargs.get(entry[0]):
|
|
83
|
+
payload[entry[1]] = [{"id": param_id} for param_id in kwargs.pop(entry[0])]
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def obfuscate_api_key(seed: list):
|
|
88
|
+
now = int(time.time() * 1000)
|
|
89
|
+
n = str(now)[-6:]
|
|
90
|
+
r = str(int(n) >> 1).zfill(6)
|
|
91
|
+
key = "".join(seed[int(str(n)[i])] for i in range(len(str(n))))
|
|
92
|
+
for j in range(len(r)):
|
|
93
|
+
key += seed[int(r[j]) + 2]
|
|
94
|
+
|
|
95
|
+
return {"timestamp": now, "key": key}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def pick_version_profile(kwargs: list, payload: list):
|
|
99
|
+
# Used in ZPA endpoints.
|
|
100
|
+
# This function is used to convert the name of the version profile to
|
|
101
|
+
# the version profile id. This means our users don't need to look up the
|
|
102
|
+
# version profile id mapping themselves.
|
|
103
|
+
|
|
104
|
+
version_profile = kwargs.pop("version_profile", None)
|
|
105
|
+
if version_profile:
|
|
106
|
+
payload["overrideVersionProfile"] = True
|
|
107
|
+
if version_profile == "default":
|
|
108
|
+
payload["versionProfileId"] = 0
|
|
109
|
+
elif version_profile == "previous_default":
|
|
110
|
+
payload["versionProfileId"] = 1
|
|
111
|
+
elif version_profile == "new_release":
|
|
112
|
+
payload["versionProfileId"] = 2
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Iterator(APIIterator):
|
|
116
|
+
"""Iterator class."""
|
|
117
|
+
|
|
118
|
+
page_size = 100
|
|
119
|
+
|
|
120
|
+
def __init__(self, api, path: str = "", **kw):
|
|
121
|
+
"""Initialize Iterator class."""
|
|
122
|
+
super().__init__(api, **kw)
|
|
123
|
+
|
|
124
|
+
self.path = path
|
|
125
|
+
self.max_items = kw.pop("max_items", 0)
|
|
126
|
+
self.max_pages = kw.pop("max_pages", 0)
|
|
127
|
+
self.payload = {}
|
|
128
|
+
if kw:
|
|
129
|
+
self.payload = {snake_to_camel(key): value for key, value in kw.items()}
|
|
130
|
+
|
|
131
|
+
def _get_page(self) -> None:
|
|
132
|
+
"""Iterator function to get the page."""
|
|
133
|
+
resp = self._api.get(
|
|
134
|
+
self.path,
|
|
135
|
+
params={**self.payload, "page": self.num_pages + 1},
|
|
136
|
+
)
|
|
137
|
+
try:
|
|
138
|
+
# If we are using ZPA then the API will return records under the
|
|
139
|
+
# 'list' key.
|
|
140
|
+
self.page = resp.get("list") or []
|
|
141
|
+
except AttributeError:
|
|
142
|
+
# If the list key doesn't exist then we're likely using ZIA so just
|
|
143
|
+
# return the full response.
|
|
144
|
+
self.page = resp
|
|
145
|
+
finally:
|
|
146
|
+
# If we use the default retry-after logic in Restfly then we are
|
|
147
|
+
# going to keep seeing 429 messages in stdout. ZIA and ZPA have a
|
|
148
|
+
# standard 1 sec rate limit on the API endpoints with pagination so
|
|
149
|
+
# we are going to include it here.
|
|
150
|
+
time.sleep(1)
|