DNS Base API¶
- class libcloud.dns.base.DNSDriver(key: str, secret: str | None = None, secure: bool = True, host: str | None = None, port: int | None = None, **kwargs: Any | None)[source]¶
A base DNSDriver class to derive from
This class is always subclassed by a specific driver.
- 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
ConnectionUserAndKey
- create_record(name: str, zone: Zone, type: RecordType, data: str, extra: dict | None = None) Record [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 (driver specific). (optional)
- Return type:
- create_zone(domain: str, type: str = 'master', ttl: int | None = None, extra: dict | None = None) Zone [source]¶
Create a new zone.
- Parameters:
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:
- delete_record(record: Record) bool [source]¶
Delete a record.
- Parameters:
record (
Record
) – Record to delete.- Return type:
bool
- delete_zone(zone: Zone) bool [source]¶
Delete a zone.
Note: This will delete all the records belonging to this zone.
- Parameters:
zone (
Zone
) – Zone to delete.- Return type:
bool
- export_zone_to_bind_format(zone: Zone) str [source]¶
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: Zone, file_path: str) None [source]¶
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: str, record_id: str) Record [source]¶
Return a Record instance.
- Parameters:
zone_id (
str
) – ID of the required zonerecord_id (
str
) – ID of the required record
- Return type:
- get_zone(zone_id: str) Zone [source]¶
Return a Zone instance.
- Parameters:
zone_id (
str
) – ID of the required zone- Return type:
- iterate_records(zone: Zone) Iterator[Record] [source]¶
Return a generator to iterate over records for the provided zone.
- iterate_zones() Iterator[Zone] [source]¶
Return a generator to iterate over available zones.
- Return type:
generator
ofZone
- list_record_types() List[RecordType] [source]¶
Return a list of RecordType objects supported by the provider.
- Returns:
list
ofRecordType
- update_record(record, name, type, data, extra=None)[source]¶
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:
- class libcloud.dns.base.Zone(id, domain, type, ttl, driver, extra=None)[source]¶
DNS zone.
- Parameters:
id (
str
) – Zone id.domain (
str
) – The name of the domain.type (
str
) – Zone type (master, slave).ttl (
int
) – Default TTL for records in this zone (in seconds).driver (
DNSDriver
) – DNSDriver instance.extra (
dict
) – (optional) Extra attributes (driver specific).
- class libcloud.dns.base.Record(id, name, type, data, zone, driver, ttl=None, extra=None)[source]¶
Zone record / resource.
- Parameters:
id (
str
) – Record idname (
str
) – Hostname or FQDN.type (
RecordType
) – DNS record type (A, AAAA, …).data (
str
) – Data for the record (depends on the record type).zone (
Zone
) – Zone instance.driver (
DNSDriver
) – DNSDriver instance.ttl (
int
) – Record TTL.extra (
dict
) – (optional) Extra attributes (driver specific).