Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions specification/resources/databases/databases_create_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ requestBody:
size: db-s-2vcpu-4gb
num_nodes: 2

Create a New Database Cluster with service CNAMEs:
value:
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"

responses:
"201":
$ref: "responses/database_cluster.yml"
Expand Down
23 changes: 18 additions & 5 deletions specification/resources/databases/databases_create_replica.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,24 @@ requestBody:
- name
- size

example:
name: read-nyc3-01
region: nyc3
size: db-s-2vcpu-4gb
storage_size_mib: 61440
examples:
Create a Read-only Replica:
value:
name: read-nyc3-01
region: nyc3
size: db-s-2vcpu-4gb
storage_size_mib: 61440

Create a Read-only Replica with service CNAMEs:
value:
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"

responses:
'201':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name": "backend", "engine": "pg", "version": "14", "region": "nyc3", "size": "db-s-2vcpu-4gb", "num_nodes": 2, "storage_size_mib": 61440, "tags": ["production"]}' \
-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"]}}' \
"https://api.digitalocean.com/v2/databases"
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name":"read-nyc3-01", "region":"nyc3", "size": "db-s-2vcpu-4gb", "storage_size_mib": 61440}' \
-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"]}}' \
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/replicas"
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ source: |-
SizeSlug: "db-s-2vcpu-4gb",
NumNodes: 2,
StorageSizeMiB : 61440,
DOSettings: &godo.DOSettings{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to add this field to the DatabaseCreateRequest struct in godo later? It doesn’t seem to be there currently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a follow-up PR to digitalocean/godo will be needed to add the DOSettings field to DatabaseCreateRequest and DatabaseCreateReplicaRequest structs. This OpenAPI change needs to merge first, then we can update godo to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServiceCnames: []string{"db.example.com", "database.myapp.io"},
},
}

cluster, _, err := client.Databases.Create(ctx, createRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ source: |-
ctx := context.TODO()

replicaRequest := &godo.DatabaseCreateReplicaRequest{

Name: "read-nyc3-01",
Region: "nyc3",
Size: "db-s-2vcpu-4gb",
StorageSizeMiB : 61440,
StorageSizeMiB: 61440,
DOSettings: &godo.DOSettings{
ServiceCnames: []string{"replica-db.example.com", "read-replica.myapp.io"},
},
}

replica, _, err := client.Databases.CreateReplica(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", replicaRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ source: |-
"storage_size_mib": 61440,
"tags": [
"production"
]
],
"do_settings": {
"service_cnames": [
"db.example.com",
"database.myapp.io"
]
}
}
create_resp = client.databases.create_cluster(body=create_req)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ source: |-
"region": "nyc3",
"size": "db-s-2vcpu-4gb",
"storage_size_mib": 61440,
"do_settings": {
"service_cnames": [
"replica-db.example.com",
"read-replica.myapp.io"
]
}
}

create_resp = client.databases.create_replica(database_cluster_uuid="9cc10173", body=create_req)
5 changes: 5 additions & 0 deletions specification/resources/databases/models/database_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ properties:
description: >-
Autoscaling configuration for the database cluster. Currently only supports storage autoscaling. If null, autoscaling is
not configured for the cluster.
do_settings:
allOf:
- $ref: './do_settings.yml'
- description: >-
DigitalOcean-specific settings for the database cluster, including custom service CNAMEs.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ properties:
Public hostname and port of the cluster's metrics endpoint(s). Includes one record for the cluster's primary node and
a second entry for the cluster's standby node(s).
readOnly: true
do_settings:
allOf:
- $ref: './do_settings.yml'
- description: >-
DigitalOcean-specific settings for the database cluster, including custom service CNAMEs.



Expand Down
5 changes: 5 additions & 0 deletions specification/resources/databases/models/database_replica.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ properties:
description: >-
Additional storage added to the cluster, in MiB. If null, no additional storage is added to the cluster, beyond
what is provided as a base amount from the 'size' and any previously added additional storage.
do_settings:
allOf:
- $ref: './do_settings.yml'
- description: >-
DigitalOcean-specific settings for the read-only replica, including custom service CNAMEs.

required:
- name
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ properties:
description: >-
Additional storage added to the cluster, in MiB. If null, no additional storage is added to the cluster, beyond
what is provided as a base amount from the 'size' and any previously added additional storage.
do_settings:
allOf:
- $ref: './do_settings.yml'
- description: >-
DigitalOcean-specific settings for the read-only replica, including custom service CNAMEs.

required:
- name
20 changes: 20 additions & 0 deletions specification/resources/databases/models/do_settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: object

description: >-
DigitalOcean-specific settings for the database cluster.

properties:
service_cnames:
type: array
items:
type: string
pattern: '^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)+$'
maxLength: 253
maxItems: 16
example:
- "db.example.com"
- "database.myapp.io"
description: >-
An array of custom CNAMEs for the database cluster. Each CNAME must be a valid
RFC 1123 hostname (e.g., "db.example.com"). Maximum of 16 CNAMEs allowed, each
up to 253 characters.
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ content:
version_end_of_life: '2023-11-09T00:00:00Z'
version_end_of_availability: '2023-05-09T00:00:00Z'
storage_size_mib: 61440
do_settings:
service_cnames:
- "db.example.com"
- "database.myapp.io"
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ content:
region: nyc3
status: online
created_at: '2019-01-11T18:37:36Z'
do_settings:
service_cnames:
- "replica-db.example.com"
- "read-replica.myapp.io"