Google DNS Driver Documentation¶
Google Cloud DNS is a scalable, reliable and managed authoritative Domain Name System (DNS) service running on the same infrastructure as Google.
Instantiating the driver¶
The Google Cloud DNS driver supports three methods of authentication: * Service accounts * Installed Application * Internal authentication
To instantiate the driver, pass authentication tokens to the constructor as shown below:
1. Getting Driver with Service Account authentication¶
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver
DNSDriver = get_driver(Provider.GOOGLE)
driver = DNSDriver('service account email', 'keyfile location',
project='project ID')
2. Getting Driver with Installed Application authentication¶
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver
DNSDriver = get_driver(Provider.GOOGLE)
driver = DNSDriver('client ID', 'client secret',
project='project ID')
API Docs¶
- class libcloud.dns.drivers.google.GoogleDNSDriver(user_id, key, project=None, auth_type=None, scopes=None, **kwargs)[source]¶
- Parameters
key (
str
) – API key or username to 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.
- Returns
None
- connectionCls¶
alias of
libcloud.dns.drivers.google.GoogleDNSConnection
- create_record(name, zone, type, data, extra=None)[source]¶
Create a new record.
- Parameters
name (
str
) – Record name fully qualified, with a ‘.’ at the end.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. (optional)
- 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.) with a ‘.’ at the end.type (
str
) – Zone type (master is the only one supported).ttl (
int
) – TTL for new records. (unused)extra (
dict
) – Extra attributes (driver specific). (optional)
- 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_bulk_record_changes(zone, records)[source]¶
Bulk add and delete records.
- Parameters
zone (
Zone
) – Zone where the requested record changes are done.records – Dictionary of additions list or deletions list, or both
- of resourceRecordSets. For example:
- {‘additions’: [{‘rrdatas’: [‘127.0.0.1’],
‘kind’: ‘dns#resourceRecordSet’, ‘type’: ‘A’, ‘name’: ‘www.example.com.’, ‘ttl’: ‘300’}],
- ‘deletions’: [{‘rrdatas’: [‘127.0.0.1’],
‘kind’: ‘dns#resourceRecordSet’, ‘type’: ‘A’, ‘name’: ‘www2.example.com.’, ‘ttl’: ‘300’}]}
- Returns
A dictionary of Record additions and deletions.
- Return type
dict
of additions and deletions ofRecord
- 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)[source]¶
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()[source]¶
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)¶
Return a list of records for the provided zone.
- Parameters
zone (
Zone
) – Zone to list records for.- Returns
list
ofRecord
- list_zones()¶
Return a list of zones.
- Returns
list
ofZone
- update_record(record, name, type, data, extra=None)¶
Update an existing record.
- Parameters
record (
Record
) – Record to update.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.type (
RecordType
) – DNS record type (A, AAAA, …).data (
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