traffic_extranet

The following methods allow for interaction with the ZIA Traffic Extranet API endpoints.

Methods are accessible via zia.traffic_extranet

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 TrafficExtranetAPI

Bases: APIClient

A Client object for the Extranet resource.

add_extranet(**kwargs)

Adds a new extranet for the organization.

Parameters:
  • name (str) – The name of the extranet

  • description (str) – The description of the extranet

  • description – The description of the extranet

Returns:

A tuple containing the newly added Extranet, response, and error.

Return type:

tuple

Examples

Add a new Extranet

>>> added_extranet, _, error = client.zia.traffic_extranet.add_extranet(
...     name=f"NewExtranet {random.randint(1000, 10000)}",
...     description=f"NewExtranet {random.randint(1000, 10000)}",
...     extranet_dns_list=[
...         {
...             "name": f"NewExtranet {random.randint(1000, 10000)}",
...             "primary_dns_server": "8.8.8.8",
...             "secondary_dns_server": "4.4.2.2",
...             "use_as_default": True,
...         }
...     ],
...     extranet_ip_pool_list=[
...         {
...             "name": f"NewExtranet {random.randint(1000, 10000)}",
...             "ip_start": "192.168.200.1",
...             "ip_end": "192.168.200.21",
...             "use_as_default": True,
...         }
...     ]
... )
>>> if error:
...     print(f"Error adding extranet: {error}")
...     return
... print(f"Extranet added successfully: {added_extranet.as_dict()}")
delete_extranet(extranet_id)

Deletes the specified Extranet.

Parameters:

extranet_id (str) – The unique identifier of the Extranet.

Returns:

A tuple containing the response object and error (if any).

Return type:

tuple

Examples

Delete a Extranet:

>>> _, _, error = client.zia.traffic_extranet.delete_extranet('73459')
>>> if error:
...     print(f"Error deleting Extranet: {error}")
...     return
... print(f"Extranet with ID {'73459' deleted successfully.")
get_extranet(extranet_id)

Fetches a specific extranet by ID.

Parameters:

extranet_id (int) – The unique identifier for the extranet.

Returns:

A tuple containing (Extranet instance, Response, error).

Return type:

tuple

Examples

Retrieve a specific extranet:

>>> fetched_extranet, _, error = client.zia.traffic_extranet.get_extranet('125245')
>>> if error:
...     print(f"Error fetching Extranet by ID: {error}")
...     return
... print(f"Fetched Extranet by ID: {fetched_extranet.as_dict()}")
list_extranets(query_params=None)

Lists extranet in your organization with pagination. A subset of extranet 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_size] {int}: Page size for pagination. [query_params.search] {str}: Search string for filtering results. [query_params.order_by] {str}: The field used to sort the list in a specific order [query_params.order] {str}: The arrangement of the list in ascending or descending order i.e ASC

Returns:

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

Return type:

tuple

Examples

List all extranets:

>>> extranet_list, _, error = client.zia.traffic_extranet.list_extranets()
>>> if error:
...     print(f"Error listing extranets: {error}")
...     return
... print(f"Total extranets found: {len(extranet_list)}")
... for extranet in extranet_list:
...     print(extranet.as_dict())
update_extranet(extranet_id, **kwargs)

Updates information for the specified ZIA Extranet.

Parameters:

extranet_id (int) – The unique ID for the Extranet.

Returns:

A tuple containing the updated Extranet, response, and error.

Return type:

tuple

Examples

Updated a Extranet

>>> updated_extranet, _, error = client.zia.traffic_extranet.add_extranet(
...     extranet_id='125245'
...     name=f"UpdateExtranet_{random.randint(1000, 10000)}",
...     description=f"UpdateExtranet_{random.randint(1000, 10000)}",
...     extranet_dns_list=[
...         {
...             "name": f"UpdateExtranet_{random.randint(1000, 10000)}",
...             "primary_dns_server": "8.8.8.8",
...             "secondary_dns_server": "4.4.2.2",
...             "use_as_default": True,
...         }
...     ],
...     extranet_ip_pool_list=[
...         {
...             "name": f"UpdateExtranet_{random.randint(1000, 10000)}",
...             "ip_start": "192.168.200.1",
...             "ip_end": "192.168.200.21",
...             "use_as_default": True,
...         }
...     ]
... )
>>> if error:
...     print(f"Error updating extranet: {error}")
...     return
... print(f"Extranet updated successfully: {updated_extranet.as_dict()}")