From 21e0351cfb308fca525c614ca854ae9921545ad7 Mon Sep 17 00:00:00 2001 From: vsharma6855 Date: Tue, 17 Sep 2024 20:07:13 +0530 Subject: [PATCH] DBaaS | Add API endpoint for applying cluster patches (#909) * [DBAAS-35] | Add API endpoint for applying cluster patches * Update specification/resources/databases/databases_update_installUpdate.yml Co-authored-by: Andrew Starr-Bochicchio * Update specification/resources/databases/databases_update_installUpdate.yml Co-authored-by: danaelhe <42972711+danaelhe@users.noreply.github.com> * changed the structure * Add 'install' to linter rules for allowed operation names. --------- Co-authored-by: v.sharma Co-authored-by: Andrew Starr-Bochicchio Co-authored-by: danaelhe <42972711+danaelhe@users.noreply.github.com> Co-authored-by: Andrew Starr-Bochicchio --- specification/DigitalOcean-public.v2.yaml | 4 ++ .../databases_update_installUpdate.yml | 45 +++++++++++++++++++ .../curl/databases_update_installUpdate.yml | 6 +++ .../go/databases_update_installUpdate.yml | 17 +++++++ .../python/databases_update_installUpdate.yml | 8 ++++ spectral/functions/validateOpIDNaming.js | 2 +- 6 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 specification/resources/databases/databases_update_installUpdate.yml create mode 100644 specification/resources/databases/examples/curl/databases_update_installUpdate.yml create mode 100644 specification/resources/databases/examples/go/databases_update_installUpdate.yml create mode 100644 specification/resources/databases/examples/python/databases_update_installUpdate.yml diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index 6315c24e..3b95f938 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -735,6 +735,10 @@ paths: put: $ref: 'resources/databases/databases_update_maintenanceWindow.yml' + /v2/databases/{database_cluster_uuid}/install_update: + put: + $ref: 'resources/databases/databases_update_installUpdate.yml' + /v2/databases/{database_cluster_uuid}/backups: get: $ref: 'resources/databases/databases_list_backups.yml' diff --git a/specification/resources/databases/databases_update_installUpdate.yml b/specification/resources/databases/databases_update_installUpdate.yml new file mode 100644 index 00000000..8345f9c5 --- /dev/null +++ b/specification/resources/databases/databases_update_installUpdate.yml @@ -0,0 +1,45 @@ +operationId: databases_install_update + +summary: Start Database Maintenance + +description: >- + To start the installation of updates for a + database cluster, send a PUT request to + `/v2/databases/$DATABASE_ID/install_update`. + + A successful request will receive a 204 No Content status code with no body + in response. + +tags: + - Databases + +parameters: + - $ref: 'parameters.yml#/database_cluster_uuid' + +responses: + '204': + $ref: '../../shared/responses/no_content.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_update_installUpdate.yml' + - $ref: 'examples/go/databases_update_installUpdate.yml' + - $ref: 'examples/python/databases_update_installUpdate.yml' + +security: + - bearer_auth: + - 'database:update' diff --git a/specification/resources/databases/examples/curl/databases_update_installUpdate.yml b/specification/resources/databases/examples/curl/databases_update_installUpdate.yml new file mode 100644 index 00000000..2777446f --- /dev/null +++ b/specification/resources/databases/examples/curl/databases_update_installUpdate.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X PUT \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/install_update" diff --git a/specification/resources/databases/examples/go/databases_update_installUpdate.yml b/specification/resources/databases/examples/go/databases_update_installUpdate.yml new file mode 100644 index 00000000..451c21eb --- /dev/null +++ b/specification/resources/databases/examples/go/databases_update_installUpdate.yml @@ -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() + + _, err := client.Databases.InstallUpdate(ctx, "88055188-9e54-4f21-ab11-8a918ed79ee2") + } diff --git a/specification/resources/databases/examples/python/databases_update_installUpdate.yml b/specification/resources/databases/examples/python/databases_update_installUpdate.yml new file mode 100644 index 00000000..2105a112 --- /dev/null +++ b/specification/resources/databases/examples/python/databases_update_installUpdate.yml @@ -0,0 +1,8 @@ +lang: Python +source: |- + import os + from pydo import Client + + client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) + + update_resp = client.databases.install_update(database_cluster_uuid="a7a8bas") diff --git a/spectral/functions/validateOpIDNaming.js b/spectral/functions/validateOpIDNaming.js index fa95aac6..80210c8a 100644 --- a/spectral/functions/validateOpIDNaming.js +++ b/spectral/functions/validateOpIDNaming.js @@ -11,7 +11,7 @@ const PATCH = ["patch"]; const POST = ["create", "post", "add", "tag", "install", "reset", "upgrade", "recycle", "run", "retry", "validate", "assign", "unassign", "cancel", "list", "destroy", "delete", "update", "attach", "revert", "commit"]; -const PUT = ["update", "promote"]; +const PUT = ["update", "promote", "install"]; const articles = ["_a_", "_an_", "_the_"]