provisioning

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

Methods are accessible via zpa.provisioning

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 ProvisioningKeyAPI

Bases: APIClient

A client object for the Provisioning Keys resource.

add_provisioning_key(key_type, **kwargs)

Adds a new provisioning key to ZPA.

Parameters:
  • key_type (str) – The type of provisioning key, accepted values are: connector and service_edge.

  • name (str) – The name of the provisioning key.

  • max_usage (int) – The maximum amount of times this key can be used.

  • enrollment_cert_id (str) – The unique id of the enrollment certificate for this provisioning key.

  • component_id (str) – The unique id of the component linked to this provisioning key.

  • microtenant_id (str, optional) – The microtenant ID if applicable.

  • **kwargs – Additional optional attributes.

Returns:

The newly created Provisioning Key resource record.

Return type:

Tuple

Examples

>>> new_prov_key, _, err = zpa.provisioning.add_provisioning_key(
...     key_type=key_type,
...     name=f"NewProvisioningKey_{random.randint(1000, 10000)}",
...     description=f"NewProvisioningKey_{random.randint(1000, 10000)}",
...     max_usage="10",
...     enrollment_cert_id="2519",
...     component_id="72058304855047746",
... )
... if err:
...     print(f"Error creating provisioning key: {err}")
...     return
... print(f"provisioning key created successfully: {new_prov_key.as_dict()}")
delete_provisioning_key(key_id, key_type, microtenant_id=None)

Deletes the specified provisioning key from ZPA.

Parameters:
  • key_id (str) – The unique id of the provisioning key that will be deleted.

  • key_type (str) –

    The type of provisioning key, accepted values are:

    connector and service_edge.

  • **kwargs – Optional keyword args.

Keyword Arguments:

microtenant_id (str) – The microtenant ID to be used for this request.

Returns:

The status code for the operation.

Return type:

int

Examples

Delete a Service Edge provisioning key:

>>> _, _, err = client.zpa.provisioning.delete_provisioning_key(
... key_id='9999', key_type='connector')
... if err:
...     print(f"Error deleting provisioning key: {err}")
...     return
... print(f"provisioning key with ID {updated_key.id} deleted successfully.")

Examples

Delete a Service Edge provisioning key:

>>> _, _, err = client.zpa.provisioning.delete_provisioning_key(
... key_id='9999', key_type='service_edge')
... if err:
...     print(f"Error deleting provisioning key: {err}")
...     return
... print(f"provisioning key with ID {updated_key.id} deleted successfully.")
get_provisioning_key(key_id, key_type, query_params=None)

Returns information on the specified provisioning key.

Parameters:
  • key_id (str) – The unique id of the provisioning key.

  • key_type (str) – The type of provisioning key, accepted values are: connector and service_edge.

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

Returns:

The requested provisioning key resource record.

Return type:

Tuple

Examples

Get the specified App Connector key.

Examples

>>> fetched_key, _, err = client.zpa.provisioning.get_provisioning_key(
    key_id='9999', key_type=connector
... if err:
...     print(f"Error fetching provisioning key by ID: {err}")
...     return
... print(f"Fetched provisioning key by ID: {fetched_key.as_dict()}")

Get the specified Service Edge key.

>>> fetched_key, _, err = client.zpa.provisioning.get_provisioning_key(
    key_id='9999', key_type=service_edge
... if err:
...     print(f"Error fetching provisioning key by ID: {err}")
...     return
... print(f"Fetched provisioning key by ID: {fetched_key.as_dict()}")
get_provisioning_key_by_zcomponent(zcomponent_id, key_type, query_params=None)

Returns information on the specified provisioning key by App Connector or Service Edge ID.

Parameters:
  • key_type (str) – The type of provisioning key, accepted values are: connector and service_edge.

  • zcomponent_id (str) – The unique id of the App Connector or Service Edge.

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

Returns:

The requested provisioning key resource record.

Return type:

Tuple

Examples

Get the specified App Connector or Service Edge provisioning key.

Examples

>>> fetched_key, _, err = client.zpa.provisioning.get_provisioning_key(
    zcomponent_id='9999',
    key_type=connector
... if err:
...     print(f"Error fetching provisioning key by App Connector or Service Edge ID: {err}")
...     return
... print(
...     f"Fetched provisioning key by App Connector or Service Edge "
...     f"provisioning key ID: {fetched_key.as_dict()}"
... )

Get the specified Service Edge provisioning key:

>>> fetched_key, _, err = (
...     client.zpa.provisioning.get_provisioning_key_by_zcomponent(
    zcomponent_id='9999',
    key_type=service_edge
... if err:
...     print(f"Error fetching provisioning key by App Connector or Service Edge ID: {err}")
...     return
... print(f"Fetched provisioning key by App Connector or Service Edge ID: {fetched_key.as_dict()}")
list_provisioning_keys(key_type, query_params=None)

Returns a list of all configured provisioning keys that match the specified key_type.

Parameters:
  • key_type (str) – The type of provisioning key. Accepted values are: connector and service_edge.

  • {dict} (query_params) –

    Map of query parameters for the request.

    [query_params.page] {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}: ID of the microtenant, if applicable.

Returns:

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

Return type:

tuple

Examples

List all App Connector Groups provisioning keys:

>>> key_list, _, err = client.zpa.provisioning.list_provisioning_keys(
... key_type=connector
... query_params={'search': 'Connector_ProvKey01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing provisioning key: {err}")
...     return
... print(f"Total provisioning key found: {len(key_list)}")
... for key in key_list:
...     print(keys.as_dict())

List all Service Edge Groups provisioning keys:

>>> key_list, _, err = client.zpa.provisioning.list_provisioning_keys(
... key_type=service_edge
... query_params={'search': 'ServiceEdge_ProvKey01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing provisioning key: {err}")
...     return
... print(f"Total provisioning key found: {len(key_list)}")
... for key in key_list:
...     print(keys.as_dict())
update_provisioning_key(key_id, key_type, **kwargs)

Updates the specified provisioning key.

Parameters:
  • key_id (str) – The unique id of the Provisioning Key being updated.

  • key_type (str) – The type of provisioning key, accepted values are: connector and service_edge.

Keyword Arguments:
  • name (str, optional) – The new name for the provisioning key.

  • max_usage (int, optional) – The new maximum usage count.

  • enrollment_cert_id (str, optional) – The enrollment certificate ID to associate.

  • component_id (str, optional) – The component ID to associate (mapped to zcomponentId).

  • microtenant_id (str, optional) – The microtenant ID.

Returns:

The updated Provisioning Key resource record.

Return type:

Tuple

Examples

Updated Provisioning Key max_usage to 20 >>> update_prov_key, _, err = zpa.provisioning.add_provisioning_key( … key_type=key_type, … name=f”NewProvisioningKey_{random.randint(1000, 10000)}”, … description=f”NewProvisioningKey_{random.randint(1000, 10000)}”, … max_usage=”20”, … enrollment_cert_id=”2519”, … component_id=”72058304855047746”, … ) … if err: … print(f”Error creating provisioning key: {err}”) … return … print(f”provisioning key created successfully: {new_prov_key.as_dict()}”)

simplify_key_type(key_type)

Simplifies the key type for the user. Accepted values are ‘connector’ and ‘service_edge’.

Parameters:

key_type (str) – The key type provided by the user.

Returns:

The simplified key type.

Return type:

str