domain_records
Creates, updates, deletes, gets or lists a domain_records resource.
Overview
| Name | domain_records |
| Type | Resource |
| Id | digitalocean.compute.domain_records |
Fields
The following fields are returned by SELECT queries:
- domains_get_record
- domains_list_records
The response will be a JSON object with a key called domain_record. The value of this will be a domain record object which contains the standard domain record attributes.
| Name | Datatype | Description |
|---|---|---|
id | integer | A unique identifier for each domain record. |
name | string | The host name, alias, or service being defined by the record. (example: @) |
data | string | Variable data depending on record type. For example, the "data" value for an A record would be the IPv4 address to which the domain will be mapped. For a CAA record, it would contain the domain name of the CA being granted permission to issue certificates. (example: ns1.digitalocean.com) |
flags | integer | An unsigned integer between 0-255 used for CAA records. |
port | integer | The port for SRV records. |
priority | integer | The priority for SRV and MX records. |
tag | string | The parameter tag for CAA records. Valid values are "issue", "issuewild", or "iodef" |
ttl | integer | This value is the time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested. |
type | string | The type of the DNS record. For example: A, CNAME, TXT, ... (example: NS) |
weight | integer | The weight for SRV records. |
The response will be a JSON object with a key called domain_records. The value of this will be an array of domain record objects, each of which contains the standard domain record attributes. For attributes that are not used by a specific record type, a value of null will be returned. For instance, all records other than SRV will have null for the weight and port attributes.
| Name | Datatype | Description |
|---|---|---|
id | integer | A unique identifier for each domain record. |
name | string | The host name, alias, or service being defined by the record. (example: @) |
data | string | Variable data depending on record type. For example, the "data" value for an A record would be the IPv4 address to which the domain will be mapped. For a CAA record, it would contain the domain name of the CA being granted permission to issue certificates. (example: ns1.digitalocean.com) |
flags | integer | An unsigned integer between 0-255 used for CAA records. |
port | integer | The port for SRV records. |
priority | integer | The priority for SRV and MX records. |
tag | string | The parameter tag for CAA records. Valid values are "issue", "issuewild", or "iodef" |
ttl | integer | This value is the time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested. |
type | string | The type of the DNS record. For example: A, CNAME, TXT, ... (example: NS) |
weight | integer | The weight for SRV records. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
domains_get_record | select | domain_name, domain_record_id | To retrieve a specific domain record, send a GET request to /v2/domains/$DOMAIN_NAME/records/$RECORD_ID. | |
domains_list_records | select | domain_name | name, type, per_page, page | To get a listing of all records configured for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records.The list of records returned can be filtered by using the name and type query parameters. For example, to only include A records for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records?type=A. name must be a fully qualified record name. For example, to only include records matching sub.example.com, send a GET request to /v2/domains/$DOMAIN_NAME/records?name=sub.example.com. Both name and type may be used together. |
domains_create_record | insert | domain_name, type | To create a new record to a domain, send a POST request to/v2/domains/$DOMAIN_NAME/records.The request must include all of the required fields for the domain record type being added. See the attribute table for details regarding record types and their respective required attributes. | |
domains_patch_record | update | domain_name, domain_record_id, type | To update an existing record, send a PATCH request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid forthe record type can be set to a new value for the record. See the attribute table for details regarding record types and their respective attributes. | |
domains_update_record | replace | domain_name, domain_record_id, type | To update an existing record, send a PUT request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid forthe record type can be set to a new value for the record. See the attribute table for details regarding record types and their respective attributes. | |
domains_delete_record | delete | domain_name, domain_record_id | To delete a record for a domain, send a DELETE request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID.The record will be deleted and the response status will be a 204. This indicates a successful request with no body returned. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
domain_name | string | The name of the domain itself. (example: example.com) |
domain_record_id | integer | The unique identifier of the domain record. (example: 3352896) |
name | string | A fully qualified record name. For example, to only include records matching sub.example.com, send a GET request to /v2/domains/$DOMAIN_NAME/records?name=sub.example.com. (example: sub.example.com) |
page | integer | Which 'page' of paginated results to return. (example: 1) |
per_page | integer | Number of items returned per page (example: 2) |
type | string | The type of the DNS record. For example: A, CNAME, TXT, ... (example: A) |
SELECT examples
- domains_get_record
- domains_list_records
To retrieve a specific domain record, send a GET request to /v2/domains/$DOMAIN_NAME/records/$RECORD_ID.
SELECT
id,
name,
data,
flags,
port,
priority,
tag,
ttl,
type,
weight
FROM digitalocean.compute.domain_records
WHERE domain_name = '{{ domain_name }}' -- required
AND domain_record_id = '{{ domain_record_id }}' -- required
;
To get a listing of all records configured for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records.
The list of records returned can be filtered by using the name and type query parameters. For example, to only include A records for a domain, send a GET request to /v2/domains/$DOMAIN_NAME/records?type=A. name must be a fully qualified record name. For example, to only include records matching sub.example.com, send a GET request to /v2/domains/$DOMAIN_NAME/records?name=sub.example.com. Both name and type may be used together.
SELECT
id,
name,
data,
flags,
port,
priority,
tag,
ttl,
type,
weight
FROM digitalocean.compute.domain_records
WHERE domain_name = '{{ domain_name }}' -- required
AND name = '{{ name }}'
AND type = '{{ type }}'
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- domains_create_record
- Manifest
To create a new record to a domain, send a POST request to/v2/domains/$DOMAIN_NAME/records.
The request must include all of the required fields for the domain record type
being added.
See the attribute table for details regarding record
types and their respective required attributes.
INSERT INTO digitalocean.compute.domain_records (
type,
name,
data,
priority,
port,
ttl,
weight,
flags,
tag,
domain_name
)
SELECT
'{{ type }}' /* required */,
'{{ name }}',
'{{ data }}',
{{ priority }},
{{ port }},
{{ ttl }},
{{ weight }},
{{ flags }},
'{{ tag }}',
'{{ domain_name }}'
RETURNING
domain_record
;
# Description fields are for documentation purposes
- name: domain_records
props:
- name: domain_name
value: "{{ domain_name }}"
description: Required parameter for the domain_records resource.
- name: type
value: "{{ type }}"
description: |
The type of the DNS record. For example: A, CNAME, TXT, ...
- name: name
value: "{{ name }}"
description: |
The host name, alias, or service being defined by the record.
- name: data
value: "{{ data }}"
description: |
Variable data depending on record type. For example, the "data" value for an A record would be the IPv4 address to which the domain will be mapped. For a CAA record, it would contain the domain name of the CA being granted permission to issue certificates.
- name: priority
value: {{ priority }}
description: |
The priority for SRV and MX records.
- name: port
value: {{ port }}
description: |
The port for SRV records.
- name: ttl
value: {{ ttl }}
description: |
This value is the time to live for the record, in seconds. This defines the time frame that clients can cache queried information before a refresh should be requested.
- name: weight
value: {{ weight }}
description: |
The weight for SRV records.
- name: flags
value: {{ flags }}
description: |
An unsigned integer between 0-255 used for CAA records.
- name: tag
value: "{{ tag }}"
description: |
The parameter tag for CAA records. Valid values are "issue", "issuewild", or "iodef"
UPDATE examples
- domains_patch_record
To update an existing record, send a PATCH request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.
See the attribute table for details regarding record
types and their respective attributes.
UPDATE digitalocean.compute.domain_records
SET
type = '{{ type }}',
name = '{{ name }}',
data = '{{ data }}',
priority = {{ priority }},
port = {{ port }},
ttl = {{ ttl }},
weight = {{ weight }},
flags = {{ flags }},
tag = '{{ tag }}'
WHERE
domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
AND type = '{{ type }}' --required
RETURNING
domain_record;
REPLACE examples
- domains_update_record
To update an existing record, send a PUT request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID. Any attribute valid for
the record type can be set to a new value for the record.
See the attribute table for details regarding record
types and their respective attributes.
REPLACE digitalocean.compute.domain_records
SET
type = '{{ type }}',
name = '{{ name }}',
data = '{{ data }}',
priority = {{ priority }},
port = {{ port }},
ttl = {{ ttl }},
weight = {{ weight }},
flags = {{ flags }},
tag = '{{ tag }}'
WHERE
domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
AND type = '{{ type }}' --required
RETURNING
domain_record;
DELETE examples
- domains_delete_record
To delete a record for a domain, send a DELETE request to/v2/domains/$DOMAIN_NAME/records/$DOMAIN_RECORD_ID.
The record will be deleted and the response status will be a 204. This
indicates a successful request with no body returned.
DELETE FROM digitalocean.compute.domain_records
WHERE domain_name = '{{ domain_name }}' --required
AND domain_record_id = '{{ domain_record_id }}' --required
;