certificates

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

Methods are accessible via zpa.certificates

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 CertificatesAPI

Bases: APIClient

A Client object for the Certificates resource.

add_certificate(**kwargs)

Adds a new certificate.

Parameters:

certificate_data (dict) – Data for the certificate to be added.

Returns:

The newly created certificate object.

Return type:

Tuple

Examples

Creating a Cloud browser isolation with the minimum required parameters:

>>> added_certificate, _, err = client.zpa.certificates.add_certificate(
...   name='new_certificate',
...   pem=("-----BEGIN CERTIFICATE-----\n"
...              "nMIIF2DCCA8CgAwIBAgIBATANBgkqhkiG==\n"
...              "-----END CERTIFICATE-----"),
... )
... if err:
...     print(f"Error adding ba certificate: {err}")
...     return
... print(f"BA Certificate added successfully: {added_certificate.as_dict()}")
delete_certificate(certificate_id, microtenant_id=None)

Deletes a certificate by its ID.

Parameters:

certificate_id (str) – The ID of the certificate to delete.

Returns:

The response object for the delete operation.

Return type:

Response

Examples

>>> _, _, err = client.zpa.certificates.delete_certificate(
...     certificate_id='999999'
... )
... if err:
...     print(f"Error deleting ba certificate: {err}")
...     return
... print(f"BA Certificate with ID {'999999'} deleted successfully.")
get_certificate(certificate_id, query_params=None)

Fetches a specific certificate by ID.

Parameters:
  • group_id (str) – The unique identifier for the connector group.

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

Returns:

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

Return type:

tuple

Examples

>>> fetched_cert, _, err = client.zpa.certificates.get_certificate('999999')
... if err:
...     print(f"Error fetching certificate by ID: {err}")
...     return
... print(fetched_cert.id)
list_certificates(query_params=None)

Fetches a list of all certificates with pagination support.

Keyword Arguments:

{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}: Search string for filtering results. [query_params.microtenant_id] {str}: The unique identifier of the microtenant of ZPA tenant.

Returns:

A list of Certificate instances.

Return type:

list

Examples

Retrieve browser certificates with pagination parameters:

>>> cert_list, _, err = client.zpa.certificates.list_certificates(
... query_params={'search': 'certificate01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing certificates: {err}")
...     return
... print(f"Total certificates found: {len(cert_list)}")
... for cert in cert_list:
...     print(cert.as_dict())
list_issued_certificates(query_params=None)

Fetches a list of all issued certificates with pagination support.

Parameters:

{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}: Search string for filtering results. [query_params.microtenant_id] {str}: The unique identifier of the microtenant of ZPA tenant.

Returns:

A list of IssuedCertificate instances.

Return type:

list

Examples

Retrieve browser certificates with pagination parameters:

>>> cert_list, _, err = client.zpa.certificates.list_issued_certificates(
... query_params={'search': 'certificate01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing certificates: {err}")
...     return
... print(f"Total certificates found: {len(cert_list)}")
... for cert in cert_list:
...     print(cert.as_dict())
update_certificate(certificate_id, **kwargs)

Updates a specific certificate.

Parameters:
  • certificate_id (str) – The ID of the certificate to update.

  • certificate_data (dict) – The new data for the certificate.

Returns:

The updated certificate object.

Return type:

Tuple

Examples

Creating a Cloud browser isolation with the minimum required parameters:

>>> updated_certificate, _, err = client.zpa.certificates.update_certificate(
...   name='new_certificate',
...   pem=("-----BEGIN CERTIFICATE-----\n"
...              "nMIIF2DCCA8CgAwIBAgIBATANBgkqhkiG==\n"
...              "-----END CERTIFICATE-----"),
... )
... if err:
...     print(f"Error adding ba certificate: {err}")
...     return
... print(f"BA Certificate added successfully: {updated_certificate.as_dict()}")