tag_handling

The following methods allow for interaction with the ZCell Tag Handling API endpoints. Includes listing and creating tags for a customer.

Methods are accessible via zcell.tag_handling

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 TagHandlingAPI

Bases: APIClient

create_tag(id=None, **kwargs)

Creates a new tag entry.

Parameters:
  • id (str) – Optional. The ZCell customer ID. Defaults to the zcellCustomerId config value or the ZCELL_CUSTOMER_ID environment variable when omitted.

  • **kwargs

    Request body fields.

    name (str): The name of the tag to create.

Returns:

(result, Response, error)

Return type:

tuple

Examples

Create a new tag:

>>> customer_id = 'gi754cvqb07r0'
>>> created_name = f"TagHandling01_{random.randint(1000, 10000)}"
>>> added_policy, _, error = client.zcell.tag_handling.create_tag(
...     id=customer_id,
...     name=created_name,
... )
>>> if error:
...     print(f"Error adding tag: {error}")
...     return
>>> print(f"Tag added successfully: {added_policy.as_dict()}")
list_tag(id=None, query_params=None)

Gets all tags for given customer.

Parameters:
  • id (str) – Optional. The ZCell customer ID. Defaults to the zcellCustomerId config value or the ZCELL_CUSTOMER_ID environment variable when omitted.

  • query_params (dict) – Map of query parameters for the request. [query_params.name] {str} [query_params.page] {int}: Page number (0-based) [query_params.size] {int}: Page size (1-100) [query_params.sort_by] {str}: Field to sort by. Default: name. Sortable fields: id, name [query_params.sort_dir] {str}: ASC or DESC. Default: ASC

Returns:

(result, Response, error)

Return type:

tuple

The returned response supports resp.search(<jmespath>) for client-side filtering/projection of the current page.

Examples

List all tags for a customer:

>>> fetched_status, _, error = client.zcell.tag_handling.list_tag(
...     id='gi754cvqb07r0',
... )
>>> if error:
...     print(f"Error listing tags: {error}")
...     return
>>> print(f"Total tags found: {len(fetched_status)}")
>>> for tag in fetched_status:
...     print(tag.as_dict())