From b6d1cd477c4ebeaa7059e9a471ac22b160ef8f8e Mon Sep 17 00:00:00 2001 From: "v.sharma" Date: Sun, 8 Sep 2024 16:02:07 +0530 Subject: [PATCH 1/5] [DBAAS-35] | Add API endpoint for applying cluster patches --- specification/DigitalOcean-public.v2.yaml | 4 ++ .../databases_update_installUpdate.yml | 47 +++++++++++++++++++ .../curl/databases_update_installUpdate.yml | 6 +++ .../go/databases_update_installUpdate.yml | 17 +++++++ .../python/databases_update_installUpdate.yml | 8 ++++ 5 files changed, 82 insertions(+) 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 8fa492bd..55a556a8 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..15d32fa6 --- /dev/null +++ b/specification/resources/databases/databases_update_installUpdate.yml @@ -0,0 +1,47 @@ +operationId: databases_update_installUpdate + +summary: Start Database Maintenance + +description: >- + To start the installation of updates now 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..555d1fe6 --- /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", nil) + } 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..ed5e24cd --- /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.update_install_update(database_cluster_uuid="a7a8bas", body=None) From 2f1a158535bd1d36efb63d45d4e65c6415759e59 Mon Sep 17 00:00:00 2001 From: vsharma6855 Date: Tue, 17 Sep 2024 17:07:54 +0530 Subject: [PATCH 2/5] Update specification/resources/databases/databases_update_installUpdate.yml Co-authored-by: Andrew Starr-Bochicchio --- .../resources/databases/databases_update_installUpdate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/resources/databases/databases_update_installUpdate.yml b/specification/resources/databases/databases_update_installUpdate.yml index 15d32fa6..828b2800 100644 --- a/specification/resources/databases/databases_update_installUpdate.yml +++ b/specification/resources/databases/databases_update_installUpdate.yml @@ -1,4 +1,4 @@ -operationId: databases_update_installUpdate +operationId: databases_install_update summary: Start Database Maintenance From 7a3985b5f284048e4ad06c87f5e1a91bc4c51652 Mon Sep 17 00:00:00 2001 From: vsharma6855 Date: Tue, 17 Sep 2024 17:08:07 +0530 Subject: [PATCH 3/5] Update specification/resources/databases/databases_update_installUpdate.yml Co-authored-by: danaelhe <42972711+danaelhe@users.noreply.github.com> --- .../resources/databases/databases_update_installUpdate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/resources/databases/databases_update_installUpdate.yml b/specification/resources/databases/databases_update_installUpdate.yml index 828b2800..e8fd085b 100644 --- a/specification/resources/databases/databases_update_installUpdate.yml +++ b/specification/resources/databases/databases_update_installUpdate.yml @@ -3,7 +3,7 @@ operationId: databases_install_update summary: Start Database Maintenance description: >- - To start the installation of updates now for a + To start the installation of updates for a database cluster, send a PUT request to `/v2/databases/$DATABASE_ID/install_update`. From d7d24ae36d8d3fee5a9d3252a06323a8ed3ff046 Mon Sep 17 00:00:00 2001 From: "v.sharma" Date: Tue, 17 Sep 2024 18:31:41 +0530 Subject: [PATCH 4/5] changed the structure --- .../databases/examples/go/databases_update_installUpdate.yml | 2 +- .../examples/python/databases_update_installUpdate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/resources/databases/examples/go/databases_update_installUpdate.yml b/specification/resources/databases/examples/go/databases_update_installUpdate.yml index 555d1fe6..451c21eb 100644 --- a/specification/resources/databases/examples/go/databases_update_installUpdate.yml +++ b/specification/resources/databases/examples/go/databases_update_installUpdate.yml @@ -13,5 +13,5 @@ source: |- client := godo.NewFromToken(token) ctx := context.TODO() - _, err := client.Databases.InstallUpdate(ctx, "88055188-9e54-4f21-ab11-8a918ed79ee2", nil) + _, 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 index ed5e24cd..2105a112 100644 --- a/specification/resources/databases/examples/python/databases_update_installUpdate.yml +++ b/specification/resources/databases/examples/python/databases_update_installUpdate.yml @@ -5,4 +5,4 @@ source: |- client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) - update_resp = client.databases.update_install_update(database_cluster_uuid="a7a8bas", body=None) + update_resp = client.databases.install_update(database_cluster_uuid="a7a8bas") From e41ef07e319a3b74505140c43a88935fcb961c63 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Tue, 17 Sep 2024 10:34:21 -0400 Subject: [PATCH 5/5] Add 'install' to linter rules for allowed operation names. --- .../resources/databases/databases_update_installUpdate.yml | 2 -- spectral/functions/validateOpIDNaming.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/specification/resources/databases/databases_update_installUpdate.yml b/specification/resources/databases/databases_update_installUpdate.yml index e8fd085b..8345f9c5 100644 --- a/specification/resources/databases/databases_update_installUpdate.yml +++ b/specification/resources/databases/databases_update_installUpdate.yml @@ -16,8 +16,6 @@ tags: parameters: - $ref: 'parameters.yml#/database_cluster_uuid' - - responses: '204': $ref: '../../shared/responses/no_content.yml' 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_"]