admin_users

The following methods allow for interaction with the ZTW Admin Users Management API endpoints.

Methods are accessible via ztw.admin_users

Copyright (c) 2023, Zscaler Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

class AdminUsersAPI

Bases: APIClient

A Client object for the Admin and Role resource.

add_admin(user_name, login_name, role, email, password, **kwargs)

Create a new admin user.

Parameters:
  • user_name (str) – The name of the admin user.

  • login_name (str) – The login name of the admin user.

  • role (str) – The role of the admin user.

  • email (str) – The email address of the admin user.

  • password (str) – The password for the admin user.

Keyword Arguments:
  • disabled (bool) – Indicates whether the admin is disabled.

  • new_location_create_allowed (bool) – Indicates whether the admin can create new locations.

  • admin_scope_type (str) – The admin scope type.

  • admin_scope_group_member_entity_ids (list) – Applicable if the admin scope type is LOCATION_GROUP.

  • is_default_admin (bool) – Indicates whether the admin is the default admin.

  • is_deprecated_default_admin (bool) – Indicates whether this admin is deletable.

  • is_auditor (bool) – Indicates whether the admin is an auditor.

  • is_security_report_comm_enabled (bool) – Indicates whether the admin can receive security reports.

  • is_service_update_comm_enabled (bool) – Indicates whether the admin can receive service updates.

  • is_password_login_allowed (bool) – Indicates whether the admin can log in with a password.

  • is_product_update_comm_enabled (bool) – Indicates whether the admin can receive product updates.

  • is_exec_mobile_app_enabled (bool) – Indicates whether Executive Insights App access is enabled for the admin.

  • send_mobile_app_invite (bool) – Indicates whether to send an invitation email to download Executive Insights App to admin.

  • send_zdx_onboard_invite (bool) – Indicates whether to send an invitation email for ZDX onboarding to admin.

  • comments (str) – Comments for the admin user.

  • name (str) – Admin user’s “friendly” name, e.g., “FirstName LastName” (this field typically matches userName.)

Returns:

A Box object representing the newly created admin user.

Return type:

Tuple

Examples

Create a new admin user with only the required parameters:

ztw.admin.add_admin(
    name="Jane Smith",
    login_name="jsmith",
    role="admin",
    email="jsmith@example.com",
    password="password123",
    )

Create a new admin with some additional parameters:

ztw.admin.add_admin(
    name="Jane Smith",
    login_name="jsmith",
    role="admin",
    email="jsmith@example.com",
    password="password123",
    is_default_admin=False,
    disabled=False,
    comments="New admin user"
change_password(username, old_password, new_password, **kwargs)

Change the password for the specified admin user.

Parameters:
  • username (str) – The username of the admin user.

  • old_password (str) – The current password of the admin user.

  • new_password (str) – The new password for the admin user.

Returns:

The status code of the operation.

Return type:

int

Examples

Change a password:

ztw.admin.change_password("jdoe", "oldpassword123", "newpassword123")
delete_admin(admin_id)

Delete the specified admin user.

Parameters:

admin_id (str) – The ID of the admin user to delete.

Returns:

The status code of the operation.

Return type:

int

Examples

Delete an admin user:

ztw.admin.delete_admin("123456789")
get_admin(admin_id)

Get details for a specific admin user.

Parameters:

admin_id (str) – The ID of the admin user to retrieve.

Returns:

The admin user details.

Return type:

Tuple

Examples

Print the details of an admin user:

print(ztw.admin.get_admin("123456789")
list_admins(query_params=None)

List all existing admin users.

Keyword Arguments:
  • include_auditor_users (bool) – Include / exclude auditor users in the response.

  • include_admin_users (bool) – Include / exclude admin users in the response.

  • include_api_roles (bool) – Include / exclude API roles in the response.

  • search (str) – The search string to filter by.

  • page (int) – The page offset to return.

  • page_size (int) – The number of records to return per page.

  • version (int) – Specifies the admins from a backup version

Returns:

The list of admin users.

Return type:

Tuple

Examples

List all admins:

for admin in ztw.admin.list_admins():
    print(admin)

List all admins with advanced features:

for admin in ztw.admin.list_admins(
    include_auditor_users=True,
    include_admin_users=True,
    include_api_roles=True,
):
    print(admin)
update_admin(admin_id, **kwargs)

Update an existing admin user.

Parameters:

admin_id (str) – The ID of the admin user to update.

Keyword Arguments:
  • role (str) – The role of the admin user.

  • email (str) – The email address of the admin user.

  • password (str) – The password for the admin user.

  • disabled (bool) – Indicates whether the admin is disabled.

  • new_location_create_allowed (bool) – Indicates whether the admin can create new locations.

  • admin_scope_type (str) – The admin scope type.

  • admin_scope_group_member_entity_ids (list) – Applicable if the admin scope type is LOCATION_GROUP.

  • is_default_admin (bool) – Indicates whether the admin is the default admin.

  • is_deprecated_default_admin (bool) – Indicates whether this admin is deletable.

  • is_auditor (bool) – Indicates whether the admin is an auditor.

  • is_security_report_comm_enabled (bool) – Indicates whether the admin can receive security reports.

  • is_service_update_comm_enabled (bool) – Indicates whether the admin can receive service updates.

  • is_password_login_allowed (bool) – Indicates whether the admin can log in with a password.

  • is_product_update_comm_enabled (bool) – Indicates whether the admin can receive product updates.

  • is_exec_mobile_app_enabled (bool) – Indicates whether Executive Insights App access is enabled for the admin.

  • send_mobile_app_invite (bool) – Indicates whether to send an invitation email to download Executive Insights App to admin.

  • send_zdx_onboard_invite (bool) – Indicates whether to send an invitation email for ZDX onboarding to admin.

  • comments (str) – Comments for the admin user.

  • name (str) – Admin user’s “friendly” name, e.g., “FirstName LastName” (this field typically matches userName.)

Returns:

A Box object representing the updated admin user.

Return type:

Tuple

Examples

Update an admin user:

ztw.admin.update_admin(
    admin_id="123456789",
    admin_scope_type="LOCATION_GROUP",
    comments="Updated admin user",
)