ip_source_groups

The following methods allow for interaction with the ZTW IP Source Groups API endpoints.

Methods are accessible via ztw.ip_source_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 IPSourceGroupsAPI

Bases: APIClient

add_ip_source_group(**kwargs)

Adds a new IP Source Group.

Parameters:
  • name (str) – The name of the IP Source Group.

  • ip_addresses (str) – The list of IP addresses for the IP Source Group.

  • description (str) – Additional information for the IP Source Group.

Returns:

The new IP Source Group resource record.

Return type:

tuple

Examples

Add a new IP Source Group:

>>> ztw.ip_source_groups.add_ip_source_group(name='My IP Source Group',
...    ip_addresses=['198.51.100.0/24', '192.0.2.1'],
...    description='Contains the IP addresses for the local network.')
delete_ip_source_group(group_id)

Deletes an IP Source Group.

Parameters:

group_id (str) – The unique ID of the IP Source Group to be deleted.

Returns:

The status code for the operation.

Return type:

int

Examples

>>> _, response, error = client.ztw.ip_source_groups.delete_ip_source_group(updated_group.id)
... if error:
...     print(f"Error deleting group: {error}")
... return
list_ip_source_groups(query_params=None)

List IP Source Groups in your organization.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.search] {str}: Search string for filtering results by rule name.

Returns:

A tuple containing (list of IP Source Groups instances, Response, error)

Return type:

tuple

Examples

List all IP Source Groups:

>>> group_list, response, error = ztw.ip_source_groups.list_ip_source_groups():
... if error:
...     print(f"Error listing IP Source Groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())

Gets a list of all IP Source Groups.

>>> group_list, response, error = ztw.ip_source_groups.list_ip_source_groups(query_params={"search": 'Group01'}):
... if error:
...     print(f"Error listing IP Source Groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())
list_ip_source_groups_lite(query_params=None)

Lists IP Source Groups name and ID all IP Source Groups. This endpoint retrieves only IPv4 source address groups. If the search parameter is provided, the function filters the rules client-side.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.search] {str}: The search string used to match against

a group’s name or description attributes.

Returns:

List of IP Source Groups resource records.

Return type:

tuple

Examples

Gets a list of all IP source groups.

>>> group_list, response, error = ztw.ip_source_groups.list_ip_source_groups_lite():
... if error:
...     print(f"Error listing IP source groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())

Gets a list of all IP source groups name and ID.

>>> group_list, response, error = (
...     ztw.ip_source_groups.list_ip_source_groups_lite(
...         query_params={"search": 'Group01'}
...     )
... ):
... if error:
...     print(f"Error listing IP source groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())