Domains¶
Domain¶
-
class
doapi.
Domain
[source]¶ A domain resource, representing a domain name whose DNS is managed by DigitalOcean’s nameservers.
New domains are created via the
doapi.create_domain()
method and can be retrieved with thedoapi.fetch_domain()
anddoapi.fetch_all_domains()
methods.The DigitalOcean API specifies the following fields for domain objects:
Variables: -
url
¶ The endpoint for operations on the specific domain
-
fetch
()[source]¶ Fetch & return a new
Domain
object representing the domain’s current stateReturn type: Domain Raises: DOAPIError – if the API endpoint replies with an error (e.g., if the domain no longer exists)
-
delete
()[source]¶ Delete the domain
Returns: None
Raises: DOAPIError – if the API endpoint replies with an error
-
record_url
¶ The endpoint for operations on the domain’s DNS records
-
fetch_record
(obj)[source]¶ Fetch a domain record by ID number
Parameters: obj (integer, dict
, orDomainRecord
) – the ID of the record, adict
with an"id"
field, or aDomainRecord
object (to re-fetch the same record)Return type: DomainRecord Raises: DOAPIError – if the API endpoint replies with an error
-
fetch_all_records
()[source]¶ Returns a generator that yields all of the DNS records for the domain
Return type: generator of DomainRecord
sRaises: DOAPIError – if the API endpoint replies with an error
-
create_record
(type, name, data, priority=None, port=None, weight=None, **kwargs)[source]¶ Add a new DNS record to the domain
Parameters: - type (str) – the type of DNS record to add (
"A"
,"CNAME"
, etc.) - name (str) – the name (hostname, alias, etc.) of the new record
- data (str) – the value of the new record
- priority (int) – the priority of the new record (SRV and MX records only)
- port (int) – the port that the service is accessible on (SRV records only)
- weight (int) – the weight of records with the same priority (SRV records only)
- kwargs – additional fields to include in the API request
Returns: the new domain record
Return type: Raises: DOAPIError – if the API endpoint replies with an error
- type (str) – the type of DNS record to add (
-
DomainRecord¶
-
class
doapi.
DomainRecord
[source]¶ A domain record resource, representing an individual DNS record that can be set & modified by the user of the DigitalOcean API.
New domain records are created via the
Domain.create_record()
method and can be retrieved with theDomain.fetch_record()
andDomain.fetch_all_records()
methods.The DigitalOcean API specifies the following fields for domain record objects:
Variables: - id (int) – a unique identifier for the domain record
- type (string) – the type of the DNS record
- name (string) – the name of the DNS record
- data (string) – the value of the DNS record
- priority (number or
None
) – the priority of the record (SRV and MX records only) - port (number or
None
) – the port of the record (SRV records only) - weight (number or
None
) – the weight of the record (SRV records only)
-
__int__
()¶ Convert the resource to its unique ID
-
url
¶ The endpoint for operations on the specific domain record
-
fetch
()[source]¶ Fetch & return a new
DomainRecord
object representing the domain record’s current stateReturn type: DomainRecord Raises: DOAPIError – if the API endpoint replies with an error (e.g., if the domain record no longer exists)
-
fetch_domain
()[source]¶ Fetch & return the domain resource that the record belongs to
Return type: Domain Raises: DOAPIError – if the API endpoint replies with an error
-
update_record
(**attrs)[source]¶ Update the record, modifying any number of its attributes (except
id
).update_record
takes the same keyword arguments asDomain.create_record()
; pass in only those attributes that you want to update.Returns: an updated DomainRecord
objectReturn type: DomainRecord Raises: DOAPIError – if the API endpoint replies with an error