Skip to content

Commit

Permalink
Small changes (#46)
Browse files Browse the repository at this point in the history
* Add .gitignore and populate with Python defaults

* Expose ZIA and ZPA Classes to root module.

* Add contributors variable

* make code more readable

* fix typo

* fix typo.  zia.users.list() doesn't exist but zia.users.list_users() does.

* search for adminuser works

* drop .gitignore and undo changes in utils.py

* Missed some undoing changes in utils.py

Co-authored-by: Dax Mickelson <dmickelson@zscaler.com>
  • Loading branch information
daxm and Dax Mickelson committed Oct 20, 2021
1 parent 7a23e8d commit 496188a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from pyzscaler.zia import ZIA
from pprint import pprint

zia = ZIA(api_key='API_KEY', cloud='CLOUD', username='USERNAME', password='PASSWORD')
for user in zia.users.list():
for user in zia.users.list_users():
pprint(user)
```

Expand Down
6 changes: 6 additions & 0 deletions pyzscaler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
__author__ = "Mitch Kelly"
__license__ = "MIT"
__contributors__ = [
"Dax Mickelson",
]

from .zia import ZIA
from .zpa import ZPA
13 changes: 12 additions & 1 deletion pyzscaler/zia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .url_filters import URLFilteringAPI
from .users import UserManagementAPI
from .vips import DataCenterVIPSAPI
from .admin_role_management import AdminAndRoleManagementAPI


class ZIA(APISession):
Expand Down Expand Up @@ -54,7 +55,9 @@ def _build_session(self, **kwargs) -> None:
"""Creates a ZIA API session."""
super(ZIA, self)._build_session(**kwargs)
return self.session.create(
api_key=self._api_key, username=self._username, password=self._password
api_key=self._api_key,
username=self._username,
password=self._password,
)

def _deauthenticate(self):
Expand Down Expand Up @@ -170,3 +173,11 @@ def vips(self):
"""
return DataCenterVIPSAPI(self)

@property
def admin_and_role_management(self):
"""
The interface object for the :ref: `ZIA Admin and Role Management interface <zia-admin_and_role_management>`.
"""
return AdminAndRoleManagementAPI(self)
30 changes: 30 additions & 0 deletions pyzscaler/zia/admin_role_management.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from restfly.endpoint import APIEndpoint

from pyzscaler.utils import Iterator


class AdminAndRoleManagementAPI(APIEndpoint):
def get_admin_users(self, **kwargs):
"""
Returns a list of admin users.
Keyword Args:
**include_auditor_users (bool, optional):
Include or exclude auditor user information in the list.
**include_admin_users (bool, optional):
Include or exclude admin user information in the list. (default: True)
**search (str, optional):
The search string used to partially match against an admin/auditor user's Login ID or Name.
**page (int, optional):
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:`list`: The admin_users resource record.
Examples:
>>> department = zia.admin_and_role_management.get_admin_users(search='login_name')
"""
return list(Iterator(self._api, "adminUsers", **kwargs))

0 comments on commit 496188a

Please sign in to comment.