Skip to main content

DnsRule

Dns Rule resource for Zscaler Cloud & Branch Connector.

Resource operations

This resource supports the following standard methods: create(), load(), update(), delete(). They operate on the instance state — set properties with dot notation, then call the method with no arguments. Any other action listed below is a custom action that takes explicit keyword arguments and returns a value.

Quick Start​

import zssdk
import logging

# Enable debug logging for DnsRule
logging.getLogger('zssdk.ztw').setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)

session = zssdk.Session(
vanity_domain="your-vanity-domain",
client_id="your-client-id",
client_secret="your-client-secret",
)

# Get a specific DnsRule
resource = session.ztw.DnsRule(id="your-resource-id")
resource.load()
print(resource)

# Debug output shows HTTP request/response details

Identifiers​

NameTypeDescription
idstringUnique identifier

Actions​

create()​

Creates a new DnsRule. Set properties on the resource instance, then call create() — this method takes no arguments.

Properties for creation:

NameTypeRequiredDescription
access_controlstringNo-
actionstringNo-
block_response_codestringNo-
default_rulebooleanNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
dns_gatewayEntityReferenceNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
orderintegerNo-
predefinedbooleanNo-
rankintegerNo-
redirect_ipstringNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
usersEntityReferenceWrapperCollectionNo-
zpa_ip_groupEntityReferenceNo-

Returns: DnsRule

Example:

resource = session.ztw.DnsRule()
resource.name = "example-name"
resource.create()
print(f"Created with ID: {resource.id}")

create_forwarding_rule()​

Parameters:

NameTypeRequiredDescription
access_controlstringNo-
app_service_groupsEntityReferenceWrapperCollectionNo-
block_response_codestringNo-
dedicated_IP_gatewayEntityReferenceNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
dest_workload_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
forward_methodstringNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
nw_application_groupsEntityReferenceWrapperCollectionNo-
nw_applicationsNwApplicationsEnumCollectionNo-
nw_service_groupsEntityReferenceWrapperCollectionNo-
nw_servicesEntityReferenceWrapperCollectionNo-
orderintegerNo-
proxy_gatewayEntityReferenceNo-
rankintegerNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
src_workload_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
typestringNo-
usersEntityReferenceWrapperCollectionNo-
wan_selectionstringNo-
zpa_app_segmentsAppSegmentWrapperCollectionNo-
zpa_application_segment_groupsZpaApplicationSegmentGroupWrapperCollectionNo-
zpa_application_segmentsZpaApplicationSegmentWrapperCollectionNo-
zpa_broker_rulebooleanNo-
zpa_gatewayEntityReferenceNo-

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule()
result = resource.create_forwarding_rule(name="example-name")
print(result)

create_self_rule()​

Parameters:

NameTypeRequiredDescription
access_controlstringNo-
app_service_groupsEntityReferenceWrapperCollectionNo-
block_response_codestringNo-
dedicated_IP_gatewayEntityReferenceNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
dest_workload_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
forward_methodstringNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
nw_application_groupsEntityReferenceWrapperCollectionNo-
nw_applicationsNwApplicationsEnumCollectionNo-
nw_service_groupsEntityReferenceWrapperCollectionNo-
nw_servicesEntityReferenceWrapperCollectionNo-
orderintegerNo-
proxy_gatewayEntityReferenceNo-
rankintegerNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
src_workload_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
typestringNo-
usersEntityReferenceWrapperCollectionNo-
wan_selectionstringNo-
zpa_app_segmentsAppSegmentWrapperCollectionNo-
zpa_application_segment_groupsZpaApplicationSegmentGroupWrapperCollectionNo-
zpa_application_segmentsZpaApplicationSegmentWrapperCollectionNo-
zpa_broker_rulebooleanNo-
zpa_gatewayEntityReferenceNo-

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule()
result = resource.create_self_rule(name="example-name")
print(result)

delete()​

Deletes a DnsRule by id. Only the id identifier is required; delete() takes no other arguments.

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
resource.delete()

get_ec_dns_rules_count()​

Parameters:

NameTypeRequiredDescription
predefined_rule_countbooleanNo-
rule_namestringNo-
rule_orderstringNo-
rule_descriptionstringNo-
rule_actionstringNo-
locationstringNo-

Example:

resource = session.ztw.DnsRule()
result = resource.get_ec_dns_rules_count()
print(result)

get_forwarding_rules_count()​

Parameters:

NameTypeRequiredDescription
predefined_rule_countbooleanNo-
rule_namestringNo-
rule_orderstringNo-
rule_descriptionstringNo-
rule_forward_methodstringNo-
locationstringNo-

Example:

resource = session.ztw.DnsRule()
result = resource.get_forwarding_rules_count()
print(result)

get_self_ec_rules_count()​

Parameters:

NameTypeRequiredDescription
predefined_rule_countbooleanNo-
rule_namestringNo-
rule_orderstringNo-
rule_descriptionstringNo-
locationstringNo-
rule_forward_methodstringNo-

Example:

resource = session.ztw.DnsRule()
result = resource.get_self_ec_rules_count()
print(result)

load()​

Fetches an existing DnsRule by id. Only the id identifier is required; load() takes no other arguments.

Returns: DnsRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
resource.load()
print(resource.name)

update()​

Updates an existing DnsRule. Call load() first, modify properties, then call update() — this method takes no arguments.

Properties for update:

NameTypeRequiredDescription
access_controlstringNo-
actionstringNo-
block_response_codestringNo-
default_rulebooleanNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
dns_gatewayEntityReferenceNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
orderintegerNo-
predefinedbooleanNo-
rankintegerNo-
redirect_ipstringNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
usersEntityReferenceWrapperCollectionNo-
zpa_ip_groupEntityReferenceNo-

Returns: DnsRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
resource.load()
resource.name = "Updated value"
resource.update()

get_forwarding_rule_by_id()​

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.get_forwarding_rule_by_id()
print(result)

update_forwarding_rule()​

Parameters:

NameTypeRequiredDescription
access_controlstringNo-
app_service_groupsEntityReferenceWrapperCollectionNo-
block_response_codestringNo-
dedicated_IP_gatewayEntityReferenceNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
dest_workload_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
forward_methodstringNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
nw_application_groupsEntityReferenceWrapperCollectionNo-
nw_applicationsNwApplicationsEnumCollectionNo-
nw_service_groupsEntityReferenceWrapperCollectionNo-
nw_servicesEntityReferenceWrapperCollectionNo-
orderintegerNo-
proxy_gatewayEntityReferenceNo-
rankintegerNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
src_workload_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
typestringNo-
usersEntityReferenceWrapperCollectionNo-
wan_selectionstringNo-
zpa_app_segmentsAppSegmentWrapperCollectionNo-
zpa_application_segment_groupsZpaApplicationSegmentGroupWrapperCollectionNo-
zpa_application_segmentsZpaApplicationSegmentWrapperCollectionNo-
zpa_broker_rulebooleanNo-
zpa_gatewayEntityReferenceNo-

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.update_forwarding_rule(name="example-name")
print(result)

delete_forwarding_rule()​

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.delete_forwarding_rule()
print(result)

get_ec_self_rule_by_id()​

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.get_ec_self_rule_by_id()
print(result)

update_self_rule()​

Parameters:

NameTypeRequiredDescription
access_controlstringNo-
app_service_groupsEntityReferenceWrapperCollectionNo-
block_response_codestringNo-
dedicated_IP_gatewayEntityReferenceNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
dest_workload_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
forward_methodstringNo-
groupsEntityReferenceWrapperCollectionNo-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
nw_application_groupsEntityReferenceWrapperCollectionNo-
nw_applicationsNwApplicationsEnumCollectionNo-
nw_service_groupsEntityReferenceWrapperCollectionNo-
nw_servicesEntityReferenceWrapperCollectionNo-
orderintegerNo-
proxy_gatewayEntityReferenceNo-
rankintegerNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
src_workload_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
typestringNo-
usersEntityReferenceWrapperCollectionNo-
wan_selectionstringNo-
zpa_app_segmentsAppSegmentWrapperCollectionNo-
zpa_application_segment_groupsZpaApplicationSegmentGroupWrapperCollectionNo-
zpa_application_segmentsZpaApplicationSegmentWrapperCollectionNo-
zpa_broker_rulebooleanNo-
zpa_gatewayEntityReferenceNo-

Returns: ForwardingRule

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.update_self_rule(name="example-name")
print(result)

delete_self_forwarding_rule()​

Example:

resource = session.ztw.DnsRule(id="your-resource-id")
result = resource.delete_self_forwarding_rule()
print(result)

Attributes​

NameTypeRequiredDescription
access_controlstringNo-
actionstringNo-
block_response_codestringNo-
default_rulebooleanNo-
departmentsEntityReferenceWrapperCollectionNo-
descriptionstringNo-
dest_addressesstringCollectionNo-
dest_countriesDestCountriesEnumCollectionNo-
dest_ip_categoriesstringCollectionNo-
dest_ip_groupsEntityReferenceWrapperCollectionNo-
dest_ipv6_groupsEntityReferenceWrapperCollectionNo-
device_groupsEntityReferenceWrapperCollectionNo-
devicesEntityReferenceWrapperCollectionNo-
dns_gatewayEntityReferenceNo-
ec_groupsEntityReferenceWrapperCollectionNo-
end_point_application_groupsEndPointApplicationGroupWrapperCollectionNo-
end_point_application_threat_levelsEndPointApplicationThreatLevelsEnumCollectionNo-
end_point_applicationsEndPointApplicationLiteWrapperCollectionNo-
exclude_context_shield_end_pointbooleanNo-
groupsEntityReferenceWrapperCollectionNo-
idintegerYes-
labelsEntityReferenceWrapperCollectionNo-
last_modified_byEntityReferenceNo-
last_modified_timeintegerNo-
location_groupsEntityReferenceWrapperCollectionNo-
locationsEntityReferenceWrapperCollectionNo-
namestringYes-
orderintegerNo-
predefinedbooleanNo-
rankintegerNo-
redirect_ipstringNo-
res_categoriesstringCollectionNo-
source_countriesDestCountriesEnumCollectionNo-
source_ip_group_exclusionbooleanNo-
source_ip_group_exclusion_flagbooleanNo-
src_ip_groupsEntityReferenceWrapperCollectionNo-
src_ipsstringCollectionNo-
src_ipv6_groupsEntityReferenceWrapperCollectionNo-
statestringNo-
template_synced_rule_flagstringNo-
time_windowsEntityReferenceWrapperCollectionNo-
usersEntityReferenceWrapperCollectionNo-
zpa_ip_groupEntityReferenceNo-
  • DnsRule - Data structure definition
  • Logging guide - enable verbose logs while debugging this resource