4.2.2.1. Zone¶
-
class
dyn.tm.zones.
Zone
(name, *args, **kwargs)[source]¶ A class representing a DynECT Zone
-
__init__
(name, *args, **kwargs)[source]¶ - Create a
Zone
object. Note: When creating a new Zone
if no contact is specified the path to a local zone file must be passed to thefile_name
param.
Parameters: - name – the name of the zone to create
- contact – Administrative contact for this zone
- ttl – TTL (in seconds) for records in the zone
- serial_style – The style of the zone’s serial. Valid values: increment, epoch, day, minute
- file_name – The path to a valid RFC1035, BIND, or tinydns style Master file. Note: this file must be under 1mb in size.
- master_ip – The IP of the master server from which to fetch zone
data for Transferring this
Zone
. Note: This argument is required for performing a valid ZoneTransfer operation. - timeout – The time, in minutes, to wait for a zone xfer to complete
- Create a
-
add_record
(name=None, record_type='A', *args, **kwargs)[source]¶ Adds an a record with the provided name and data to this
Zone
Parameters: - name – The name of the node where this record will be added
- record_type – The type of record you would like to add. Valid record_type arguments are: ‘A’, ‘AAAA’, ‘CERT’, ‘CNAME’, ‘DHCID’, ‘DNAME’, ‘DNSKEY’, ‘DS’, ‘KEY’, ‘KX’, ‘LOC’, ‘IPSECKEY’, ‘MX’, ‘NAPTR’, ‘PTR’, ‘PX’, ‘NSAP’, ‘RP’, ‘NS’, ‘SOA’, ‘SPF’, ‘SRV’, and ‘TXT’.
- args – Non-keyword arguments to pass to the Record constructor
- kwargs – Keyword arguments to pass to the Record constructor
-
add_service
(name=None, service_type=None, *args, **kwargs)[source]¶ Add the specified service type to this zone, or to a node under this zone
Parameters: - name – The name of the
Node
where this service will be attached to or None to attach it to the rootNode
of thisZone
- service_type – The type of the service you would like to create. Valid service_type arguments are: ‘ActiveFailover’, ‘DDNS’, ‘DNSSEC’, ‘DSF’, ‘GSLB’, ‘RDNS’, ‘RTTM’, ‘HTTPRedirect’
- args – Non-keyword arguments to pass to the Record constructor
- kwargs – Keyword arguments to pass to the Record constructor
- name – The name of the
-
contact
¶ The email address of the primary
Contact
associated with thisZone
-
fqdn
¶ The name of this
Zone
-
freeze
()[source]¶ Causes the zone to become frozen. Freezing a zone prevents changes to the zone until it is thawed.
-
get_all_active_failovers
()[source]¶ Retrieve a list of all
ActiveFailover
services associated with thisZone
Returns: A List
ofActiveFailover
Services
-
get_all_ddns
()[source]¶ Retrieve a list of all
DDNS
services associated with thisZone
Returns: A List
ofDDNS
Services
-
get_all_gslb
()[source]¶ Retrieve a list of all
GSLB
services associated with thisZone
Returns: A List
ofGSLB
Services
-
get_all_httpredirect
()[source]¶ Retrieve a list of all
HTTPRedirect
services associated with thisZone
Returns: A List
ofHTTPRedirect
Services
-
get_all_nodes
()[source]¶ Returns a list of Node Objects for all subnodes in Zone (Excluding the Zone itself.)
-
get_all_rdns
()[source]¶ Retrieve a list of all
ReverseDNS
services associated with thisZone
Returns: A List
ofReverseDNS
Services
-
get_all_records
()[source]¶ Retrieve a list of all record resources for the specified node and zone combination as well as all records from any Base_Record below that point on the zone hierarchy
Returns: A List
of all theDNSRecord
‘s under thisZone
-
get_all_records_by_type
(record_type)[source]¶ Get a list of all
DNSRecord
of typerecord_type
which are owned by this node.Parameters: record_type – The type of DNSRecord
you wish returned. Valid record_type arguments are: ‘A’, ‘AAAA’, ‘CERT’, ‘CNAME’, ‘DHCID’, ‘DNAME’, ‘DNSKEY’, ‘DS’, ‘KEY’, ‘KX’, ‘LOC’, ‘IPSECKEY’, ‘MX’, ‘NAPTR’, ‘PTR’, ‘PX’, ‘NSAP’, ‘RP’, ‘NS’, ‘SOA’, ‘SPF’, ‘SRV’, and ‘TXT’.Returns: A List
ofDNSRecord
‘s
-
get_all_rttm
()[source]¶ Retrieve a list of all
RTTM
services associated with thisZone
Returns: A List
ofRTTM
Services
-
get_node
(node=None)[source]¶ Returns all DNS Records for that particular node
Parameters: node – The name of the Node you wish to access, or None to get the root Node
of thisZone
-
get_notes
(offset=None, limit=None)[source]¶ Generates a report containing the Zone Notes for this
Zone
Parameters: - offset – The starting point at which to retrieve the notes
- limit – The maximum number of notes to be retrieved
Returns: A
list
ofdict
containingZone
Notes
-
get_qps
(start_ts, end_ts=None, breakdown=None, hosts=None, rrecs=None)[source]¶ Generates a report with information about Queries Per Second (QPS) for this zone
Parameters: - start_ts – datetime.datetime instance identifying point in time for the QPS report
- end_ts – datetime.datetime instance indicating the end of the data range for the report. Defaults to datetime.datetime.now()
- breakdown – By default, most data is aggregated together. Valid values (‘hosts’, ‘rrecs’, ‘zones’).
- hosts – List of hosts to include in the report.
- rrecs – List of record types to include in report.
Returns: A
str
with CSV data
-
name
¶ The name of this
Zone
-
publish
(notes=None)[source]¶ Causes all pending changes to become part of the zone. The serial number increments based on its serial style and the data is pushed out to the nameservers.
-
serial
¶ The current serial of this
Zone
-
serial_style
¶ The current serial style of this
Zone
-
status
¶ Convenience property for
Zones
. If aZones
is frozen the status will read as ‘frozen’, if theZones
is not frozen the status will read as ‘active’. Because the API does not return information about whether or not aZones
is frozen there will be a few cases where this status will be None in order to avoid guessing what the current status actually is.
-
task
¶ Task
for most recent system action on thisZone
.
-
thaw
()[source]¶ Causes the zone to become thawed. Thawing a frozen zone allows changes to again be made to the zone.
-
ttl
¶ This
Zone
‘s default TTL
-
4.2.2.1.1. Zone Examples¶
The following examples highlight how to use the Zone
class to
get/create Zone
‘s on the dyn.tm System and how to edit these objects
from within a Python script.
4.2.2.1.1.1. Creating a new Zone¶
The following example shows how to create a new Zone
on the dyn.tm
System and how to edit some of the fields using the returned Zone
object.
>>> from dyn.tm.zones import Zone
>>> # Create a dyn.tmSession
>>> new_zone = Zone('myzone.com', 'me@email.com')
>>> new_zone.serial
0
>>> new_zone.publish()
>>> new_zone.serial
1
4.2.2.1.1.2. Getting an Existing Zone¶
The following example shows how to get an existing Zone
from the
dyn.tm System.
>>> from dyn.tm.zones import Zone
>>> # Create a dyn.tmSession
>>> my_zone = Zone('myzone.com')
>>> my_zone.serial
5
>>> my_zone.contact
u'myemail@email.com'
4.2.2.1.1.3. Using lists of Zones¶
The following example shows how to use the results of a call to the
get_all_zones()
functions
>>> from dyn.tm.zones import get_all_zones
>>> # Create a dyn.tmSession
>>> my_zones = get_all_zones()
>>> for zone in my_zones:
... if zone.serial_style != 'increment':
... zone.serial_style = 'increment'
4.2.2.1.1.4. Adding Records to a Zone¶
The following examples show how to add records to a Zone using the add_record method.
>>> from dyn.tm.zones import Zone
>>> # Create a dyn.tmSession
>>> my_zone = Zone('myzone.com')
# Add record to zone apex
>>> my_zone.add_record(record_type='MX', exchange='mail.example.com.')
# Add record to node under zone apex
>>> my_zone.add_record('my_node', record_type='A', address='1.1.1.1')