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 ZIA Rule Label.
- Parameters:
name (str) – The name of the label.
**kwargs – Optional keyword args.
- Keyword Arguments:
description (str) – Additional notes or information
- Returns:
A tuple containing the newly added Rule Label, 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 label: {error}") ... return ... print(f"Label added successfully: {added_label.as_dict()}")
- delete_label(label_id)¶
Deletes the specified Rule Label.
- Parameters:
label_id (str) – The unique identifier of 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('73459') >>> if error: ... print(f"Error deleting Rule Label: {error}") ... return ... print(f"Rule Label with ID {'73459' deleted successfully.")
- get_label(label_id)¶
Fetches a specific rule labels by ID.
- Parameters:
label_id (int) – The unique identifier for the rule label.
- Returns:
A tuple containing (Rule Label instance, Response, error).
- Return type:
Examples
Print a specific Rule Label
>>> fetched_label, _, error = client.zia.rule_labels.get_label( '1254654') >>> if error: ... print(f"Error fetching Rule Label by ID: {error}") ... return ... print(f"Fetched Rule Label by ID: {fetched_label.as_dict()}")
- list_labels(query_params=None)¶
Lists rule labels in your organization with pagination. A subset of rule labels can be returned that match a supported filter expression or query.
- 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 Rule Labels instances, Response, error)
- Return type:
Examples
List Rule Labels using default settings:
>>> label_list, _, error = client.zia.rule_labels.list_labels( query_params={'search': updated_label.name}) >>> if error: ... print(f"Error listing labels: {error}") ... return ... print(f"Total labels found: {len(label_list)}") ... for label in label_list: ... print(label.as_dict())
- update_label(label_id, **kwargs)¶
Updates information for the specified ZIA Rule Label.
- Parameters:
label_id (int) – The unique ID for the Rule Label.
- Returns:
A tuple containing the updated Rule Label, response, and error.
- Return type:
Examples
Update an existing Rule Label :
>>> updated_label, _, error = client.zia.rule_labels.add_label( label_id='1524566' ... name=f"UpdatedRuleLabel_{random.randint(1000, 10000)}", ... description=f"UpdatedRuleLabel_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error updating Rule Label: {error}") ... return ... print(f"Rule Label updated successfully: {updated_label.as_dict()}")