ip_destination_groups

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

Methods are accessible via ztw.ip_destination_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 IPDestinationGroupsAPI

Bases: APIClient

add_ip_destination_group(**kwargs)

Adds a new IP Destination Group.

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

  • **kwargs – Optional keyword args.

Keyword Arguments:
  • type (str) – Destination IP group type. Allowed values are DSTN_IP and DSTN_FQDN.

  • addresses (list) – Destination IP addresses or FQDNs within the group.

  • description (str) – Additional information about the destination IP group.

  • ip_categories (list) – Destination IP address URL categories.

  • countries (list) – Destination IP address counties.

Returns:

The newly created IP Destination Group resource record.

Return type:

Tuple

Examples

Add a Destination IP Group with IP addresses:

>>> client.ztw.ip_destination_groups.add_ip_destination_group(name='Destination Group - IP',
...    addresses=['203.0.113.0/25', '203.0.113.131'],
...    type='DSTN_IP')

Add a Destination IP Group with FQDN:

>>> client.ztw.ip_destination_groups.add_ip_destination_group(name='Destination Group - FQDN',
...    description='Covers domains for Example Inc.',
...    addresses=['example.com', 'example.edu'],
...    type='DSTN_FQDN')

Add a Destionation IP Group for the US:

>>> client.ztw.ip_destination_groups.add_ip_destination_group(name='Destination Group - US',
...    description='Covers the US',
...    countries=['COUNTRY_US'])
delete_ip_destination_group(group_id)

Deletes the specified IP Destination Group.

Parameters:

group_id (str) – The unique ID of the IP Destination Group.

Returns:

The status code of the operation.

Return type:

int

Examples

>>> _, response, error = client.client.ztw.ip_destination_groups.delete_ip_destination_group(updated_group.id)
... if error:
...     print(f"Error deleting group: {error}")
... return
list_ip_destination_groups(exclude_type=None, query_params=None)

Returns a list of IP Destination Groups.

Parameters:

query_params (dict) –

Map of query parameters for the request.

[query_params.exclude_type] (str):

Exclude all groups that match the specified IP destination group’s type. Accepted values: DSTN_IP, DSTN_FQDN, DSTN_DOMAIN, DSTN_OTHER.

Returns:

A tuple containing (list of IPDestinationGroups instances, Response, error)

Return type:

tuple

Examples

Gets a list of all IP destination groups.

>>> group_list, response, error = client.ztw.ip_destination_groups.list_ip_destination_groups():
... if error:
...     print(f"Error listing ip destination 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 destination groups by excluding specific type.

>>> group_list, response, error = (
...     client.ztw.ip_destination_groups.list_ip_destination_groups(
...         query_params={"exclude_type": 'DSTN_DOMAIN'}
...     )
... ):
... if error:
...     print(f"Error listing ip destination groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())
list_ip_destination_groups_lite(exclude_type=None, query_params=None)

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

Parameters:

query_params (dict) –

Map of query parameters for the request.

[query_params.exclude_type] (str):

Exclude all groups that match the specified IP destination group’s type. Accepted values: DSTN_IP, DSTN_FQDN, DSTN_DOMAIN, DSTN_OTHER.

Returns:

List of IP Destination Groups resource records.

Return type:

tuple

Examples

Gets a list of all IP destination groups.

>>> group_list, response, error = client.ztw.ip_destination_groups.list_ip_destination_groups_lite():
... if error:
...     print(f"Error listing ip destination 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 destination groups by excluding specific type.

>>> group_list, response, error = (
...     client.ztw.ip_destination_groups.list_ip_destination_groups_lite(
...         query_params={"exclude_type": 'DSTN_DOMAIN'}
...     )
... ):
... if error:
...     print(f"Error listing ip destination groups: {error}")
...     return
... print(f"Total groups found: {len(group_list)}")
... for group in group_list:
...     print(group.as_dict())