Skip to content

Commit 2c75905

Browse files
authored
Include DBaaS metrics endpoint operations (#859)
* add metrics auth docs * rm duplicate metrics endpoint definition * split out basic auth obj * add godo examples
1 parent 479ee7b commit 2c75905

12 files changed

+202
-0
lines changed

Diff for: specification/DigitalOcean-public.v2.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,12 @@ paths:
840840
delete:
841841
$ref: 'resources/databases/databases_delete_kafka_topic.yml'
842842

843+
/v2/databases/metrics/credentials:
844+
get:
845+
$ref: 'resources/databases/databases_get_cluster_metrics_credentials.yml'
846+
put:
847+
$ref: 'resources/databases/databases_update_cluster_metrics_credentials.yml'
848+
843849
/v2/domains:
844850
get:
845851
$ref: 'resources/domains/domains_list.yml'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
operationId: databases_get_cluster_metrics_credentials
2+
3+
summary: Retrieve Database Clusters' Metrics Endpoint Credentials
4+
5+
description: >-
6+
To show the credentials for all database clusters' metrics endpoints, send a GET request to
7+
`/v2/databases/metrics/credentials`. The result will be a JSON object with a `credentials` key.
8+
9+
tags:
10+
- Databases
11+
12+
responses:
13+
'200':
14+
$ref: 'responses/database_metrics_auth.yml'
15+
16+
'401':
17+
$ref: '../../shared/responses/unauthorized.yml'
18+
19+
'404':
20+
$ref: '../../shared/responses/not_found.yml'
21+
22+
'429':
23+
$ref: '../../shared/responses/too_many_requests.yml'
24+
25+
'500':
26+
$ref: '../../shared/responses/server_error.yml'
27+
28+
default:
29+
$ref: '../../shared/responses/unexpected_error.yml'
30+
31+
x-codeSamples:
32+
- $ref: 'examples/curl/databases_get_cluster_metrics_credentials.yml'
33+
- $ref: 'examples/go/databases_get_cluster_metrics_credentials.yml'
34+
35+
security:
36+
- bearer_auth:
37+
- 'write'
38+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
operationId: databases_update_cluster_metrics_credentials
2+
3+
summary: Update Database Clusters' Metrics Endpoint Credentials
4+
5+
description: >-
6+
To update the credentials for all database clusters' metrics endpoints, send a PUT request to
7+
`/v2/databases/metrics/credentials`. A successful request will receive a 204 No Content status code
8+
with no body in response.
9+
10+
tags:
11+
- Databases
12+
13+
requestBody:
14+
content:
15+
application/json:
16+
schema:
17+
allOf:
18+
- $ref: 'models/database_metrics_credentials.yml'
19+
example:
20+
credentials:
21+
basic_auth_username: "new_username"
22+
basic_auth_password: "new_password"
23+
24+
responses:
25+
'204':
26+
$ref: '../../shared/responses/no_content.yml'
27+
28+
'401':
29+
$ref: '../../shared/responses/unauthorized.yml'
30+
31+
'429':
32+
$ref: '../../shared/responses/too_many_requests.yml'
33+
34+
'500':
35+
$ref: '../../shared/responses/server_error.yml'
36+
37+
default:
38+
$ref: '../../shared/responses/unexpected_error.yml'
39+
40+
x-codeSamples:
41+
- $ref: 'examples/curl/databases_update_cluster_metrics_credentials.yml'
42+
- $ref: 'examples/go/databases_update_cluster_metrics_credentials.yml'
43+
44+
security:
45+
- bearer_auth:
46+
- 'write'
47+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
5+
"https://api.digitalocean.com/v2/databases/metrics/credentials"
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
lang: cURL
2+
source: |-
3+
curl -X PUT \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
-d '{"credentials": {"basic_auth_username": "new_username", "basic_auth_password": "new_password"}}'\
7+
"https://api.digitalocean.com/v2/databases/metrics/credentials"
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
lang: Go
2+
source: |-
3+
import (
4+
"context"
5+
"os"
6+
7+
"github.com/digitalocean/godo"
8+
)
9+
10+
func main() {
11+
token := os.Getenv("DIGITALOCEAN_TOKEN")
12+
13+
client := godo.NewFromToken(token)
14+
ctx := context.TODO()
15+
16+
creds, _, _ := client.Databases.GetMetricsCredentials(ctx)
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
lang: Go
2+
source: |-
3+
import (
4+
"context"
5+
"os"
6+
7+
"github.com/digitalocean/godo"
8+
)
9+
10+
func main() {
11+
token := os.Getenv("DIGITALOCEAN_TOKEN")
12+
13+
client := godo.NewFromToken(token)
14+
ctx := context.TODO()
15+
16+
_, _ = client.Databases.UpdateMetricsCredentials(ctx, &godo.DatabaseUpdateMetricsCredentialsRequest{
17+
Credentials: &godo.DatabaseMetricsCredentials{
18+
BasicAuthUsername: "a_new_username",
19+
BasicAuthPassword: "a_new_password",
20+
},
21+
})
22+
}

Diff for: specification/resources/databases/models/database_cluster.yml

+9
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ properties:
147147
description: >-
148148
Additional storage added to the cluster, in MiB. If null, no additional storage is added to the cluster, beyond
149149
what is provided as a base amount from the 'size' and any previously added additional storage.
150+
metrics_endpoints:
151+
type: array
152+
items:
153+
$ref: './database_service_endpoint.yml'
154+
description: >-
155+
Public hostname and port of the cluster's metrics endpoint(s). Includes one record for the cluster's primary node and
156+
a second entry for the cluster's standby node(s).
157+
158+
150159
151160
152161
required:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: object
2+
3+
properties:
4+
credentials:
5+
$ref: "./databases_basic_auth_credentials.yml"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: object
2+
3+
properties:
4+
host:
5+
type: string
6+
description: A FQDN pointing to the database cluster's node(s).
7+
example: backend-do-user-19081923-0.db.ondigitalocean.com
8+
readOnly: true
9+
port:
10+
type: integer
11+
description: The port on which a service is listening.
12+
example: 9273
13+
readOnly: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type: object
2+
3+
properties:
4+
basic_auth_username:
5+
type: string
6+
example: username
7+
description: basic authentication username for metrics HTTP endpoint
8+
basic_auth_password:
9+
type: string
10+
example: password
11+
description: basic authentication password for metrics HTTP endpoint
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
description: A JSON object with a key of `credentials`.
2+
3+
headers:
4+
ratelimit-limit:
5+
$ref: '../../../shared/headers.yml#/ratelimit-limit'
6+
ratelimit-remaining:
7+
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
8+
ratelimit-reset:
9+
$ref: '../../../shared/headers.yml#/ratelimit-reset'
10+
11+
content:
12+
application/json:
13+
schema:
14+
properties:
15+
credentials:
16+
$ref: '../models/database_metrics_credentials.yml'
17+
example:
18+
credentials:
19+
basic_auth_username: username
20+
basic_auth_password: password

0 commit comments

Comments
 (0)