groups_router

The following methods allow for interaction with the ZTB Groups Router API endpoints.

Methods are accessible via ztb.groups_router

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 GroupsRouterAPI

Bases: APIClient

Client for the ZTB Groups Router resource.

Provides CRUD operations for groups router in the Zero Trust Branch API.

create_group(**kwargs)

Creates a new ZTB Group.

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

  • **kwargs – Optional keyword args.

Keyword Arguments:
  • display_name (str) – The display name for the group.

  • type (str) – The group type (e.g. device).

  • autonomous (bool) – Whether the group is autonomous.

  • owner (str) – The owner of the group.

  • member_attributes (dict) – Member attribute filters.

Returns:

A tuple containing the newly created Group, response, and error.

Return type:

tuple

Examples

Create a new Group:

>>> created_group, _, error = client.ztb.groups_router.create_group(
...     name="Group01",
...     display_name="Group01",
...     type="device",
...     autonomous=True,
...     owner="user",
... )
>>> if error:
...     print(f"Error creating group: {error}")
...     return
... print(f"Group created successfully: {created_group.as_dict()}")
delete_group(group_id)

Deletes the specified Group.

Parameters:

group_id (int) – The unique identifier of the Group.

Returns:

A tuple containing the response object and error (if any).

Return type:

tuple

Examples

Delete a Group:

>>> _, _, error = client.ztb.groups_router.delete_group('73459')
>>> if error:
...     print(f"Error deleting group: {error}")
...     return
... print(f"Group with ID 73459 deleted successfully.")
get_group(group_id)

Fetches a specific group by ID.

Parameters:

group_id (int) – The unique identifier for the group.

Returns:

A tuple containing (GroupsRouter instance, Response, error).

Return type:

tuple

Examples

Print a specific Group:

>>> fetched_group, _, error = client.ztb.groups_router.get_group('73459')
>>> if error:
...     print(f"Error fetching group by ID: {error}")
...     return
... print(f"Fetched group by ID: {fetched_group.as_dict()}")
list_groups(query_params=None)

Get all groups.

Parameters:

query_params (dict) –

Map of query parameters for the request.

[query_params.refresh_token] (str): Available values : enabled

[query_params.site_id] (str):

[query_params.page] (int):

[query_params.size] (int):

[query_params.sort] (str):

[query_params.sortdir] (str):

[query_params.group_type] (str): List of group types to filter

If empty would list isolation types only for backward compatibility Use all to list both Isolation and Access types

[query_params.filter_hidden] (str): Available values : true

Returns:

A tuple containing (list of GroupsRouter instances, Response, error).

Return type:

tuple

Examples

List all groups:

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

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_patch(group_id, **kwargs)

Updates information for the specified ZTB Group (PATCH).

Parameters:
  • group_id (int) – The unique ID for the Group.

  • **kwargs – Group fields to patch.

Returns:

A tuple containing the updated Group, response, and error.

Return type:

tuple

Examples

Patch an existing Group:

>>> patched_group, _, error = client.ztb.groups_router.update_group_patch(
...     group_id='73459',
...     display_name="Group01_Patched",
... )
>>> if error:
...     print(f"Error patching group: {error}")
...     return
... print(f"Group updated successfully (PATCH): {patched_group.as_dict()}")
update_group_put(group_id, **kwargs)

Updates information for the specified ZTB Group (PUT).

Parameters:
  • group_id (int) – The unique ID for the Group.

  • **kwargs – Full group replacement fields.

Returns:

A tuple containing the updated Group, response, and error.

Return type:

tuple

Examples

Update an existing Group:

>>> updated_group, _, error = client.ztb.groups_router.update_group_put(
...     group_id='73459',
...     name="Group01",
...     display_name="Group01",
...     type="device",
...     autonomous=True,
...     owner="user",
... )
>>> if error:
...     print(f"Error updating group: {error}")
...     return
... print(f"Group updated successfully (PUT): {updated_group.as_dict()}")