site

The following methods allow for interaction with the ZTB Site API endpoints. Includes site CRUD, app segments, cloud site creation, hostname config, site names, overview, static IP mapping, and template management.

Methods are accessible via ztb.site

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 SiteAPI

Bases: APIClient

Client for the ZTB Site resource.

Provides CRUD and utility operations for sites in the Zero Trust Branch API. Endpoints under /api/v2/Site/.

create_cloud_site(body=None, **kwargs)

Create a cloud gateway site.

Parameters:
  • body (CloudSiteCreateBody, optional) – Create payload.

  • **kwargs – Override body fields.

Returns:

(response data or None, Response, error).

Return type:

tuple

create_site(**kwargs)

Create a new site.

Parameters:

**kwargs – Site fields (e.g. name, display_name, deployment_type, etc).

Returns:

(created Site or None, Response, error).

Return type:

tuple

delete_site(site_id)

Delete a site.

Parameters:

site_id (str) – The site ID.

Returns:

(None, Response, error).

Return type:

tuple

get_hostname_config(gateway_ipaddress, site_name, query_params=None)

Get hostname config.

Parameters:
  • gateway_ipaddress (str) – Gateway IP address.

  • site_name (str) – Site name.

  • query_params (dict, optional) – Additional query params.

Returns:

(HostnameConfig instance, Response, error).

Return type:

tuple

get_md5()

Get Gateway MD5.

Returns:

(result string, Response, error).

Return type:

tuple

get_site_by_id(site_id)

Get site by ID.

Parameters:

site_id (str) – The site ID.

Returns:

(Site instance, Response, error).

Return type:

tuple

get_site_by_name(name)

Get site by name.

Parameters:

name (str) – The site name.

Returns:

(Site instance, Response, error).

Return type:

tuple

get_site_overview(site_id)

Get site overview data.

Parameters:

site_id (str) – The site ID.

Returns:

(SiteOverview instance, Response, error).

Return type:

tuple

list_app_segments(query_params=None)

Get list of ZPA app segments with pagination.

Parameters:

query_params (dict, optional) – page, limit, search.

Returns:

(list of AppSegment, Response, error).

Client-side filtering with JMESPath:

The response object supports client-side filtering and projection via resp.search(expression). See the JMESPath documentation for expression syntax.

Return type:

tuple

list_site_names(query_params=None)

Get all site names.

Parameters:

query_params (dict, optional) – siteId, gatewayType, full.

Returns:

(list of SiteNameItem, Response, error).

Client-side filtering with JMESPath:

The response object supports client-side filtering and projection via resp.search(expression). See the JMESPath documentation for expression syntax.

Return type:

tuple

list_sites(query_params=None)

Get list of sites with pagination and search.

Parameters:

query_params (dict, optional) – Map of query parameters. [query_params.search] (str): Search filter. [query_params.page] (int): Page number. [query_params.limit] (int): Page size. [query_params.sort] (str): Sort field. [query_params.sortdir] (str): asc or desc. [query_params.siteId] (str): Site ID filter. [query_params.gatewayType] (str): Gateway type filter.

Returns:

(list of Site instances, Response, error).

Return type:

tuple

Examples

>>> sites, _, err = client.ztb.site.list_sites()
>>> sites, _, err = client.ztb.site.list_sites(
...     query_params={"search": "prod", "page": 1, "limit": 25}
... )

Client-side filtering with JMESPath:

The response object supports client-side filtering and projection via resp.search(expression). See the JMESPath documentation for expression syntax.

update_app_segments(site_id)

Update ZPA app segments for a site.

Parameters:

site_id (str) – The site ID.

Returns:

(None, Response, error).

Return type:

tuple

update_site(site_id, body=None, **kwargs)

Update a site.

Parameters:
  • site_id (str) – The site ID.

  • body (SiteUpdateBody, optional) – Update payload.

  • **kwargs – Override body fields.

Returns:

(None or updated Site, Response, error).

Return type:

tuple

update_site_template(site_id, template_id)

Change template for a site.

Parameters:
  • site_id (str) – The site ID.

  • template_id (str) – The template ID.

Returns:

(None, Response, error).

Return type:

tuple

update_static_ips_mapping(site_id, enabled)

Update app segment static IP mapping for a site.

Parameters:
  • site_id (str) – The site ID.

  • enabled (bool) – Whether to enable static IP mapping.

Returns:

(None, Response, error).

Return type:

tuple