traffic_vpn_credentials

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

Methods are accessible via zia.traffic_vpn_credentials

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 TrafficVPNCredentialAPI

Bases: APIClient

A Client object for the Traffic Forwarding VPN Credentials resources.

add_vpn_credential(**kwargs)

Add new VPN credentials.

Parameters:

credential (dict) –

A dictionary representing the VPN credential to be created. It must include type (either IP or UFQDN) and pre_shared_key.

For example:

{
    "type": "UFQDN",
    "fqdn": "example@domain.com",
    "pre_shared_key": "my_key",
    "comments": "Optional comments",
    "location_id": 12345
}

Returns:

The newly created VPN credential resource record, accompanied by the response object and any error.

Return type:

tuple

Raises:

ValueError – If required arguments are not provided or invalid.

bulk_delete_vpn_credentials(credential_ids)

Bulk delete VPN credentials.

Parameters:

credential_ids (list) – List containing IDs of each vpn credential that will be deleted.

Returns:

Response code for operation.

Return type:

tuple

Examples

>>> zia.traffic.bulk_delete_vpn_credentials(['94963984', '97679232'])
delete_vpn_credential(credential_id)

Delete VPN credentials for the specified ID.

Parameters:

credential_id (str) – The unique identifier for the VPN credentials that will be deleted.

Returns:

Response code for the operation.

Return type:

tuple

Examples

>>> zia.traffic.delete_vpn_credential('97679391')
get_vpn_credential(credential_id)

Get VPN credentials for the specified ID or fqdn.

Parameters:
  • credential_id (str, optional) – The unique identifier for the VPN credentials.

  • fqdn (str, optional) – The unique FQDN for the VPN credentials.

Returns:

The resource record for the requested VPN credentials.

Return type:

tuple

Examples

>>> pprint(zia.traffic.get_vpn_credential('97679391'))
>>> pprint(zia.traffic.get_vpn_credential(fqdn='userid@fqdn'))
list_vpn_credentials(query_params=None)

Returns the list of all configured VPN credentials with optional filtering.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.page] {int}: Specifies the page offset. [query_params.page_size] {int}: Page size for pagination. [query_params.search] {str}: Search string for filtering results. [query_params.type] {str}: The type of VPN credential. Must be one of ‘CN’, ‘IP’, ‘UFQDN’, ‘XAUTH’.

[query_params.include_only_without_location] {bool}: Include VPN credential only

if not associated with any location.

[query_params.location_id] {int}: Gets the VPN credentials for the specified location ID. [query_params.managed_by] {int}: Gets the VPN credentials managed by the given partner.

Returns:

A tuple containing (list of VPN credentials instances, Response, error)

Return type:

tuple

Examples

List VPN credentials of type UFQDN:

>>> credentials_list, _, err = client.zia.traffic_vpn_credentials.list_vpn_credentials(
    query_params={"type": "UFQDN"})
... if err:
...     print(f"Error listing credentials: {err}")
...     return
... print(f"Total UFQDN credentials found: {len(credentials_list)}")
... for credential in credentials_list:
...     print(credential.as_dict())
update_vpn_credential(credential_id, **kwargs)

Update VPN credentials with the specified ID.

Parameters:
  • credential_id (int) – The unique identifier for the credential that will be updated.

  • credential (dict or VPNCredential object) – The data for the VPN credential that is being updated.

Returns:

The newly updated VPN credential resource record.

Return type:

tuple

Raises:

ValueError – If certain fields are invalid or attempted to be modified (i.e., type, fqdn, ipAddress).