Link Search Menu Expand Document
  1. Zscaler ZPA Server Groups API
    1. Overview
    2. References
    3. Class Methods
    4. Adding a ZPA Server Group
    5. Deleting a ZPA Server Group
    6. Getting information on a ZPA Server Group
    7. Listing all ZPA Server Groups
    8. Updating a ZPA Server Group

Zscaler ZPA Server Groups API

Overview

Server Groups are used within ZPA to define a group of servers that host one or more applications. Application Segments are assigned to Server Groups.

References

Class Methods

The pyZscaler Server Groups Class can be accessed via zpa.server_groups.

The following methods are supported by pyZscaler for ZPA Server Groups:

Adding a ZPA Server Group

This section details how you can add a Server Group in ZPA using pyZscaler.

Class Methods used

  • add_group()

Prerequisites

You must have one or more app_connector_group_ids that you want to attach to the Server Group.

Example

Add a ZPA Server Group with a name of DC1 - Management Zone and associate an App Connector with an id of 2345324.

from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    
    # Add a server group called 'DC1 - Management Zone'
    zpa.server_groups.add_group('DC1 - Management Zone',
                                app_connector_ids=['2345324'])

Detailed Example

Add a ZPA Server group with the following configuration:

  • Name is Corporate HQ App Servers
  • App Connector IDs are 234721 and 234722
  • Application IDs are 926196382959075422 and 926196382959075423
  • Server IDs are 916196382959075424 and 916196382959075425
  • Description is Servers in Corporate HQ Office
  • IP Anchoring is enabled.
from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    zpa.server_groups.add_group('Corporate HQ App Servers',
                                app_connector_ids=['234721', '234722'],
                                application_ids=['926196382959075422', '926196382959075423'],
                                server_ids=['916196382959075424', '916196382959075425'],
                                description='Servers in Corporate HQ Office',
                                ip_anchored=True)

Deleting a ZPA Server Group

This section details how you can delete a Server Group in ZPA using pyZscaler.

Class Methods used

  • delete_group()

Prerequisites

You’ll need the id of the Server Group you want to delete.

Example

Delete a Server Group with an id of 916196382959075361.

from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    zpa.server_groups.delete_group('916196382959075361')

Getting information on a ZPA Server Group

This section details how you can get information on a Server Group in ZPA using pyZscaler.

Class Methods used

  • get_group()

Prerequisites

You’ll need the id of the Server Group that you want to get information on.

Example

Get information on the Server Group with an id of 916196382959075362.

from pprint import pprint
from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    # Print all information for the server group
    pprint(zpa.server_groups.get_group('916196382959075361'))
    
    # Print the server IDs for the server group
    for server in zpa.server_groups.get_group('916196382959075361').server_ids:
        print(server)

Listing all ZPA Server Groups

This section details how you can list all Server Groups in ZPA using pyZscaler.

Class Methods used

  • list_groups()

Example

Iterate through the list of all Server Groups and print each Server Group.

from pprint import pprint
from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    for group in zpa.server_groups.list_groups():
        pprint(group)

Updating a ZPA Server Group

This section details how you can update a Server Group in ZPA using pyZscaler.

Class Methods used

  • update_group()

Prerequisites

You’ll need the id of the Server Group that you want to update.

Example

Update the name and description of a Server Group, enabling Dynamic Discovery.

from pyzscaler.zpa import ZPA

with ZPA() as zpa:
    zpa.server_groups.update_group('916196382959075361',
                                   name='DC_Management_NICs',
                                   description='Management NICs for servers in DC',
                                   dynamic_discovery=True)