Skip to content

Commit

Permalink
Merge tag '1.4.1' into develop
Browse files Browse the repository at this point in the history
Tagging version 1.4.1 1.4.1
  • Loading branch information
mitchos committed Feb 20, 2023
2 parents 57402f9 + 4502dc8 commit 656f96d
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: ^(docsrc/|docs/|examples/)
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
rev: 23.1.0
hooks:
- id: black
name: black
Expand All @@ -12,7 +12,7 @@ repos:
types: [python]

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 6.0.0
hooks:
- id: flake8

Expand Down
13 changes: 6 additions & 7 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
black==22.10.0
sphinx==5.3.0
furo==2022.12.7
pre-commit==3.0.4
pytest==7.2.1
python-box==7.0.0
restfly==1.4.7
python-box==6.1.0
furo==2022.9.29
pre-commit==2.20.0
pytest==7.2.0
requests==2.28.2
responses==0.22.0
requests==2.28.1
sphinx==6.1.3
toml==0.10.2
2 changes: 1 addition & 1 deletion docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# The short X.Y version
version = '1.4'
# The full version, including alpha/beta/rc tags
release = '1.4.0'
release = '1.4.1'

# -- General configuration ---------------------------------------------------

Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyzscaler"
version = "1.4.0"
version = "1.4.1"
description = "A python SDK for the Zscaler API."
authors = ["Mitch Kelly <me@mkelly.dev>"]
license = "MIT"
Expand Down Expand Up @@ -32,17 +32,17 @@ include = [
[tool.poetry.dependencies]
python = "^3.7"
restfly = "1.4.7"
python-box = "6.1.0"
python-box = "7.0.0"

[tool.poetry.dev-dependencies]
python = "^3.7"
restfly = "1.4.7"
python-box = "6.1.0"
Sphinx = "5.3.0"
furo = "2022.9.29"
pytest = "7.2.0"
requests = "2.28.1"
pre-commit = "2.20.0"
python-box = "7.0.0"
sphinx = "6.1.3"
furo = "2022.12.7"
pytest = "7.2.1"
requests = "2.28.2"
pre-commit = "3.0.4"
responses = "0.22.0"
toml = "0.10.2"

Expand Down
2 changes: 1 addition & 1 deletion pyzscaler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Dax Mickelson",
"Jacob Gårder",
]
__version__ = "1.4.0"
__version__ = "1.4.1"

from pyzscaler.zcc import ZCC # noqa
from pyzscaler.zia import ZIA # noqa
Expand Down
78 changes: 55 additions & 23 deletions pyzscaler/zia/admin_and_role_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ class AdminAndRoleManagementAPI(APIEndpoint):
def add_user(self, name: str, login_name: str, email: str, password: str, **kwargs) -> Box:
"""
Adds a new admin user to ZIA.
Args:
name (str): The user's full name.
login_name (str):
The name that the admin user will use to login to ZIA in email format, i.e. `user@domain.tld.`
email (str): The email address for the admin user.
password (str): The password for the admin user.
**kwargs: Optional keyword args.
Keyword Args:
admin_scope (str): The scope of the admin's permissions, accepted values are:
``organization``, ``department``, ``location``, ``location_group``
Expand All @@ -37,30 +39,36 @@ def add_user(self, name: str, login_name: str, email: str, password: str, **kwar
``department`` then you will need to provide a list of department ids.
**NOTE**: This param doesn't need to
be provided if the admin user's scope is set to ``organization``.
Returns:
:obj:`Box`: The newly created admin user resource record.
Examples:
Add an admin user with the minimum required params:
>>> admin_user = zia.admin_and_role_management.add_user(
... name="Jim Bob",
... login_name="jim@example.com",
... password="hunter2",
... email="jim@example.com")
>>> admin_user = zia.admin_and_role_management.add_user(
... name="Jim Bob",
... login_name="jim@example.com",
... password="hunter2",
... email="jim@example.com")
Add an admin user with a department admin scope:
>>> admin_user = zia.admin_and_role_management.add_user(
... name="Jane Bob",
... login_name="jane@example.com",
... password="hunter3",
... email="jane@example.com,
... admin_scope="department",
... scope_ids = ['376542', '245688'])
>>> admin_user = zia.admin_and_role_management.add_user(
... name="Jane Bob",
... login_name="jane@example.com",
... password="hunter3",
... email="jane@example.com,
... admin_scope="department",
... scope_ids = ['376542', '245688'])
Add an auditor user:
>>> auditor_user = zia.admin_and_role_management.add_user(
... name="Head Bob",
... login_name="head@example.com",
... password="hunter4",
... email="head@example.com,
... is_auditor=True)
>>> auditor_user = zia.admin_and_role_management.add_user(
... name="Head Bob",
... login_name="head@example.com",
... password="hunter4",
... email="head@example.com,
... is_auditor=True)
"""
payload = {
"userName": name,
Expand Down Expand Up @@ -98,6 +106,7 @@ def add_user(self, name: str, login_name: str, email: str, password: str, **kwar
def list_users(self, **kwargs) -> BoxList:
"""
Returns a list of admin users.
Keyword Args:
**include_auditor_users (bool, optional):
Include or exclude auditor user information in the list.
Expand All @@ -109,26 +118,34 @@ def list_users(self, **kwargs) -> BoxList:
Specifies the page offset.
**page_size (int, optional):
Specifies the page size. The default size is 100, but the maximum size is 1000.
Returns:
:obj:`BoxList`: The admin_users resource record.
Examples:
>>> users = zia.admin_and_role_management.list_users(search='login_name')
"""
return BoxList(Iterator(self._api, "adminUsers", **kwargs))

def list_roles(self, **kwargs) -> BoxList:
"""
Return a list of the configured admin roles in ZIA.
Args:
**kwargs: Optional keyword args.
Keyword Args:
include_auditor_role (bool): Set to ``True`` to include auditor role information in the response.
include_partner_role (bool): Set to ``True`` to include partner admin role information in the response.
Returns:
:obj:`BoxList`: A list of admin role resource records.
Examples:
Get a list of all configured admin roles:
>>> roles = zia.admin_and_management_roles.list_roles()
"""
payload = {snake_to_camel(key): value for key, value in kwargs.items()}

Expand All @@ -137,12 +154,16 @@ def list_roles(self, **kwargs) -> BoxList:
def get_user(self, user_id: str) -> Box:
"""
Returns information on the specified admin user id.
Args:
user_id (str): The unique id of the admin user.
Returns:
:obj:`Box`: The admin user resource record.
Examples:
>>> print(zia.admin_and_role_management.get_user('987321202'))
"""
admin_user = next(user for user in self.list_users() if user.id == int(user_id))

Expand All @@ -151,22 +172,28 @@ def get_user(self, user_id: str) -> Box:
def delete_user(self, user_id: str) -> int:
"""
Deletes the specified admin user by id.
Args:
user_id (str): The unique id of the admin user.
Returns:
:obj:`int`: The response code for the request.
Examples:
>>> zia.admin_role_management.delete_admin_user('99272455')
"""

return self._delete(f"adminUsers/{user_id}", box=False).status_code

def update_user(self, user_id: str, **kwargs) -> dict:
"""
Update an admin user.
Args:
user_id (str): The unique id of the admin user to be updated.
**kwargs: Optional keyword args.
Keyword Args:
admin_scope (str): The scope of the admin's permissions, accepted values are:
``organization``, ``department``, ``location``, ``location_group``
Expand All @@ -192,16 +219,21 @@ def update_user(self, user_id: str, **kwargs) -> dict:
``department`` then you will need to provide a list of department ids.
**NOTE:** This param doesn't need to
be provided if the admin user's scope is set to `organization`.
Returns:
:obj:`dict`: The updated admin user resource record.
Examples:
Update the email address for an admin user:
>>> user = zia.admin_and_role_management.update_user('99695301',
... email='jimbob@example.com')
>>> user = zia.admin_and_role_management.update_user('99695301',
... email='jimbob@example.com')
Update the admin scope for an admin user to department:
>>> user = zia.admin_and_role_management.update_user('99695301',
... admin_scope='department',
... scope_ids=['3846532', '3846541'])
>>> user = zia.admin_and_role_management.update_user('99695301',
... admin_scope='department',
... scope_ids=['3846532', '3846541'])
"""

# Get the resource record for the provided user id
Expand Down
1 change: 0 additions & 1 deletion pyzscaler/zpa/service_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class ServiceEdgesAPI(APIEndpoint):

# Parameter names that will be reformatted to be compatible with ZPAs API
reformat_params = [
("service_edge_ids", "serviceEdges"),
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
restfly==1.4.7
python-box==6.1.0
python-box==7.0.0
1 change: 0 additions & 1 deletion tests/zcc/test_zcc_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

@responses.activate
def test_create_token(zcc, session):

responses.add(
responses.POST,
url="https://api-mobile.zscaler.net/papi/auth/v1/login",
Expand Down
1 change: 0 additions & 1 deletion tests/zia/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def test_delete_urls_from_whitelist(zia, whitelist_urls):

@responses.activate
def test_add_urls_to_blacklist(zia, blacklist_urls):

blacklist_urls["blacklistUrls"].append("mysite.com")

responses.add(
Expand Down
1 change: 0 additions & 1 deletion tests/zia/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

@responses.activate
def test_create(zia, session):

responses.add(
responses.POST,
url="https://zsapi.zscaler.net/api/v1/authenticatedSession",
Expand Down

0 comments on commit 656f96d

Please sign in to comment.