Skip to content

Commit

Permalink
Include DBaaS metrics endpoint operations (#859)
Browse files Browse the repository at this point in the history
* add metrics auth docs

* rm duplicate metrics endpoint definition

* split out basic auth obj

* add godo examples
  • Loading branch information
dwilsondo authored Mar 18, 2024
1 parent 479ee7b commit 2c75905
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 0 deletions.
6 changes: 6 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,12 @@ paths:
delete:
$ref: 'resources/databases/databases_delete_kafka_topic.yml'

/v2/databases/metrics/credentials:
get:
$ref: 'resources/databases/databases_get_cluster_metrics_credentials.yml'
put:
$ref: 'resources/databases/databases_update_cluster_metrics_credentials.yml'

/v2/domains:
get:
$ref: 'resources/domains/domains_list.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
operationId: databases_get_cluster_metrics_credentials

summary: Retrieve Database Clusters' Metrics Endpoint Credentials

description: >-
To show the credentials for all database clusters' metrics endpoints, send a GET request to
`/v2/databases/metrics/credentials`. The result will be a JSON object with a `credentials` key.
tags:
- Databases

responses:
'200':
$ref: 'responses/database_metrics_auth.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'404':
$ref: '../../shared/responses/not_found.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'

x-codeSamples:
- $ref: 'examples/curl/databases_get_cluster_metrics_credentials.yml'
- $ref: 'examples/go/databases_get_cluster_metrics_credentials.yml'

security:
- bearer_auth:
- 'write'

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
operationId: databases_update_cluster_metrics_credentials

summary: Update Database Clusters' Metrics Endpoint Credentials

description: >-
To update the credentials for all database clusters' metrics endpoints, send a PUT request to
`/v2/databases/metrics/credentials`. A successful request will receive a 204 No Content status code
with no body in response.
tags:
- Databases

requestBody:
content:
application/json:
schema:
allOf:
- $ref: 'models/database_metrics_credentials.yml'
example:
credentials:
basic_auth_username: "new_username"
basic_auth_password: "new_password"

responses:
'204':
$ref: '../../shared/responses/no_content.yml'

'401':
$ref: '../../shared/responses/unauthorized.yml'

'429':
$ref: '../../shared/responses/too_many_requests.yml'

'500':
$ref: '../../shared/responses/server_error.yml'

default:
$ref: '../../shared/responses/unexpected_error.yml'

x-codeSamples:
- $ref: 'examples/curl/databases_update_cluster_metrics_credentials.yml'
- $ref: 'examples/go/databases_update_cluster_metrics_credentials.yml'

security:
- bearer_auth:
- 'write'

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lang: cURL
source: |-
curl -X GET \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/databases/metrics/credentials"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: cURL
source: |-
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"credentials": {"basic_auth_username": "new_username", "basic_auth_password": "new_password"}}'\
"https://api.digitalocean.com/v2/databases/metrics/credentials"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
creds, _, _ := client.Databases.GetMetricsCredentials(ctx)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
lang: Go
source: |-
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
_, _ = client.Databases.UpdateMetricsCredentials(ctx, &godo.DatabaseUpdateMetricsCredentialsRequest{
Credentials: &godo.DatabaseMetricsCredentials{
BasicAuthUsername: "a_new_username",
BasicAuthPassword: "a_new_password",
},
})
}
9 changes: 9 additions & 0 deletions specification/resources/databases/models/database_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ 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.
metrics_endpoints:
type: array
items:
$ref: './database_service_endpoint.yml'
description: >-
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).
required:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: object

properties:
credentials:
$ref: "./databases_basic_auth_credentials.yml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type: object

properties:
host:
type: string
description: A FQDN pointing to the database cluster's node(s).
example: backend-do-user-19081923-0.db.ondigitalocean.com
readOnly: true
port:
type: integer
description: The port on which a service is listening.
example: 9273
readOnly: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object

properties:
basic_auth_username:
type: string
example: username
description: basic authentication username for metrics HTTP endpoint
basic_auth_password:
type: string
example: password
description: basic authentication password for metrics HTTP endpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: A JSON object with a key of `credentials`.

headers:
ratelimit-limit:
$ref: '../../../shared/headers.yml#/ratelimit-limit'
ratelimit-remaining:
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
ratelimit-reset:
$ref: '../../../shared/headers.yml#/ratelimit-reset'

content:
application/json:
schema:
properties:
credentials:
$ref: '../models/database_metrics_credentials.yml'
example:
credentials:
basic_auth_username: username
basic_auth_password: password

0 comments on commit 2c75905

Please sign in to comment.