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
Zoneobject. Note: When creating a new Zoneif no contact is specified the path to a local zone file must be passed to thefile_nameparam.
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
ZoneParameters: - 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
Nodewhere this service will be attached to or None to attach it to the rootNodeof 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
-
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
ActiveFailoverservices associated with thisZoneReturns: A ListofActiveFailoverServices
-
get_all_advanced_redirect()[source]¶ Retrieve a list of all
AdvancedRedirectservices associated with thisZoneReturns: A ListofAdvancedRedirectServices
-
get_all_ddns()[source]¶ Retrieve a list of all
DDNSservices associated with thisZoneReturns: A ListofDDNSServices
-
get_all_gslb()[source]¶ Retrieve a list of all
GSLBservices associated with thisZoneReturns: A ListofGSLBServices
-
get_all_httpredirect()[source]¶ Retrieve a list of all
HTTPRedirectservices associated with thisZoneReturns: A ListofHTTPRedirectServices
-
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
ReverseDNSservices associated with thisZoneReturns: A ListofReverseDNSServices
-
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 Listof all theDNSRecord’s under thisZone
-
get_all_records_by_type(record_type)[source]¶ Get a list of all
DNSRecordof typerecord_typewhich are owned by this node.Parameters: record_type – The type of DNSRecordyou wish returned. Valid record_type arguments are: ‘A’, ‘AAAA’, ‘CAA’, ‘CERT’, ‘CNAME’, ‘DHCID’, ‘DNAME’, ‘DNSKEY’, ‘DS’, ‘KEY’, ‘KX’, ‘LOC’, ‘IPSECKEY’, ‘MX’, ‘NAPTR’, ‘PTR’, ‘PX’, ‘NSAP’, ‘RP’, ‘NS’, ‘SOA’, ‘SPF’, ‘SRV’, and ‘TXT’.Returns: A ListofDNSRecord’s
-
get_all_rttm()[source]¶ Retrieve a list of all
RTTMservices associated with thisZoneReturns: A ListofRTTMServices
-
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 Nodeof thisZone
-
get_notes(offset=None, limit=None)[source]¶ Generates a report containing the Zone Notes for this
ZoneParameters: - offset – The starting point at which to retrieve the notes
- limit – The maximum number of notes to be retrieved
Returns: A
listofdictcontainingZoneNotes
-
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
strwith CSV data
-
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.
-
status¶ Convenience property for
Zones. If aZonesis frozen the status will read as ‘frozen’, if theZonesis not frozen the status will read as ‘active’. Because the API does not return information about whether or not aZonesis frozen there will be a few cases where this status will be None in order to avoid guessing what the current status actually is.
-
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')