Skip to content

Commit 8a97bd7

Browse files
Add do_settings.service_cnames support to Databases API (#1137)
This change adds support for custom service CNAMEs (do_settings.service_cnames) to the Managed Databases API for both cluster creation and read replica creation. Changes: - Add new do_settings.yml model with service_cnames array field - Add do_settings field to database_cluster and database_cluster_read models - Add do_settings field to database_replica and database_replica_read models - Update databases_create_cluster.yml with example using service_cnames - Update databases_create_replica.yml with example using service_cnames - Update response examples to include do_settings - Update curl, Go, and Python code examples The service_cnames field allows users to specify custom CNAMEs for their database clusters. Each CNAME must be a valid RFC 1123 hostname (e.g., "db.example.com"), with a maximum of 16 CNAMEs allowed, each up to 253 characters in length.
1 parent 375b304 commit 8a97bd7

15 files changed

Lines changed: 104 additions & 10 deletions

specification/resources/databases/databases_create_cluster.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ requestBody:
9494
size: db-s-2vcpu-4gb
9595
num_nodes: 2
9696

97+
Create a New Database Cluster with service CNAMEs:
98+
value:
99+
name: backend
100+
engine: pg
101+
version: "14"
102+
region: nyc3
103+
size: db-s-2vcpu-4gb
104+
num_nodes: 2
105+
storage_size_mib: 61440
106+
tags:
107+
- production
108+
do_settings:
109+
service_cnames:
110+
- "db.example.com"
111+
- "database.myapp.io"
112+
97113
responses:
98114
"201":
99115
$ref: "responses/database_cluster.yml"

specification/resources/databases/databases_create_replica.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,24 @@ requestBody:
3434
- name
3535
- size
3636

37-
example:
38-
name: read-nyc3-01
39-
region: nyc3
40-
size: db-s-2vcpu-4gb
41-
storage_size_mib: 61440
37+
examples:
38+
Create a Read-only Replica:
39+
value:
40+
name: read-nyc3-01
41+
region: nyc3
42+
size: db-s-2vcpu-4gb
43+
storage_size_mib: 61440
44+
45+
Create a Read-only Replica with service CNAMEs:
46+
value:
47+
name: read-nyc3-01
48+
region: nyc3
49+
size: db-s-2vcpu-4gb
50+
storage_size_mib: 61440
51+
do_settings:
52+
service_cnames:
53+
- "replica-db.example.com"
54+
- "read-replica.myapp.io"
4255

4356
responses:
4457
'201':

specification/resources/databases/examples/curl/databases_create_cluster.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ source: |-
33
curl -X POST \
44
-H "Content-Type: application/json" \
55
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6-
-d '{"name": "backend", "engine": "pg", "version": "14", "region": "nyc3", "size": "db-s-2vcpu-4gb", "num_nodes": 2, "storage_size_mib": 61440, "tags": ["production"]}' \
6+
-d '{"name": "backend", "engine": "pg", "version": "14", "region": "nyc3", "size": "db-s-2vcpu-4gb", "num_nodes": 2, "storage_size_mib": 61440, "tags": ["production"], "do_settings": {"service_cnames": ["db.example.com", "database.myapp.io"]}}' \
77
"https://api.digitalocean.com/v2/databases"

specification/resources/databases/examples/curl/databases_create_replica.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ source: |-
33
curl -X POST \
44
-H "Content-Type: application/json" \
55
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6-
-d '{"name":"read-nyc3-01", "region":"nyc3", "size": "db-s-2vcpu-4gb", "storage_size_mib": 61440}' \
6+
-d '{"name":"read-nyc3-01", "region":"nyc3", "size": "db-s-2vcpu-4gb", "storage_size_mib": 61440, "do_settings": {"service_cnames": ["replica-db.example.com", "read-replica.myapp.io"]}}' \
77
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/replicas"

specification/resources/databases/examples/go/databases_create_cluster.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ source: |-
2121
SizeSlug: "db-s-2vcpu-4gb",
2222
NumNodes: 2,
2323
StorageSizeMiB : 61440,
24+
DOSettings: &godo.DOSettings{
25+
ServiceCnames: []string{"db.example.com", "database.myapp.io"},
26+
},
2427
}
2528
2629
cluster, _, err := client.Databases.Create(ctx, createRequest)

specification/resources/databases/examples/go/databases_create_replica.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ source: |-
1414
ctx := context.TODO()
1515
1616
replicaRequest := &godo.DatabaseCreateReplicaRequest{
17-
1817
Name: "read-nyc3-01",
1918
Region: "nyc3",
2019
Size: "db-s-2vcpu-4gb",
21-
StorageSizeMiB : 61440,
20+
StorageSizeMiB: 61440,
21+
DOSettings: &godo.DOSettings{
22+
ServiceCnames: []string{"replica-db.example.com", "read-replica.myapp.io"},
23+
},
2224
}
2325
2426
replica, _, err := client.Databases.CreateReplica(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", replicaRequest)

specification/resources/databases/examples/python/databases_create_cluster.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ source: |-
1515
"storage_size_mib": 61440,
1616
"tags": [
1717
"production"
18-
]
18+
],
19+
"do_settings": {
20+
"service_cnames": [
21+
"db.example.com",
22+
"database.myapp.io"
23+
]
24+
}
1925
}
2026
2127
create_resp = client.databases.create_cluster(body=create_req)

specification/resources/databases/examples/python/databases_create_replica.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ source: |-
1010
"region": "nyc3",
1111
"size": "db-s-2vcpu-4gb",
1212
"storage_size_mib": 61440,
13+
"do_settings": {
14+
"service_cnames": [
15+
"replica-db.example.com",
16+
"read-replica.myapp.io"
17+
]
18+
}
1319
}
1420
1521
create_resp = client.databases.create_replica(database_cluster_uuid="9cc10173", body=create_req)

specification/resources/databases/models/database_cluster.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ properties:
177177
description: >-
178178
Autoscaling configuration for the database cluster. Currently only supports storage autoscaling. If null, autoscaling is
179179
not configured for the cluster.
180+
do_settings:
181+
allOf:
182+
- $ref: './do_settings.yml'
183+
- description: >-
184+
DigitalOcean-specific settings for the database cluster, including custom service CNAMEs.
180185
181186
182187

specification/resources/databases/models/database_cluster_read.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ properties:
171171
Public hostname and port of the cluster's metrics endpoint(s). Includes one record for the cluster's primary node and
172172
a second entry for the cluster's standby node(s).
173173
readOnly: true
174+
do_settings:
175+
allOf:
176+
- $ref: './do_settings.yml'
177+
- description: >-
178+
DigitalOcean-specific settings for the database cluster, including custom service CNAMEs.
174179
175180
176181

0 commit comments

Comments
 (0)