CloudFlare DNS Driver Documentation¶
CloudFlare, Inc. is a U.S. company that provides a content delivery network and distributed domain name server services.
Instantiating the driver¶
To instantiate the driver you need to pass email address associated with your account and API key available on the account page to the driver constructor as shown below.
from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver
cls = get_driver(Provider.CLOUDFLARE)
driver = cls('<email address>', '<api key>')
API Docs¶
-
class
libcloud.dns.drivers.cloudflare.
CloudFlareDNSDriver
(key, secret=None, secure=True, host=None, port=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
-
create_zone
(domain, type='master', ttl=None, extra=None)¶ 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: Zone
- domain (
-
delete_zone
(zone)¶ Delete a zone.
Note: This will delete all the records belonging to this zone.
Parameters: zone ( Zone
) – Zone to delete.Return type: bool
-
ex_enable_development_mode
(zone)[source]¶ Enable development mode. When Development Mode is on the cache is bypassed. Development mode remains on for 3 hours or until when it is toggled back off.
-
ex_get_ip_threat_score
(ip)[source]¶ Retrieve current threat score for a given IP. Note that scores are on a logarithmic scale, where a higher score indicates a higher threat.
-
ex_purge_cached_file
(zone, url)[source]¶ Purge single file from CloudFlare’s cache.
Parameters: url ( str
) – URL to the file to purge from cache.
-
ex_set_zone_cache_level
(zone, level)[source]¶ Set the zone caching level.
Parameters: level ( str
) – Caching level. Valid values are: agg (aggresive), basic.
-
ex_set_zone_security_level
(zone, level)[source]¶ Set the zone Basic Security Level to I’M UNDER ATTACK! / HIGH / MEDIUM / LOW / ESSENTIALLY OFF.
Parameters: level ( str
) – Security level. Valid values are: help, high, med, low, eoff.
-
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.
- zone (
-
get_record
(zone_id, record_id)¶ Return a Record instance.
Parameters: - zone_id (
str
) – ID of the required zone - record_id (
str
) – ID of the required record
Return type: Record
- zone_id (
-
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_regions
()¶ Method which returns a list of the available / supported regions.
Return type: list
ofstr
-
list_zones
()¶ Return a list of zones.
Returns: list
ofZone
-
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
- zone (
- key (