tag_group

The following methods allow for interaction with the ZPA Tag Group API endpoints. Tag groups combine tags (namespace + key + value) into reusable groups for assignment to resources.

Methods are accessible via zpa.tag_group

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 TagGroupAPI

Bases: APIClient

A client object for the Tag Group resource.

create_tag_group(tag_group, query_params=None)

Create a tag group.

Parameters:
  • tag_group (TagGroup) – The tag group object to create.

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

Returns:

(TagGroup, Response, error).

Return type:

tuple

Examples

>>> group = TagGroup({"name": "MyGroup", "tags": []})
>>> created, _, err = client.zpa.tag_group.create_tag_group(group)
>>> if err:
...     print(err)
delete_tag_group(tag_group_id, query_params=None)

Delete a tag group.

Parameters:
  • tag_group_id (str) – The unique identifier of the tag group.

  • 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_group.delete_tag_group("123")
>>> if err:
...     print(err)
get_tag_group(tag_group_id, query_params=None)

Get a tag group by ID.

Parameters:
  • tag_group_id (str) – The unique identifier of the tag group.

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

Returns:

(TagGroup, Response, error).

Return type:

tuple

Examples

>>> group, _, err = client.zpa.tag_group.get_tag_group("123456")
>>> if err:
...     print(err)
>>> print(group.as_dict())
get_tag_group_by_name(tag_group_name, query_params=None)

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

Parameters:
  • tag_group_name (str) – The name of the tag group.

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

Returns:

(TagGroup, Response, error).

Return type:

tuple

Examples

>>> group, _, err = client.zpa.tag_group.get_tag_group_by_name("MyGroup")
>>> if err:
...     print(err)
>>> print(group.as_dict())
list_tag_groups(query_params=None)

Get all tag groups.

Parameters:

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

Returns:

(list of TagGroup, Response, error).

Return type:

tuple

Examples

>>> groups, _, err = client.zpa.tag_group.list_tag_groups()
>>> if err:
...     print(err)
>>> for g in groups:
...     print(g.as_dict())

Client-side filtering with JMESPath:

The response object supports client-side filtering and projection via resp.search(expression). See the JMESPath documentation for expression syntax.

update_tag_group(tag_group_id, tag_group, query_params=None)

Update a tag group.

Parameters:
  • tag_group_id (str) – The unique identifier of the tag group.

  • tag_group (TagGroup) – The tag group object with updated fields.

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

Returns:

(TagGroup, Response, error).

Return type:

tuple

Examples

>>> group.name = "UpdatedName"
>>> updated, resp, err = client.zpa.tag_group.update_tag_group("123", group)
>>> if err:
...     print(err)