DigitalOcean DNS Driver Documentation¶
DigitalOcean is an American cloud provider based in New York City with data centers in New York, Amsterdam, San Francisco, London, Singapore, Frankfurt, Toronto, and Bangalore.
Instantiating a driver¶
The DigitalOcean DNS driver only supports the v2.0 API requiring a Personal Access Token to initialize as the key.
Instantiating the driver¶
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver
cls = get_driver(Provider.DIGITAL_OCEAN)
driver = cls(key="access token")
API Docs¶
- class libcloud.dns.drivers.digitalocean.DigitalOceanDNSDriver(key, secret=None, api_version='v2', **kwargs)[source]¶
- Parameters
key (
str
) – API key or username to be used (required)secret (
str
) – Secret password to be used (required)secure (
bool
) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.host (
str
) – Override hostname used for connections.port (
int
) – Override port used for connections.api_version (
str
) – Optional API version. Only used by drivers which support multiple API versions.region (
str
) – Optional driver region. Only used by drivers which support multiple regions.
- Return type
None
- connectionCls¶
alias of
libcloud.common.digitalocean.DigitalOcean_v2_Connection
- create_record(name, zone, type, data, extra=None)[source]¶
Create a new record.
- Parameters
name (
str
) – Record name without the domain name (e.g. www). Note: If you want to create a record for a base domain name, you should specify empty string (‘’) for this argument.zone (
Zone
) – Zone where the requested record is created.type (
RecordType
) – DNS record type (A, AAAA, …).data (
str
) – Data for the record (depends on the record type).extra (
dict
) – Extra attributes for MX and SRV. (Depends on record) {“priority” : 0, “port” : 443, “weight” : 100}
- Return type
Record
- create_zone(domain, type='master', ttl=None, extra=None)[source]¶
Create a new zone.
- Parameters
domain (
str
) – Zone domain name (e.g. example.com)type (
str
) – Zone type (master / slave) (does nothing).ttl (
int
) – TTL for new records. (does nothing)extra (
dict
) – Extra attributes (to set ip). (optional) Note: This can be used to set the default A record with {“ip” : “IP.AD.DR.ESS”} otherwise 127.0.0.1 is used
- Return type
Zone
- delete_record(record)[source]¶
Delete a record.
- Parameters
record (
Record
) – Record to delete.- Return type
bool
- delete_zone(zone)[source]¶
Delete a zone.
Note: This will delete all the records belonging to this zone.
- Parameters
zone (
Zone
) – Zone to delete.- Return type
bool
- ex_get_event(event_id)¶
Get an event object
- Parameters
event_id (
str
) – Event id (required)
- export_zone_to_bind_format(zone)¶
Export Zone object to the BIND compatible format.
- Parameters
zone (
Zone
) – Zone to export.- Returns
Zone data in BIND compatible format.
- Return type
str
- export_zone_to_bind_zone_file(zone, file_path)¶
Export Zone object to the BIND compatible format and write result to a file.
- Parameters
zone (
Zone
) – Zone to export.file_path (
str
) – File path where the output will be saved.
- get_record(zone_id, record_id)[source]¶
Return a Record instance.
- Parameters
zone_id (
str
) – ID of the required zonerecord_id (
str
) – ID of the required record
- Return type
Record
- get_zone(zone_id)[source]¶
Return a Zone instance.
- Parameters
zone_id (
str
) – ID of the required zone- Return type
Zone
- iterate_records(zone)¶
Return a generator to iterate over records for the provided zone.
- Parameters
zone (
Zone
) – Zone to list records for.- Return type
generator
ofRecord
- iterate_zones()¶
Return a generator to iterate over available zones.
- Return type
generator
ofZone
- list_record_types()¶
Return a list of RecordType objects supported by the provider.
- Returns
list
ofRecordType
- list_records(zone)[source]¶
Return a list of records for the provided zone.
- Parameters
zone (
Zone
) – Zone to list records for.- Returns
list
ofRecord
- update_record(record, name=None, type=None, data=None, extra=None)[source]¶
Update an existing record.
- Parameters
record (
Record
) – Record to update.name (
str
) – Record name without the domain name (e.g. www). (Ignored) Note: The value is pulled from the record being updatedtype (
RecordType
) – DNS record type (A, AAAA, …). (Ignored) Note: Updating records does not support changing type so this value is ignoreddata (
str
) – Data for the record (depends on the record type).extra (
dict
) – (optional) Extra attributes (driver specific).
- Return type
Record
- update_zone(zone, domain, type='master', ttl=None, extra=None)¶
Update an existing zone.
- Parameters
zone (
Zone
) – Zone to update.domain (
str
) – Zone domain name (e.g. example.com)type (
str
) – Zone type (master / slave).ttl (
int
) – TTL for new records. (optional)extra (
dict
) – Extra attributes (driver specific). (optional)
- Return type
Zone