rule_labels¶
The following methods allow for interaction with the ZIA Rule Labels API endpoints.
Methods are accessible via zia.rule_labels
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 RuleLabelsAPI¶
Bases:
APIClientA Client object for the Rule Labels resource.
- add_label(**kwargs)¶
Creates a new rule label.
- Parameters:
name (str) – The name of the rule label.
**kwargs – Optional keyword args.
- Keyword Arguments:
- Returns:
A tuple containing the newly added RuleLabels instance, response, and error.
- Return type:
Examples
Add a new rule label:
>>> added_label, _, error = client.zia.rule_labels.add_label( ... name=f"NewLabel_{random.randint(1000, 10000)}", ... description=f"NewLabel_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error adding rule label: {error}") ... return ... print(f"Rule label added successfully: {added_label.as_dict()}")
- delete_label(label_id)¶
Deletes the specified rule label.
- Parameters:
label_id (int) – The unique identifier for the rule label.
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete a rule label:
>>> _, _, error = client.zia.rule_labels.delete_label(1013) >>> if error: ... print(f"Error deleting rule label: {error}") ... return ... print(f"Rule label deleted successfully.")
- get_label(label_id)¶
Fetches a specific rule label by ID.
- Parameters:
label_id (int) – The unique identifier for the rule label.
- Returns:
A tuple containing (RuleLabels instance, Response, error).
- Return type:
Examples
Print a specific rule label:
>>> fetched_label, _, error = client.zia.rule_labels.get_label(1013) >>> if error: ... print(f"Error fetching rule label by ID: {error}") ... return ... print(f"Fetched rule label by ID: {fetched_label.as_dict()}")
- get_rule_type_label(rule_type, query_params=None)¶
Retrieves a list of rule labels based on the specified rule type.
- Parameters:
rule_type (str) – The type of rule to retrieve labels for.
{dict} (query_params) – Map of query parameters for the request.
[query_params.page]{int}: Specifies the page offset.[query_params.page_size]{int}: Page size for pagination.[query_params.search]{str}: Search string for filtering results.
- Returns:
A tuple containing (list of RuleLabels instances, Response, error)
- Return type:
Examples
List rule labels:
>>> label_list, _, error = client.zia.rule_labels.get_rule_type_label('URL_FILTERING') >>> if error: ... print(f"Error listing rule labels: {error}") ... return ... print(f"Total rule labels found: {len(label_list)}") ... for label in label_list: ... print(label.as_dict())
List rule labels using filters:
>>> label_list, _, error = client.zia.rule_labels.get_rule_type_label( ... 'URL_FILTERING', query_params={'page': 'VALUE'}) >>> if error: ... print(f"Error listing rule labels: {error}") ... return ... print(f"Total rule labels found: {len(label_list)}")
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.
- list_labels(query_params=None)¶
Lists the rule labels configured in your organization.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
[query_params.page]{int}: Specifies the page offset.[query_params.page_size]{int}: Page size for pagination.[query_params.search]{str}: Search string for filtering results.- Returns:
A tuple containing (list of RuleLabels instances, Response, error)
- Return type:
Examples
List rule labels:
>>> label_list, _, error = client.zia.rule_labels.list_labels() >>> if error: ... print(f"Error listing rule labels: {error}") ... return ... print(f"Total rule labels found: {len(label_list)}") ... for label in label_list: ... print(label.as_dict())
List rule labels using filters:
>>> label_list, _, error = client.zia.rule_labels.list_labels( ... query_params={'page': 'VALUE'}) >>> if error: ... print(f"Error listing rule labels: {error}") ... return ... print(f"Total rule labels found: {len(label_list)}")
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_label(label_id, **kwargs)¶
Updates information for the specified rule label.
- Parameters:
label_id (int) – The unique identifier for the rule label.
- Keyword Arguments:
- Returns:
A tuple containing the updated RuleLabels instance, response, and error.
- Return type:
Examples
Update an existing rule label:
>>> updated_label, _, error = client.zia.rule_labels.update_label( ... label_id=1013, ... name=f"UpdatedLabel_{random.randint(1000, 10000)}", ... description=f"UpdatedLabel_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error updating rule label: {error}") ... return ... print(f"Rule label updated successfully: {updated_label.as_dict()}")