segment_groups¶
The following methods allow for interaction with the ZPA Segment Groups API endpoints.
Methods are accessible via zpa.segment_groups
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 SegmentGroupsAPI¶
Bases:
APIClientA Client object for the Segment Groups resource.
- add_group(**kwargs)¶
Creates a new segment group.
- Parameters:
name (str) – The name of the segment group.
**kwargs – Optional keyword args.
- Keyword Arguments:
description (str) – Additional information about the segment group.
enabled (bool) – Indicates whether the segment group is enabled.
policy_migrated (str) – The policy migrated for this segment group.
config_space (str) – The config space for this segment group.
tcp_keep_alive_enabled (str) – The tcp keep alive enabled for this segment group.
microtenant_name (str) – The microtenant name for this segment group.
skip_detailed_app_info (str) – The skip detailed app info for this segment group.
applications (str) – The applications for this segment group.
microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.
- Returns:
A tuple containing the newly added SegmentGroup instance, response, and error.
- Return type:
Examples
Add a new segment group:
>>> added_group, _, error = client.zpa.segment_groups.add_group( ... name=f"NewGroup_{random.randint(1000, 10000)}", ... description=f"NewGroup_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error adding segment group: {error}") ... return ... print(f"Segment group added successfully: {added_group.as_dict()}")
- delete_group(group_id, microtenant_id=None)¶
Deletes the specified segment group.
- Parameters:
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete a segment group:
>>> _, _, error = client.zpa.segment_groups.delete_group('216196257331370181') >>> if error: ... print(f"Error deleting segment group: {error}") ... return ... print(f"Segment group deleted successfully.")
- get_group(group_id, query_params=None)¶
Fetches a specific segment group by ID.
- Parameters:
- Returns:
A tuple containing (SegmentGroup instance, Response, error).
- Return type:
Examples
Print a specific segment group:
>>> fetched_group, _, error = client.zpa.segment_groups.get_group('216196257331370181') >>> if error: ... print(f"Error fetching segment group by ID: {error}") ... return ... print(f"Fetched segment group by ID: {fetched_group.as_dict()}")
- list_groups(query_params=None)¶
Lists the segment groups configured in your organization.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
[query_params.page]{str}: Specifies the page number.[query_params.page_size]{int}: Page size for pagination.[query_params.search]{str}: Search string for filtering results.[query_params.microtenant_id]{str}: ID of the microtenant, if applicable.- Returns:
A tuple containing (list of SegmentGroup instances, Response, error)
- Return type:
Examples
List segment groups:
>>> group_list, _, error = client.zpa.segment_groups.list_groups() >>> if error: ... print(f"Error listing segment groups: {error}") ... return ... print(f"Total segment groups found: {len(group_list)}") ... for group in group_list: ... print(group.as_dict())
List segment groups using filters:
>>> group_list, _, error = client.zpa.segment_groups.list_groups( ... query_params={'page': 'VALUE'}) >>> if error: ... print(f"Error listing segment groups: {error}") ... return ... print(f"Total segment groups found: {len(group_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_group(group_id, **kwargs)¶
Updates information for the specified segment group.
- Parameters:
group_id (str) – The unique identifier for the segment group.
- Keyword Arguments:
name (str) – The name of the segment group.
description (str) – Additional information about the segment group.
enabled (bool) – Indicates whether the segment group is enabled.
policy_migrated (str) – The policy migrated for this segment group.
config_space (str) – The config space for this segment group.
tcp_keep_alive_enabled (str) – The tcp keep alive enabled for this segment group.
microtenant_name (str) – The microtenant name for this segment group.
skip_detailed_app_info (str) – The skip detailed app info for this segment group.
applications (str) – The applications for this segment group.
microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.
- Returns:
A tuple containing the updated SegmentGroup instance, response, and error.
- Return type:
Examples
Update an existing segment group:
>>> updated_group, _, error = client.zpa.segment_groups.update_group( ... group_id='216196257331370181', ... name=f"UpdatedGroup_{random.randint(1000, 10000)}", ... description=f"UpdatedGroup_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error updating segment group: {error}") ... return ... print(f"Segment group updated successfully: {updated_group.as_dict()}")
- update_group_v2(group_id, **kwargs)¶
Updates the specified segment group (v2 endpoint).
- Parameters:
group_id (str) – The unique identifier for the segment group.
- Keyword Arguments:
name (str) – The name of the segment group.
description (str) – Additional information about the segment group.
enabled (bool) – Indicates whether the segment group is enabled.
policy_migrated (str) – The policy migrated for this segment group.
config_space (str) – The config space for this segment group.
tcp_keep_alive_enabled (str) – The tcp keep alive enabled for this segment group.
microtenant_name (str) – The microtenant name for this segment group.
skip_detailed_app_info (str) – The skip detailed app info for this segment group.
applications (str) – The applications for this segment group.
microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.
- Returns:
A tuple containing the updated SegmentGroup instance, response, and error.
- Return type:
Examples
Update an existing segment group:
>>> updated_group, _, error = client.zpa.segment_groups.update_group_v2( ... group_id='216196257331370181', ... name=f"UpdatedGroup_{random.randint(1000, 10000)}", ... description=f"UpdatedGroup_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error updating segment group: {error}") ... return ... print(f"Segment group updated successfully: {updated_group.as_dict()}")