Zscaler ZPA Segment Groups API
Overview
Segment Groups are used to configure policies for one or more Application Segments. Application Segments can only belong to a single Segment Group.
Creating a Segment Group is a prerequisite for adding an Application Segment.
References
- pyZscaler - Library Reference for Segment Groups
- Zscaler - ZPA Segment Groups API Reference
- Zscaler - ZPA Segment Groups Documentation
Class Methods
The pyZscaler Segment Groups Class can be accessed via zpa.segment_groups
.
The following methods are supported by pyZscaler for ZPA Segment Groups:
Adding a ZPA Segment Group
This section details how you can add a Segment Group via API in ZPA using pyZscaler.
Overview
If you don’t know which applications you want to associate with the Segment Group (or they haven’t been created yet), you may want to start with a basic config that only has a name. You can always customise the Segment Group later using the update_group()
method.
Class Methods used
add_group()
Prerequisites
The minimum params required to create a Segment Group in ZPA with the API are:
name
The Segment Group will be in the disabled state unless you pass enabled=True
upon creation.
Example
We can add a Segment Group with the absolute minimum required parameters as per below:
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
# Add a segment group called 'Management Apps' in the disabled state
zpa.segment_groups.add_group(name='Management Apps')
# Add a segment group called 'Web Apps' in the enabled state
zpa.segment_groups.add_group(name="Web Apps", enabled=True)
Detailed Example
In this example we’re going to add a Segment Group via API in ZPA with the following configuration:
- Name is Remote Access
- Segment Group is enabled
- Description is Remote Acccess Applications
- Application IDs to associate are 926196382959075422, 926196382959075423 and 926196382959075424.
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
# Add a segment group called 'Remote Access' and associate some applications
zpa.segment_groups.add_group(name='Remote Access',
enabled=True,
description='Remote Access Applications',
application_ids=[
'926196382959075422',
'926196382959075423',
'926196382959075424'])
Deleting a ZPA Segment Group
This section details how you can delete a Segment Group via API in ZPA using pyZscaler.
Class Methods used
delete_group()
Prerequisites
You’ll need the id
of the Segment Group that you want to delete.
Example
Delete a Segment Group with the id
45096653.
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
# Delete the segment group with id of 45096653
zpa.segment_groups.delete_group('45096653')
Getting information on a ZPA Segment Group
This section details how you can get information on a single Segment Group via API in ZPA using pyZscaler.
Class Methods used
get_group()
Prerequisites
You’ll need the id
of the Segment Group that you want information on.
Example
Get information for a Segment Group with an id
of 45096653.
from pprint import pprint
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
pprint(zpa.segment_groups.get_group('45096653'))
Listing all ZPA Segment Groups
This section details how you can list all Segment Groups via API in ZPA using pyZscaler.
Class Methods used
list_groups()
Example
Iterate through Segment Groups list and print each configured Segment Group.
from pprint import pprint
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
for group in zpa.segment_groups.list_groups():
pprint(group)
Updating a ZPA Segment Group
This section details how you can update a Segment Group via API in ZPA using pyZscaler.
Class Methods used
update_group()
Prerequisites
You’ll need the id
of the Segment Group that you want to update.
Example
Update the name of a Segment Group to Development Apps and enable it.
from pyzscaler.zpa import ZPA
with ZPA() as zpa:
zpa.segment_groups.update_group('45096653',
name='Development Apps',
enabled=True)