nsone.zones

Object representing a single DNS zone.

Note

Answers to a record (the answers kwarg) should be passed as one of the following four structures, depending on how advanced the configuration for the answer needs to be:

  1. A single string that is coerced to a single answer with no other fields e.g. meta. For example: “1.1.1.1”
  2. A list of single strings that is coerced to several answers with no other fields e.g. meta. For example: [“1.1.1.1”, “2.2.2.2”]
  3. A list of lists. In this case there will be as many answers as are in the outer list, and the answers themselves are used verbatim from the inner list (e.g. may have MX style [10, ‘1.1.1.1]), but no other fields e.g. meta. You must use this form for MX records, and if there is only one answer it still must be wrapped in an outer list.
  4. A list of dicts. In this case it expects the full rest model and passes it along unchanged. You must use this form for any advanced record config like meta data or data feeds.
# Example of an advanced answer configuration (list of dicts)
record = yield zone.add_A('record',
                           [{'answer': ['1.1.1.1'],
                             'meta': {
                                 'up': False
                                 }
                             },
                            {'answer': ['9.9.9.9'],
                             'meta': {
                                 'up': True
                                 }
                             }],
                           filters=[{'up': {}}])
class nsone.zones.Zone(config, zone)

Bases: object

High level object representing a Zone. In addition to the documented methods, there are magic methods allowing easy creation of records in this zone. Simply can ‘add_TYPE’ where TYPE is a valid DNS record type, such as add_A(). See examples for more information.

Create a new high level Zone object

Parameters:
cloneRecord(existing_domain, new_domain, rtype, zone=None, callback=None, errback=None)

Clone the given record to a new record such that their configs are identical.

Parameters:
  • existing_domain (str) – The existing record to clone
  • new_domain (str) – The name of the new cloned record
  • rtype (str) – DNS record type
  • zone (str) – Optional zone name, if the new record should exist in a different zone than the original record.
Return type:

nsone.records.Record

Returns:

new Record

create(zoneFile=None, callback=None, errback=None, **kwargs)

Create a new zone. Pass a list of keywords and their values to configure. For the list of keywords available for zone configuration, see nsone.rest.zones.Zones.INT_FIELDS and nsone.rest.zones.Zones.PASSTHRU_FIELDS If zoneFile is passed, it should be a zone text file on the local disk that will be used to populate the created zone file.

createLinkToSelf(new_zone, callback=None, errback=None, **kwargs)

Create a new linked zone, linking to ourselves. All records in this zone will then be available as “linked records” in the new zone.

Parameters:new_zone (str) – the new zone name to link to this one
Returns:new Zone
delete(callback=None, errback=None)

Delete the zone and ALL records it contains.

linkRecord(existing_domain, new_domain, rtype, callback=None, errback=None, **kwargs)

Create a new linked record in this zone. These records use the configuration (answers, ttl, filters, etc) from an existing record in the NSONE platform.

Parameters:
  • existing_domain (str) – FQDN of the target record whose config should be used. Does not have to be in the same zone.
  • new_domain (str) – Name of the new (linked) record. Zone name is appended automatically.
  • rtype (str) – DNS record type, which must match the target record.
Return type:

nsone.records.Record

Returns:

new Record

load(callback=None, errback=None, reload=False)

Load zone data from the API.

loadRecord(domain, rtype, callback=None, errback=None)

Load a high level Record object from a domain within this Zone.

Parameters:
  • domain (str) – The name of the record to load
  • rtype (str) – The DNS record type
Return type:

nsone.records.Record

Returns:

new Record

qps(callback=None, errback=None)

Return the current QPS for this zone

Return type:dict
Returns:QPS information
reload(callback=None, errback=None)

Reload zone data from the API.

update(callback=None, errback=None, **kwargs)

Update zone configuration. Pass a list of keywords and their values to update. For the list of keywords available for zone configuration, see nsone.rest.zones.Zones.INT_FIELDS and nsone.rest.zones.Zones.PASSTHRU_FIELDS

usage(callback=None, errback=None, **kwargs)

Return the current usage information for this zone

Return type:dict
Returns:usage information
exception nsone.zones.ZoneException

Bases: exceptions.Exception