From ff19e005a09d912d1930a59bc496c55b4ea292ee Mon Sep 17 00:00:00 2001 From: Blesswin Samuel Date: Tue, 5 Nov 2024 19:57:22 +0530 Subject: [PATCH 1/3] APPS-9764 Add docs for restart API --- specification/DigitalOcean-public.v2.yaml | 4 ++ specification/resources/apps/apps_restart.yml | 45 +++++++++++++++++++ .../apps/examples/curl/apps_restart.yml | 6 +++ .../apps/examples/python/apps_restart.yml | 8 ++++ .../apps/models/apps_restart_request.yml | 10 +++++ 5 files changed, 73 insertions(+) create mode 100755 specification/resources/apps/apps_restart.yml create mode 100644 specification/resources/apps/examples/curl/apps_restart.yml create mode 100644 specification/resources/apps/examples/python/apps_restart.yml create mode 100755 specification/resources/apps/models/apps_restart_request.yml diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index ff8df2f4..18b7ef35 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -549,6 +549,10 @@ paths: put: $ref: 'resources/apps/apps_update.yml' + /v2/apps/{app_id}/restart: + post: + $ref: 'resources/apps/apps_restart.yml' + /v2/apps/{app_id}/components/{component_name}/logs: get: $ref: 'resources/apps/apps_get_logs_active_deployment.yml' diff --git a/specification/resources/apps/apps_restart.yml b/specification/resources/apps/apps_restart.yml new file mode 100755 index 00000000..b1f7d2b7 --- /dev/null +++ b/specification/resources/apps/apps_restart.yml @@ -0,0 +1,45 @@ +operationId: apps_restart + +summary: Restart an App + +description: Perform a rolling restart of all or specific components in an app. + +tags: + - Apps + +parameters: + - $ref: parameters.yml#/app_id + +requestBody: + content: + application/json: + schema: + $ref: models/apps_restart_request.yml + required: true + +responses: + "200": + $ref: responses/new_app_deployment.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/apps_restart.yml" + - $ref: "examples/python/apps_restart.yml" + +security: + - bearer_auth: + - "app:create" diff --git a/specification/resources/apps/examples/curl/apps_restart.yml b/specification/resources/apps/examples/curl/apps_restart.yml new file mode 100644 index 00000000..467323f0 --- /dev/null +++ b/specification/resources/apps/examples/curl/apps_restart.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/apps/{app_id}/restart" diff --git a/specification/resources/apps/examples/python/apps_restart.yml b/specification/resources/apps/examples/python/apps_restart.yml new file mode 100644 index 00000000..6c979bca --- /dev/null +++ b/specification/resources/apps/examples/python/apps_restart.yml @@ -0,0 +1,8 @@ +lang: Python +source: |- + import os + from pydo import Client + + client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) + + create_resp = client.apps.restart(app_id="b6bdf840", body={"components": ["component1", "component2"]}) diff --git a/specification/resources/apps/models/apps_restart_request.yml b/specification/resources/apps/models/apps_restart_request.yml new file mode 100755 index 00000000..915e2b7a --- /dev/null +++ b/specification/resources/apps/models/apps_restart_request.yml @@ -0,0 +1,10 @@ +type: object +properties: + components: + title: Optional list of components to restart. If not provided, all components will be restarted. + type: array + items: + type: string + example: + - component1 + - component2 From bed6fbd9e4cd267b821b21f3a8d57e97d9b2b07e Mon Sep 17 00:00:00 2001 From: Blesswin Samuel Date: Tue, 5 Nov 2024 20:24:21 +0530 Subject: [PATCH 2/3] remove required --- specification/resources/apps/apps_restart.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/resources/apps/apps_restart.yml b/specification/resources/apps/apps_restart.yml index b1f7d2b7..6c402a31 100755 --- a/specification/resources/apps/apps_restart.yml +++ b/specification/resources/apps/apps_restart.yml @@ -15,7 +15,6 @@ requestBody: application/json: schema: $ref: models/apps_restart_request.yml - required: true responses: "200": From 49afd08e5d4b2b57c913dcb6a2cf9bbb94362445 Mon Sep 17 00:00:00 2001 From: Blesswin Samuel Date: Tue, 5 Nov 2024 22:24:10 +0530 Subject: [PATCH 3/3] add "restart" to valid POST paths to fix linter --- spectral/functions/validateOpIDNaming.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spectral/functions/validateOpIDNaming.js b/spectral/functions/validateOpIDNaming.js index 80210c8a..8556bfc6 100644 --- a/spectral/functions/validateOpIDNaming.js +++ b/spectral/functions/validateOpIDNaming.js @@ -10,7 +10,7 @@ const GET = ["get", "list"]; 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"]; + "destroy", "delete", "update", "attach", "revert", "commit", "restart"]; const PUT = ["update", "promote", "install"]; const articles = ["_a_", "_an_", "_the_"]