emergency_access

The following methods allow for interaction with the ZPA ZPA Emergency Access API endpoints.

Methods are accessible via zpa.emergency_access

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 EmergencyAccessAPI

Bases: APIClient

A Client object for the Emergency Access Users resource.

activate_user(user_id, send_email=False, **kwargs)

Activates the emergency access user.

Parameters:
  • user_id (str) – The unique identifier of the emergency access user.

  • send_email (bool, optional) – Whether to send an email upon activation. Defaults to False.

Returns:

A tuple containing the EmergencyAccessUser instance, response object, and error if any.

Return type:

tuple

add_user(activate_now=True, **kwargs)

Add an emergency access user.

Parameters:
  • email_id (str) – The email address of the emergency access user.

  • first_name (str) – The first name of the emergency access user.

  • last_name (str) – The last name of the emergency access user.

  • user_id (str) – The unique identifier of the emergency access user.

  • update_enabled (bool) – Indicates if the emergency access user can be updated (true) or not (false).

  • activate_now (bool, optional) – Indicates if the emergency access user is activated upon creation. Defaults to True.

Returns:

A tuple containing the EmergencyAccessUser instance, response object, and error if any.

Return type:

Tuple

Examples

>>> added_user, _, err = client.zpa.emergency_access.add_user(
...     email_id=f"user1_{random.randint(1000, 10000)}@acme.com",
...     user_id="user1",
...     first_name="User1",
...     last_name="Smith",
...     activated_on="1",
...     allowed_activate=True,
...     allowed_deactivate=True,
... )
... if err:
...     print(f"Error creating emergency user: {err}")
...     return
... print(f"emergency user created successfully: {added_user.as_dict()}")
deactivate_user(user_id, **kwargs)

Deactivates the emergency access user.

Parameters:

user_id (str) – The unique identifier of the emergency access user.

Returns:

A tuple containing the EmergencyAccessUser instance, response object, and error if any.

Return type:

tuple

get_user(user_id, query_params=None)

Returns information on the specified emergency access user.

Parameters:

user_id (str) – The unique identifier for the emergency access user.

Returns:

A tuple containing the EmergencyAccessUser instance, response object, and error if any.

Return type:

tuple

Examples

>>> fetched_user, _, err = client.zpa.emergency_access.get_user('999999')
... if err:
...     print(f"Error fetching user by ID: {err}")
...     return
... print(f"Fetched user by ID: {fetched_user.as_dict()}")
list_users(query_params=None, **kwargs)

Enumerates emergency access in your organization with pagination. A subset of emergency access can be returned that match a supported filter expression or query.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.page_id] {str}: Specifies the page number.

[query_params.page_size] {str}: Specifies the page size.

If not provided, the default page size is 20. The max page size is 500.

[query_params.search] {str}: The search string used to support search by features and fields for the API. [query_params.microtenant_id] {str}: The unique identifier of the microtenant of ZPA tenant.

Returns:

A tuple containing (list of Emergency Access instances, Response, error)

Return type:

Tuple

Examples

>>> access_list, _, err = client.zpa.emergency_access.list_users(
... query_params={'search': 'first_name+EQ+Emily', 'page_id': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing emergency access users: {err}")
...     return
... print(f"Total emergency access users found: {len(access_list)}")
... for user in access_list:
...     print(user.as_dict())
update_user(user_id, activate_now=True, **kwargs)

Updates the specified emergency access user.

Parameters:

user_id (str) – The unique identifier of the emergency access user.

Keyword Arguments:
  • email_id (str) – The email address of the emergency access user.

  • first_name (str) – The first name of the emergency access user.

  • last_name (str) – The last name of the emergency access user.

Returns:

A tuple containing the EmergencyAccessUser instance, response object, and error if any.

Return type:

tuple

Examples

>>> update_user, _, err = client.zpa.emergency_access.add_uupdate_userser(
...     user_id='99999'
...     email_id=f"user1_{random.randint(1000, 10000)}@acme.com",
...     user_id="user1",
...     first_name="User1",
...     last_name="Smith",
...     activated_on="1",
...     allowed_activate=True,
...     allowed_deactivate=True,
... )
... if err:
...     print(f"Error updating emergency user: {err}")
...     return
... print(f"emergency user updated successfully: {added_update_useruser.as_dict()}")