tag_key

The following methods allow for interaction with the ZPA Tag Key API endpoints. Tag keys are scoped to a namespace and define keys (e.g., environment, team) that can have multiple values.

Methods are accessible via zpa.tag_key

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 TagKeyAPI

Bases: APIClient

A client object for the Tag Key resource (scoped to a namespace).

bulk_update_status(namespace_id, bulk_update, query_params=None)

Bulk update the enabled status of tag keys.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • bulk_update (BulkUpdateStatusRequest) – The bulk update request.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(None, Response, error).

Return type:

tuple

Examples

>>> update = BulkUpdateStatusRequest({"enabled": False, "tagKeyIds": ["k1", "k2"]})
>>> _, _, err = client.zpa.tag_key.bulk_update_status("ns-123", update)
>>> if err:
...     print(err)
create_tag_key(namespace_id, tag_key, query_params=None)

Create a tag key in a namespace.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • tag_key (TagKey) – The tag key object to create.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(TagKey, Response, error).

Return type:

tuple

Examples

>>> key = TagKey({"name": "env", "enabled": True, "tagValues": []})
>>> created, _, err = client.zpa.tag_key.create_tag_key("ns-123", key)
>>> if err:
...     print(err)
delete_tag_key(namespace_id, tag_key_id, query_params=None)

Delete a tag key.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • tag_key_id (str) – The unique identifier of the tag key.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(None, Response, error).

Return type:

tuple

Examples

>>> _, _, err = client.zpa.tag_key.delete_tag_key("ns-123", "key-456")
>>> if err:
...     print(err)
get_tag_key(namespace_id, tag_key_id, query_params=None)

Get a tag key by ID.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • tag_key_id (str) – The unique identifier of the tag key.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(TagKey, Response, error).

Return type:

tuple

Examples

>>> key, _, err = client.zpa.tag_key.get_tag_key("ns-123", "key-456")
>>> if err:
...     print(err)
>>> print(key.as_dict())
get_tag_key_by_name(namespace_id, tag_key_name, query_params=None)

Get a tag key by name (case-insensitive).

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • tag_key_name (str) – The name of the tag key.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(TagKey, Response, error).

Return type:

tuple

Examples

>>> key, _, err = client.zpa.tag_key.get_tag_key_by_name("ns-123", "environment")
>>> if err:
...     print(err)
>>> print(key.as_dict())
list_tag_keys(namespace_id, query_params=None)

Get all tag keys in a namespace.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(list of TagKey, Response, error).

Return type:

tuple

Examples

>>> keys, _, err = client.zpa.tag_key.list_tag_keys("namespace-123")
>>> if err:
...     print(err)
>>> for k in keys:
...     print(k.as_dict())
update_tag_key(namespace_id, tag_key_id, tag_key, query_params=None)

Update a tag key.

Parameters:
  • namespace_id (str) – The unique identifier of the namespace.

  • tag_key_id (str) – The unique identifier of the tag key.

  • tag_key (TagKey) – The tag key object with updated fields.

  • query_params (dict, optional) – Map of query parameters. [query_params.microtenant_id] (str): ID of the microtenant.

Returns:

(TagKey, Response, error).

Return type:

tuple

Examples

>>> key.name = "updated-name"
>>> updated, resp, err = client.zpa.tag_key.update_tag_key("ns-123", "key-456", key)
>>> if err:
...     print(err)