user_portal_controller

The following methods allow for interaction with the ZPA User Portal Controller API endpoints.

Methods are accessible via zpa.user_portal_controller

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 UserPortalControllerAPI

Bases: APIClient

A client object for the User Portal Controller resource.

add_user_portal(**kwargs)

Adds a new user portal.

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

  • description (str) – The description of the user portal.

  • enabled (bool) – Enable the user portal. Defaults to True.

  • user_notification (str) – The user notification message for the portal.

  • user_notification_enabled (bool) – Whether user notifications are enabled for the portal.

  • managed_by_zs (bool) – Whether the portal is managed by Zscaler.

  • ext_label (str) – The external label for the portal.

  • ext_domain (str) – The external domain for the portal.

  • ext_domain_name (str) – The external domain name for the portal.

Returns:

UserPortalController: The created user portal object.

Return type:

Tuple

Example

Basic example: Add a new user portal

>>> added_portal, _, err = client.zpa.user_portal_controller.add_user_portal(
...     name=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     description=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     enabled=True,
...     user_notification=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     user_notification_enabled=True,
...     managed_by_zs=True,
...     ext_label='portal01',
...     ext_domain='acme.com'
...     ext_domain_name='-acme.com.b.zscalerportal.net'
... )
>>> if err:
...     print(f"Error adding user portal: {err}")
...     return
... print(f"user portal added successfully: {added_portal.as_dict()}")
delete_user_portal(portal_id, microtenant_id=None)

Deletes the specified user portal.

Parameters:

portal_id (str) – The unique identifier for the user portal to be deleted.

Returns:

Status code of the delete operation.

Return type:

int

Example

# Delete a user portal by ID >>> _, _, err = client.zpa.user_portal_controller.delete_user_portal(‘513265’) … if err: … print(f”Error deleting user portal: {err}”) … return … print(f”User Portal with ID {‘513265’} deleted successfully.”)

get_user_portal(portal_id, query_params=None)

Gets information on the specified user portal.

Parameters:
  • portal_id (str) – The unique identifier of the user portal.

  • query_params (dict, optional) – Map of query parameters for the request. [query_params.microtenant_id] {str}: The microtenant ID, if applicable.

Returns:

UserPortalController: The corresponding user portal object.

Return type:

Tuple

Example

Retrieve details of a specific user portal

>>> fetched_portal, _, err = client.zpa.user_portal_controller.get_user_portal('999999')
... if err:
...     print(f"Error fetching user portal by ID: {err}")
...     return
... print(f"Fetched user portal by ID: {fetched_portal.as_dict()}")
list_user_portals(query_params=None)

Enumerates user portals in an organization with pagination.

Parameters:

{dict} (query_params) – Map of query parameters for the request. [query_params.page] {str}: Specifies the page number. [query_params.page_size] {int}: Page size for pagination. [query_params.search] {str}: Search string for filtering results. [query_params.ui_config] {str}: Filter by UI Configuration. [query_params.microtenant_id] {str}: ID of the microtenant, if applicable.

Returns:

A tuple containing (list of UserPortalController instances, Response, error)

Return type:

Tuple

Example

Fetch all user portals without filtering

>>> portal_list, _, err = client.zpa.user_portal_controller.list_user_portals()
... if err:
...     print(f"Error listing user portals: {err}")
...     return
... print(f"Total user portals found: {len(portal_list)}")
... for portal in portal_list:
...     print(portal.as_dict())

Fetch user portals with query_params filters >>> portal_list, _, err = client.zpa.user_portal_controller.list_user_portals( … query_params={‘search’: ‘UserPortal01’, ‘page’: ‘1’, ‘page_size’: ‘100’}) … if err: … print(f”Error listing user portals: {err}”) … return … print(f”Total user portals found: {len(portal_list)}”) … for portal in portal_list: … print(portal.as_dict())

update_user_portal(portal_id, **kwargs)

Updates the specified user portal.

Parameters:

portal_id (str) – The unique identifier for the user portal being updated.

Returns:

UserPortalController: The updated user portal object.

Return type:

Tuple

Example

Updating a user portal for a specific microtenant

>>> updated_portal, _, err = client.zpa.user_portal_controller.update_user_portal(
...     portal_id='25456654',
...     name=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     description=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     enabled=True,
...     user_notification=f"Portal01_Dev_{random.randint(1000, 10000)}",
...     user_notification_enabled=True,
...     managed_by_zs=True,
...     ext_label='portal01',
...     ext_domain='acme.com'
...     ext_domain_name='-acme.com.b.zscalerportal.net'
... )
>>> if err:
...     print(f"Error updating user portal: {err}")
...     return
... print(f"User portal updated successfully: {updated_portal.as_dict()}")