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:
- A single string that is coerced to a single answer with no other fields e.g. meta. For example: “1.1.1.1”
- 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”]
- 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.
- 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: - config (nsone.config.Config) – config object
- zone (str) – zone name
-
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: Return type: 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
andnsone.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: Return type: 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: Return type: 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
andnsone.rest.zones.Zones.PASSTHRU_FIELDS
-
exception
nsone.zones.
ZoneException
¶ Bases:
exceptions.Exception