users#

The following methods allow for interaction with the ZIA User Management API endpoints.

Methods are accessible via zia.users

class UserManagementAPI#

The methods within this section use the ZIA User Management API and are accessed via ZIA.users.

add_user(name, email, groups, department, **kwargs)#

Creates a new ZIA user.

Parameters:
  • name (str) – User name.

  • email (str) – User email consists of a user name and domain name. It does not have to be a valid email address, but it must be unique and its domain must belong to the organisation.

  • groups (list) – List of Groups a user belongs to.

  • department (dict) – The department the user belongs to.

Keyword Arguments:
  • **comments (str) – Additional information about this user.

  • **tempAuthEmail (str) – Temporary Authentication Email. If you enabled one-time tokens or links, enter the email address to which the Zscaler service sends the tokens or links. If this is empty, the service will send the email to the User email.

  • **adminUser (bool) – True if this user is an Admin user.

  • **password (str) – User’s password. Applicable only when authentication type is Hosted DB. Password strength must follow what is defined in the auth settings.

  • **type (str) – User type. Provided only if this user is not an end user. Accepted values are SUPERADMIN, ADMIN, AUDITOR, GUEST, REPORT_USER and UNAUTH_TRAFFIC_DEFAULT.

Returns:

The resource record for the new user.

Return type:

Box

Examples

Add a user with the minimum required params:

>>> zia.users.add_user(name='Jane Doe',
...    email='jane.doe@example.com',
...    groups=[{
...      'id': '49916183'}]
...    department={
...      'id': '49814321'})
bulk_delete_users(user_ids)#

Bulk delete ZIA users.

Parameters:

user_ids (list) – List containing id int of each user that will be deleted.

Returns:

Object containing list of users that were deleted.

Return type:

Box

Examples

>>> bulk_delete_users = zia.users.bulk_delete_users(['99999', '88888', '77777'])
delete_user(user_id)#

Deletes the specified user ID.

Parameters:

user_id (str) – The unique identifier of the user that will be deleted.

Returns:

The response code for the request.

Return type:

int

Examples
>>> user = zia.users.delete_user('99999')
get_department(department_id)#

Returns the department details for a given department.

Parameters:

department_id (str) – The unique identifier for the department.

Returns:

The department resource record.

Return type:

Box

Examples

>>> department = zia.users.get_department('99999')
get_group(group_id)#

Returns the user group details for a given user group.

Parameters:

group_id (str) – The unique identifier for the user group.

Returns:

The user group resource record.

Return type:

Box

Examples

>>> user_group = zia.users.get_group('99999')
get_user(user_id=None, email=None)#

Returns the user information for the specified ID or email.

Parameters:
  • user_id (optional, str) – The unique identifier for the requested user.

  • email (optional, str) – The unique email for the requested user.

Returns:

The resource record for the requested user.

Return type:

Box

Examples
>>> user = zia.users.get_user('99999')
>>> user = zia.users.get_user(email='jane.doe@example.com')
list_departments(**kwargs)#

Returns the list of departments.

Keyword Arguments:
  • **limit_search (bool, optional) – Limits the search to match against the department name only.

  • **max_items (int, optional) – The maximum number of items to request before stopping iteration.

  • **max_pages (int, optional) – The maximum number of pages to request before stopping iteration.

  • **page_size (int, optional) – Specifies the page size. The default size is 100, but the maximum size is 1000.

  • **search (str, optional) – The search string used to match against a department’s name or comments attributes.

Returns:

The list of departments configured in ZIA.

Return type:

BoxList

Examples

List departments using default settings:

>>> for department in zia.users.list_departments():
...   print(department)

List departments, limiting to a maximum of 10 items:

>>> for department in zia.users.list_departments(max_items=10):
...    print(department)

List departments, returning 200 items per page for a maximum of 2 pages:

>>> for department in zia.users.list_departments(page_size=200, max_pages=2):
...    print(department)
list_groups(**kwargs)#

Returns the list of user groups.

Keyword Arguments:
  • **max_items (int, optional) – The maximum number of items to request before stopping iteration.

  • **max_pages (int, optional) – The maximum number of pages to request before stopping iteration.

  • **page_size (int, optional) – Specifies the page size. The default size is 100, but the maximum size is 1000.

  • **search (str, optional) – The search string used to match against a group’s name or comments attributes.

Returns:

The list of user groups configured in ZIA.

Return type:

BoxList

Examples

List groups using default settings:

>>> for group in zia.users.list_groups():
...    print(group)

List groups, limiting to a maximum of 10 items:

>>> for group in zia.users.list_groups(max_items=10):
...    print(group)

List groups, returning 200 items per page for a maximum of 2 pages:

>>> for group in zia.users.list_groups(page_size=200, max_pages=2):
...    print(group)
list_users(**kwargs)#

Returns the list of users.

Keyword Arguments:
  • **dept (str, optional) – Filters by department name. This is a starts with match.

  • **group (str, optional) – Filters by group name. This is a starts with match.

  • **max_items (int, optional) – The maximum number of items to request before stopping iteration.

  • **max_pages (int, optional) – The maximum number of pages to request before stopping iteration.

  • **name (str, optional) – Filters by user name. This is a partial match.

  • **page_size (int, optional) – Specifies the page size. The default size is 100, but the maximum size is 1000.

Returns:

The list of users configured in ZIA.

Return type:

BoxList

Examples

List users using default settings:

>>> for user in zia.users.list_users():
...    print(user)

List users, limiting to a maximum of 10 items:

>>> for user in zia.users.list_users(max_items=10):
...    print(user)

List users, returning 200 items per page for a maximum of 2 pages:

>>> for user in zia.users.list_users(page_size=200, max_pages=2):
...    print(user)
update_user(user_id, **kwargs)#

Updates the details for the specified user.

Parameters:
  • user_id (str) – The unique identifier for the user.

  • **kwargs – Optional parameters

Keyword Arguments:
  • **adminUser (bool) – True if this user is an Admin user.

  • **comments (str) – Additional information about this user.

  • **department (dict, optional) – The updated department object. Defaults to existing department if not specified.

  • **email (str, optional) – The updated email. Defaults to existing email if not specified.

  • **groups (list of dict, optional) – The updated list of groups. Defaults to existing groups if not specified.

  • **name (str, optional) – The updated name. Defaults to existing name if not specified.

  • **password (str) – User’s password. Applicable only when authentication type is Hosted DB. Password strength must follow what is defined in the auth settings.

  • **tempAuthEmail (str) – Temporary Authentication Email. If you enabled one-time tokens or links, enter the email address to which the Zscaler service sends the tokens or links. If this is empty, the service will send the email to the User email.

  • **type (str) – User type. Provided only if this user is not an end user. Accepted values are SUPERADMIN, ADMIN, AUDITOR, GUEST, REPORT_USER and UNAUTH_TRAFFIC_DEFAULT.

Returns:

The resource record of the updated user.

Return type:

Box

Examples

Update the user name:

>>> zia.users.update_user('99999',
...      name='Joe Bloggs')

Update the email and add a comment:

>>> zia.users.update_user('99999',
...      name='Joe Bloggs',
...      comment='External auditor.')