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: APIClient

A client object for the Segment Groups resource.

add_group(**kwargs)

Adds a new segment group.

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

  • description (str) – The description of the segment group.

  • enabled (bool) – Enable the segment group. Defaults to True.

Returns:

SegmentGroup: The created segment group object.

Return type:

Tuple

Example

# Basic example: Add a new segment group >>> added_group, _, err = client.zpa.segment_groups.add_group( … name=”Example Group”, … description=”This is an example segment group.”, … enabled=True … )

# Adding a new segment group for a specific microtenant >>> added_group, _, err = zpa.segment_groups.add_group( … name=”Example Group”, … description=”Segment group for microtenant”, … enabled=True, … microtenant_id=”216196257331380392” … )

delete_group(group_id, microtenant_id=None)

Deletes the specified segment group.

Parameters:

group_id (str) – The unique identifier for the segment group to be deleted.

Returns:

Status code of the delete operation.

Return type:

int

Example

# Delete a segment group by ID >>> _, _, err = client.zpa.segment_groups.delete_group(updated_group_v2.id) … if err: … print(f”Error deleting group: {err}”) … return … print(f”Group with ID {updated_group_v2.id} deleted successfully.”)

get_group(group_id, query_params=None)

Gets information on the specified segment group.

Parameters:
  • group_id (str) – The unique identifier of the segment group.

  • query_params (dict, optional) – Map of query parameters for the request. [query_params.microtenant_id] {str}: The microtenant ID, if applicable.

Returns:

SegmentGroup: The corresponding segment group object.

Return type:

Tuple

Example

Retrieve details of a specific segment group

>>> fetched_group, _, err = client.zpa.segment_groups.get_group('999999')
... if err:
...     print(f"Error fetching segment group by ID: {err}")
...     return
... print(f"Fetched segment group by ID: {fetched_group.as_dict()}")
list_groups(query_params=None)

Enumerates segment groups in your organization with pagination. A subset of segment groups 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] {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:

Tuple

Example

Fetch all segment groups without filtering

>>> group_list, _, err = client.zpa.segment_groups.list_groups()
... if err:
...     print(f"Error listing segment groups: {err}")
...     return
... print(f"Total segment groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())

Fetch segment groups with query_params filters >>> group_list, _, err = client.zpa.segment_groups.list_groups( … query_params={‘search’: ‘Group01’, ‘page’: ‘1’, ‘page_size’: ‘100’}) … if err: … print(f”Error listing segment groups: {err}”) … return … print(f”Total segment groups found: {len(group_list)}”) … for group in group_list: … print(group.as_dict())

update_group(group_id, **kwargs)

Updates the specified segment group.

Parameters:

group_id (str) – The unique identifier for the segment group being updated.

Returns:

SegmentGroup: The updated segment group object.

Return type:

Tuple

Example

# Basic example: Update an existing segment group >>> group_id = “216196257331370181” >>> updated_group, _, err = zpa.segment_groups.update_group( … group_id, … name=”Updated Group Name”, … description=”Updated description for the segment group”, … enabled=False … )

# Updating a segment group for a specific microtenant >>> group_id = “216196257331370181” >>> updated_group, _, err = zpa.segment_groups.update_group( … group_id, … name=”Tenant-Specific Group Update”, … description=”Updated segment group for microtenant”, … enabled=True, … microtenant_id=”216196257331380392” … )

update_group_v2(group_id, **kwargs)

Updates the specified segment group.

Parameters:

group_id (str) – The unique identifier for the segment group being updated.

Returns:

SegmentGroup: The updated segment group object.

Return type:

Tuple

Example

# Basic example: Update an existing segment group >>> group_id = “216196257331370181” >>> updated_group, response, err = zpa.segment_groups.update_group_v2( … group_id, … name=”Updated Group Name”, … description=”Updated description for the segment group”, … enabled=False … )

# Updating a segment group for a specific microtenant >>> group_id = “216196257331370181” >>> updated_group, response, err = zpa.segment_groups.update_group_v2( … group_id, … name=”Tenant-Specific Group Update”, … description=”Updated segment group for microtenant”, … enabled=True, … microtenant_id=”216196257331380392” … )