From 87cc947b4c9dc426b8e05443fed0ad760f6fb882 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Thu, 12 Dec 2024 10:09:07 -0800 Subject: [PATCH 1/7] Add Spaces Key API --- specification/DigitalOcean-public.v2.yaml | 23 +++++++ specification/resources/spaces/key_create.yml | 69 +++++++++++++++++++ specification/resources/spaces/key_delete.yml | 35 ++++++++++ specification/resources/spaces/key_list.yml | 38 ++++++++++ specification/resources/spaces/key_patch.yml | 43 ++++++++++++ specification/resources/spaces/key_update.yml | 43 ++++++++++++ .../resources/spaces/models/grant.yml | 16 +++++ .../spaces/models/key_create_response.yml | 37 ++++++++++ .../resources/spaces/models/key_request.yml | 14 ++++ .../resources/spaces/models/key_response.yml | 31 +++++++++ specification/resources/spaces/parameters.yml | 59 ++++++++++++++++ .../resources/spaces/responses/key_create.yml | 27 ++++++++ .../resources/spaces/responses/key_list.yml | 35 ++++++++++ .../resources/spaces/responses/key_update.yml | 26 +++++++ 14 files changed, 496 insertions(+) create mode 100644 specification/resources/spaces/key_create.yml create mode 100644 specification/resources/spaces/key_delete.yml create mode 100644 specification/resources/spaces/key_list.yml create mode 100644 specification/resources/spaces/key_patch.yml create mode 100644 specification/resources/spaces/key_update.yml create mode 100644 specification/resources/spaces/models/grant.yml create mode 100644 specification/resources/spaces/models/key_create_response.yml create mode 100644 specification/resources/spaces/models/key_request.yml create mode 100644 specification/resources/spaces/models/key_response.yml create mode 100644 specification/resources/spaces/parameters.yml create mode 100644 specification/resources/spaces/responses/key_create.yml create mode 100644 specification/resources/spaces/responses/key_list.yml create mode 100644 specification/resources/spaces/responses/key_update.yml diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index ea66dc4f..d529b9c4 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -461,6 +461,12 @@ tags: To interact with snapshots, you will generally send requests to the snapshots endpoint at `/v2/snapshots`. + - name: Spaces Keys + description: |- + Spaces keys are used to authenticate requests to DigitalOcean Spaces Buckets. By + sending requests to the `/v2/spaces/keys` endpoint, you can list, create, or + update, delete Spaces keys. + - name: SSH Keys description: Manage SSH keys available on your account. @@ -1600,6 +1606,23 @@ paths: delete: $ref: 'resources/snapshots/snapshots_delete.yml' + /v2/spaces/keys: + get: + $ref: 'resources/spaces/key_list.yml' + + post: + $ref: 'resources/spaces/key_create.yml' + + /v2/spaces/keys/{access_key}: + delete: + $ref: 'resources/spaces/key_delete.yml' + + put: + $ref: 'resources/spaces/key_update.yml' + + patch: + $ref: 'resources/spaces/key_patch.yml' + /v2/tags: get: $ref: 'resources/tags/tags_list.yml' diff --git a/specification/resources/spaces/key_create.yml b/specification/resources/spaces/key_create.yml new file mode 100644 index 00000000..69fc433f --- /dev/null +++ b/specification/resources/spaces/key_create.yml @@ -0,0 +1,69 @@ +operationId: key_create + +summary: Create a New Spaces Access Key + +description: | + To create a new Spaces Access Key, send a POST request to `/v2/spaces/keys`. + +tags: + - Spaces Keys + +requestBody: + required: true + + content: + application/json: + schema: + $ref: 'models/key_request.yml' + + examples: + Read Only Key: + value: + name: 'read-only-key' + grants: [{ "bucket": "my-bucket", "permission": "read" }] + + Read Write Key: + value: + name: 'read-write-key' + grants: [{ "bucket": "my-bucket", "permission": "readwrite" }] + + Full Access Key: + value: + name: 'full-access-key' + grants: [{ "bucket": "my-bucket", "permission": "fullaccess" }] + + Multiple Grants Key: + value: + name: 'multiple-grants-key' + grants: [ + { "bucket": "my-bucket", "permission": "read" }, + { "bucket": "my-bucket2", "permission": "readwrite" } + ] + + No Grant Key: + value: + name: 'no-grant-key' + grants: [] + +responses: + '201': + $ref: 'responses/key_create.yml' + + '400': + $ref: '../../shared/responses/bad_request.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' + +security: + - bearer_auth: + - 'spaces_key:create_credentials' diff --git a/specification/resources/spaces/key_delete.yml b/specification/resources/spaces/key_delete.yml new file mode 100644 index 00000000..0d9c69f2 --- /dev/null +++ b/specification/resources/spaces/key_delete.yml @@ -0,0 +1,35 @@ +operationId: key_delete + +summary: Delete a Spaces Access Key + +description: | + To delete a Spaces Access Key, send a DELETE request to `/v2/spaces/keys/$ACCESS_KEY`. + +tags: + - Spaces Keys + +parameters: + - $ref: 'parameters.yml#/access_key_name' + +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' + +security: + - bearer_auth: + - 'spaces_key:delete' diff --git a/specification/resources/spaces/key_list.yml b/specification/resources/spaces/key_list.yml new file mode 100644 index 00000000..cc3a3b40 --- /dev/null +++ b/specification/resources/spaces/key_list.yml @@ -0,0 +1,38 @@ +operationId: key_list + +summary: List Spaces Access Keys + +description: | + To list Spaces Access Key, send a GET request to `/v2/spaces/keys`. + +tags: + - Spaces Keys + +parameters: + - $ref: '../../shared/parameters.yml#/per_page' + - $ref: '../../shared/parameters.yml#/page' + - $ref: 'parameters.yml#/sort' + - $ref: 'parameters.yml#/sort_direction' + - $ref: 'parameters.yml#/name' + - $ref: 'parameters.yml#/bucket' + - $ref: 'parameters.yml#/permission' + +responses: + '200': + $ref: 'responses/key_list.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' + +security: + - bearer_auth: + - 'spaces_key:read' diff --git a/specification/resources/spaces/key_patch.yml b/specification/resources/spaces/key_patch.yml new file mode 100644 index 00000000..aeccb7a3 --- /dev/null +++ b/specification/resources/spaces/key_patch.yml @@ -0,0 +1,43 @@ +operationId: key_patch + +summary: Update Spaces Access Keys + +description: | + To update Spaces Access Key, send a PUT or PATCH request to `/v2/spaces/keys/$ACCESS_KEY`. + +tags: + - Spaces Keys + +parameters: + - $ref: 'parameters.yml#/access_key_name' + +requestBody: + required: true + + content: + application/json: + schema: + $ref: 'models/key_request.yml' + +responses: + '200': + $ref: 'responses/key_update.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' + +security: + - bearer_auth: + - 'spaces_key:update' diff --git a/specification/resources/spaces/key_update.yml b/specification/resources/spaces/key_update.yml new file mode 100644 index 00000000..32544ce5 --- /dev/null +++ b/specification/resources/spaces/key_update.yml @@ -0,0 +1,43 @@ +operationId: key_update + +summary: Update Spaces Access Keys + +description: | + To update Spaces Access Key, send a PUT or PATCH request to `/v2/spaces/keys/$ACCESS_KEY`. + +tags: + - Spaces Keys + +parameters: + - $ref: 'parameters.yml#/access_key_name' + +requestBody: + required: true + + content: + application/json: + schema: + $ref: 'models/key_request.yml' + +responses: + '200': + $ref: 'responses/key_update.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' + +security: + - bearer_auth: + - 'spaces_key:update' diff --git a/specification/resources/spaces/models/grant.yml b/specification/resources/spaces/models/grant.yml new file mode 100644 index 00000000..fe177ab8 --- /dev/null +++ b/specification/resources/spaces/models/grant.yml @@ -0,0 +1,16 @@ +type: object + +properties: + bucket: + type: string + description: The name of the bucket. + example: my-bucket + + permission: + type: string + description: The permission to grant to the user. + example: read + +required: +- bucket +- permission diff --git a/specification/resources/spaces/models/key_create_response.yml b/specification/resources/spaces/models/key_create_response.yml new file mode 100644 index 00000000..85646b9f --- /dev/null +++ b/specification/resources/spaces/models/key_create_response.yml @@ -0,0 +1,37 @@ +type: object + +properties: + name: + type: string + description: The name of your access key. + example: "my-access-key" + + grants: + type: array + description: The grants set to this access key. + items: + $ref: 'grant.yml' + default: [] + + access_key: + type: string + description: The access key. + example: DOACCESSKEYEXAMPLE + + secret_key: + type: string + description: The secret key. + example: DOSECRETKEYEXAMPLE + + created_at: + type: string + format: date-time + description: The date and time the key was created. + example: '2018-07-19T15:04:16Z' + +required: +- name +- grants +- access_key +- secret_key +- created_at diff --git a/specification/resources/spaces/models/key_request.yml b/specification/resources/spaces/models/key_request.yml new file mode 100644 index 00000000..449db4d9 --- /dev/null +++ b/specification/resources/spaces/models/key_request.yml @@ -0,0 +1,14 @@ +type: object + +properties: + name: + type: string + description: The name of your access key. + example: "my-access-key" + + grants: + type: array + description: The grants to set to this access key. + items: + $ref: 'grant.yml' + default: [] diff --git a/specification/resources/spaces/models/key_response.yml b/specification/resources/spaces/models/key_response.yml new file mode 100644 index 00000000..808da9d9 --- /dev/null +++ b/specification/resources/spaces/models/key_response.yml @@ -0,0 +1,31 @@ +type: object + +properties: + name: + type: string + description: The name of your access key. + example: "my-access-key" + + grants: + type: array + description: The grants set to this access key. + items: + $ref: 'grant.yml' + default: [] + + access_key: + type: string + description: The access key. + example: DOACCESSKEYEXAMPLE + + created_at: + type: string + format: date-time + description: The date and time the key was created. + example: '2018-07-19T15:04:16Z' + +required: +- name +- grants +- access_key +- created_at diff --git a/specification/resources/spaces/parameters.yml b/specification/resources/spaces/parameters.yml new file mode 100644 index 00000000..920ac980 --- /dev/null +++ b/specification/resources/spaces/parameters.yml @@ -0,0 +1,59 @@ +access_key_name: + in: path + name: access_key + description: The name of your access key. + required: true + schema: + type: string + default: "" + example: DOACCESSKEYEXAMPLE + +sort: + in: query + name: sort + required: false + description: The field to sort by. + schema: + type: string + default: "created_at" + example: created_at + +sort_direction: + in: query + name: sort_direction + required: false + description: The direction to sort by. + schema: + type: string + default: "desc" + example: desc + +name: + in: query + name: name + required: false + description: The name of the access key. + schema: + type: string + default: "" + example: my-access-key + +bucket: + in: query + name: bucket + required: false + description: The name of the bucket. + schema: + type: string + default: "" + example: my-bucket + +permission: + in: query + name: permission + required: false + description: The permission of the access key. + schema: + type: string + default: "" + example: read diff --git a/specification/resources/spaces/responses/key_create.yml b/specification/resources/spaces/responses/key_create.yml new file mode 100644 index 00000000..730fa191 --- /dev/null +++ b/specification/resources/spaces/responses/key_create.yml @@ -0,0 +1,27 @@ +description: >- + The response will be a JSON object + +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: + $ref: '../models/key_create_response.yml' + + examples: + Read Only Key: + value: + name: read-only-key + access_key: DOACCESSKEYEXAMPLE + secret_key: DOSECRETKEYEXAMPLE + grants: + - bucket: my-bucket + permission: read + created_at: '2018-07-19T15:04:16Z' diff --git a/specification/resources/spaces/responses/key_list.yml b/specification/resources/spaces/responses/key_list.yml new file mode 100644 index 00000000..a7017398 --- /dev/null +++ b/specification/resources/spaces/responses/key_list.yml @@ -0,0 +1,35 @@ +description: >- + The result will be a JSON object with a `keys` key. + +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: + allOf: + - type: object + properties: + keys: + type: array + items: + $ref: '../models/key_response.yml' + - $ref: '../../../shared/pages.yml#/pagination' + - $ref: '../../../shared/meta.yml' + + example: + keys: + - name: my-access-key + access_key: DOACCESSKEYEXAMPLE + grants: + - bucket: my-bucket + permission: read + created_at: '2018-07-19T15:04:16Z' + links: {} + meta: + total: 1 diff --git a/specification/resources/spaces/responses/key_update.yml b/specification/resources/spaces/responses/key_update.yml new file mode 100644 index 00000000..74f5565f --- /dev/null +++ b/specification/resources/spaces/responses/key_update.yml @@ -0,0 +1,26 @@ +description: >- + The response will be a JSON object + +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: + $ref: '../models/key_response.yml' + + examples: + Read Only Key: + value: + name: read-only-key + access_key: DOACCESSKEYEXAMPLE + grants: + - bucket: my-bucket + permission: read + created_at: '2018-07-19T15:04:16Z' From b6b3fd4fc7b070ba2a80f23432dd1f7a680b7117 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Thu, 2 Jan 2025 09:23:23 -0800 Subject: [PATCH 2/7] Fix Lint --- specification/resources/spaces/key_create.yml | 4 ++-- specification/resources/spaces/key_delete.yml | 4 ++-- specification/resources/spaces/key_list.yml | 4 ++-- specification/resources/spaces/key_patch.yml | 4 ++-- specification/resources/spaces/key_update.yml | 4 ++-- specification/resources/spaces/models/key_create_response.yml | 2 ++ specification/resources/spaces/models/key_response.yml | 2 ++ specification/resources/spaces/parameters.yml | 1 - specification/resources/spaces/responses/key_create.yml | 3 +-- specification/resources/spaces/responses/key_update.yml | 3 +-- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/specification/resources/spaces/key_create.yml b/specification/resources/spaces/key_create.yml index 69fc433f..235e1e78 100644 --- a/specification/resources/spaces/key_create.yml +++ b/specification/resources/spaces/key_create.yml @@ -1,6 +1,6 @@ -operationId: key_create +operationId: spacesKey_create -summary: Create a New Spaces Access Key +summary: "[Beta] Create a New Spaces Access Key" description: | To create a new Spaces Access Key, send a POST request to `/v2/spaces/keys`. diff --git a/specification/resources/spaces/key_delete.yml b/specification/resources/spaces/key_delete.yml index 0d9c69f2..487fcafe 100644 --- a/specification/resources/spaces/key_delete.yml +++ b/specification/resources/spaces/key_delete.yml @@ -1,6 +1,6 @@ -operationId: key_delete +operationId: spacesKey_delete -summary: Delete a Spaces Access Key +summary: "[Beta] Delete a Spaces Access Key" description: | To delete a Spaces Access Key, send a DELETE request to `/v2/spaces/keys/$ACCESS_KEY`. diff --git a/specification/resources/spaces/key_list.yml b/specification/resources/spaces/key_list.yml index cc3a3b40..72f873ed 100644 --- a/specification/resources/spaces/key_list.yml +++ b/specification/resources/spaces/key_list.yml @@ -1,6 +1,6 @@ -operationId: key_list +operationId: spacesKey_list -summary: List Spaces Access Keys +summary: "[Beta] List Spaces Access Keys" description: | To list Spaces Access Key, send a GET request to `/v2/spaces/keys`. diff --git a/specification/resources/spaces/key_patch.yml b/specification/resources/spaces/key_patch.yml index aeccb7a3..85e91327 100644 --- a/specification/resources/spaces/key_patch.yml +++ b/specification/resources/spaces/key_patch.yml @@ -1,6 +1,6 @@ -operationId: key_patch +operationId: spacesKey_patch -summary: Update Spaces Access Keys +summary: "[Beta] Update Spaces Access Keys" description: | To update Spaces Access Key, send a PUT or PATCH request to `/v2/spaces/keys/$ACCESS_KEY`. diff --git a/specification/resources/spaces/key_update.yml b/specification/resources/spaces/key_update.yml index 32544ce5..5c70908a 100644 --- a/specification/resources/spaces/key_update.yml +++ b/specification/resources/spaces/key_update.yml @@ -1,6 +1,6 @@ -operationId: key_update +operationId: spacesKey_update -summary: Update Spaces Access Keys +summary: "[Beta] Update Spaces Access Keys" description: | To update Spaces Access Key, send a PUT or PATCH request to `/v2/spaces/keys/$ACCESS_KEY`. diff --git a/specification/resources/spaces/models/key_create_response.yml b/specification/resources/spaces/models/key_create_response.yml index 85646b9f..0f7338fd 100644 --- a/specification/resources/spaces/models/key_create_response.yml +++ b/specification/resources/spaces/models/key_create_response.yml @@ -17,6 +17,7 @@ properties: type: string description: The access key. example: DOACCESSKEYEXAMPLE + readOnly: true secret_key: type: string @@ -28,6 +29,7 @@ properties: format: date-time description: The date and time the key was created. example: '2018-07-19T15:04:16Z' + readOnly: true required: - name diff --git a/specification/resources/spaces/models/key_response.yml b/specification/resources/spaces/models/key_response.yml index 808da9d9..ffe40e18 100644 --- a/specification/resources/spaces/models/key_response.yml +++ b/specification/resources/spaces/models/key_response.yml @@ -17,12 +17,14 @@ properties: type: string description: The access key. example: DOACCESSKEYEXAMPLE + readOnly: true created_at: type: string format: date-time description: The date and time the key was created. example: '2018-07-19T15:04:16Z' + readOnly: true required: - name diff --git a/specification/resources/spaces/parameters.yml b/specification/resources/spaces/parameters.yml index 920ac980..983993c8 100644 --- a/specification/resources/spaces/parameters.yml +++ b/specification/resources/spaces/parameters.yml @@ -5,7 +5,6 @@ access_key_name: required: true schema: type: string - default: "" example: DOACCESSKEYEXAMPLE sort: diff --git a/specification/resources/spaces/responses/key_create.yml b/specification/resources/spaces/responses/key_create.yml index 730fa191..987c5d64 100644 --- a/specification/resources/spaces/responses/key_create.yml +++ b/specification/resources/spaces/responses/key_create.yml @@ -12,8 +12,7 @@ headers: content: application/json: schema: - properties: - $ref: '../models/key_create_response.yml' + $ref: '../models/key_create_response.yml' examples: Read Only Key: diff --git a/specification/resources/spaces/responses/key_update.yml b/specification/resources/spaces/responses/key_update.yml index 74f5565f..fcc1d10d 100644 --- a/specification/resources/spaces/responses/key_update.yml +++ b/specification/resources/spaces/responses/key_update.yml @@ -12,8 +12,7 @@ headers: content: application/json: schema: - properties: - $ref: '../models/key_response.yml' + $ref: '../models/key_response.yml' examples: Read Only Key: From 982efa0cc307e35cdfbf5f3e3d5b3c883adaf20e Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Mon, 6 Jan 2025 18:41:37 -0800 Subject: [PATCH 3/7] Update permissions to be enums --- specification/resources/spaces/models/grant.yml | 5 +++++ specification/resources/spaces/parameters.yml | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/specification/resources/spaces/models/grant.yml b/specification/resources/spaces/models/grant.yml index fe177ab8..5721e8c1 100644 --- a/specification/resources/spaces/models/grant.yml +++ b/specification/resources/spaces/models/grant.yml @@ -9,6 +9,11 @@ properties: permission: type: string description: The permission to grant to the user. + enum: + - read + - readwrite + - fullaccess + - '' example: read required: diff --git a/specification/resources/spaces/parameters.yml b/specification/resources/spaces/parameters.yml index 983993c8..7df2286d 100644 --- a/specification/resources/spaces/parameters.yml +++ b/specification/resources/spaces/parameters.yml @@ -34,7 +34,6 @@ name: description: The name of the access key. schema: type: string - default: "" example: my-access-key bucket: @@ -44,7 +43,6 @@ bucket: description: The name of the bucket. schema: type: string - default: "" example: my-bucket permission: @@ -54,5 +52,9 @@ permission: description: The permission of the access key. schema: type: string - default: "" + enum: + - read + - readwrite + - fullaccess + - "" example: read From 51b5bb539a9b8e72cc3596315d3182a42d7a4372 Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Tue, 7 Jan 2025 11:17:48 -0800 Subject: [PATCH 4/7] Add curl examples --- .../resources/spaces/examples/curl/spaces_key_create.yml | 7 +++++++ .../resources/spaces/examples/curl/spaces_key_delete.yml | 6 ++++++ .../resources/spaces/examples/curl/spaces_key_list.yml | 6 ++++++ .../resources/spaces/examples/curl/spaces_key_patch.yml | 7 +++++++ .../resources/spaces/examples/curl/spaces_key_update.yml | 7 +++++++ specification/resources/spaces/key_create.yml | 3 +++ specification/resources/spaces/key_delete.yml | 3 +++ specification/resources/spaces/key_list.yml | 3 +++ specification/resources/spaces/key_patch.yml | 3 +++ specification/resources/spaces/key_update.yml | 3 +++ 10 files changed, 48 insertions(+) create mode 100644 specification/resources/spaces/examples/curl/spaces_key_create.yml create mode 100644 specification/resources/spaces/examples/curl/spaces_key_delete.yml create mode 100644 specification/resources/spaces/examples/curl/spaces_key_list.yml create mode 100644 specification/resources/spaces/examples/curl/spaces_key_patch.yml create mode 100644 specification/resources/spaces/examples/curl/spaces_key_update.yml diff --git a/specification/resources/spaces/examples/curl/spaces_key_create.yml b/specification/resources/spaces/examples/curl/spaces_key_create.yml new file mode 100644 index 00000000..b51ec52e --- /dev/null +++ b/specification/resources/spaces/examples/curl/spaces_key_create.yml @@ -0,0 +1,7 @@ +lang: cURL +source: |- + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -d '{"name": "test-key", "grants": [{"bucket": "test-bucket", "permission": "read"}]}' \ + "https://api.digitalocean.com/v2/spaces/keys" diff --git a/specification/resources/spaces/examples/curl/spaces_key_delete.yml b/specification/resources/spaces/examples/curl/spaces_key_delete.yml new file mode 100644 index 00000000..52c78970 --- /dev/null +++ b/specification/resources/spaces/examples/curl/spaces_key_delete.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X DELETE \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/spaces/keys/DOACCESSKEYEXAMPLE" diff --git a/specification/resources/spaces/examples/curl/spaces_key_list.yml b/specification/resources/spaces/examples/curl/spaces_key_list.yml new file mode 100644 index 00000000..df84f9d1 --- /dev/null +++ b/specification/resources/spaces/examples/curl/spaces_key_list.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/spaces/keys" diff --git a/specification/resources/spaces/examples/curl/spaces_key_patch.yml b/specification/resources/spaces/examples/curl/spaces_key_patch.yml new file mode 100644 index 00000000..6af8bb7f --- /dev/null +++ b/specification/resources/spaces/examples/curl/spaces_key_patch.yml @@ -0,0 +1,7 @@ +lang: cURL +source: |- + curl -X PATCH \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -d '{"name": "new-key-name"}' \ + "https://api.digitalocean.com/v2/spaces/keys/DOACCESSKEYEXAMPLE" diff --git a/specification/resources/spaces/examples/curl/spaces_key_update.yml b/specification/resources/spaces/examples/curl/spaces_key_update.yml new file mode 100644 index 00000000..06eb40c6 --- /dev/null +++ b/specification/resources/spaces/examples/curl/spaces_key_update.yml @@ -0,0 +1,7 @@ +lang: cURL +source: |- + curl -X PUT \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -d '{"name": "new-key-name"}' \ + "https://api.digitalocean.com/v2/spaces/keys/DOACCESSKEYEXAMPLE" diff --git a/specification/resources/spaces/key_create.yml b/specification/resources/spaces/key_create.yml index 235e1e78..d7810a96 100644 --- a/specification/resources/spaces/key_create.yml +++ b/specification/resources/spaces/key_create.yml @@ -64,6 +64,9 @@ responses: default: $ref: '../../shared/responses/unexpected_error.yml' +x-codeSamples: + - $ref: 'examples/curl/spaces_key_create.yml' + security: - bearer_auth: - 'spaces_key:create_credentials' diff --git a/specification/resources/spaces/key_delete.yml b/specification/resources/spaces/key_delete.yml index 487fcafe..1c1eba8a 100644 --- a/specification/resources/spaces/key_delete.yml +++ b/specification/resources/spaces/key_delete.yml @@ -30,6 +30,9 @@ responses: default: $ref: '../../shared/responses/unexpected_error.yml' +x-codeSamples: + - $ref: 'examples/curl/spaces_key_delete.yml' + security: - bearer_auth: - 'spaces_key:delete' diff --git a/specification/resources/spaces/key_list.yml b/specification/resources/spaces/key_list.yml index 72f873ed..89171ecd 100644 --- a/specification/resources/spaces/key_list.yml +++ b/specification/resources/spaces/key_list.yml @@ -33,6 +33,9 @@ responses: default: $ref: '../../shared/responses/unexpected_error.yml' +x-codeSamples: + - $ref: 'examples/curl/spaces_key_list.yml' + security: - bearer_auth: - 'spaces_key:read' diff --git a/specification/resources/spaces/key_patch.yml b/specification/resources/spaces/key_patch.yml index 85e91327..d28cbc1b 100644 --- a/specification/resources/spaces/key_patch.yml +++ b/specification/resources/spaces/key_patch.yml @@ -38,6 +38,9 @@ responses: default: $ref: '../../shared/responses/unexpected_error.yml' +x-codeSamples: + - $ref: 'examples/curl/spaces_key_patch.yml' + security: - bearer_auth: - 'spaces_key:update' diff --git a/specification/resources/spaces/key_update.yml b/specification/resources/spaces/key_update.yml index 5c70908a..1ba7ece5 100644 --- a/specification/resources/spaces/key_update.yml +++ b/specification/resources/spaces/key_update.yml @@ -38,6 +38,9 @@ responses: default: $ref: '../../shared/responses/unexpected_error.yml' +x-codeSamples: + - $ref: 'examples/curl/spaces_key_update.yml' + security: - bearer_auth: - 'spaces_key:update' From 5652218e33043f08c0029abb1b495e0074046d0f Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Tue, 7 Jan 2025 13:47:31 -0800 Subject: [PATCH 5/7] Fix grants --- specification/resources/spaces/models/grant.yml | 7 +------ specification/resources/spaces/parameters.yml | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/specification/resources/spaces/models/grant.yml b/specification/resources/spaces/models/grant.yml index 5721e8c1..35af33ec 100644 --- a/specification/resources/spaces/models/grant.yml +++ b/specification/resources/spaces/models/grant.yml @@ -8,12 +8,7 @@ properties: permission: type: string - description: The permission to grant to the user. - enum: - - read - - readwrite - - fullaccess - - '' + description: The permission to grant to the user. Possible values are `read`, `readwrite`, `fullaccess`, or an empty string. example: read required: diff --git a/specification/resources/spaces/parameters.yml b/specification/resources/spaces/parameters.yml index 7df2286d..7bf81ed9 100644 --- a/specification/resources/spaces/parameters.yml +++ b/specification/resources/spaces/parameters.yml @@ -49,12 +49,7 @@ permission: in: query name: permission required: false - description: The permission of the access key. + description: The permission of the access key. Possible values are `read`, `readwrite`, `fullaccess`, or an empty string. schema: type: string - enum: - - read - - readwrite - - fullaccess - - "" example: read From b2a596fe4b6ef1101772ae23b5703240b0adeaa3 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Wed, 8 Jan 2025 12:36:41 -0500 Subject: [PATCH 6/7] Dedup Spaces key model --- specification/resources/spaces/key_create.yml | 2 +- specification/resources/spaces/key_patch.yml | 2 +- specification/resources/spaces/key_update.yml | 2 +- .../models/{key_response.yml => key.yml} | 6 --- .../spaces/models/key_create_response.yml | 49 ++++--------------- .../resources/spaces/models/key_request.yml | 14 ------ .../resources/spaces/responses/key_list.yml | 2 +- .../resources/spaces/responses/key_update.yml | 2 +- 8 files changed, 15 insertions(+), 64 deletions(-) rename specification/resources/spaces/models/{key_response.yml => key.yml} (91%) delete mode 100644 specification/resources/spaces/models/key_request.yml diff --git a/specification/resources/spaces/key_create.yml b/specification/resources/spaces/key_create.yml index d7810a96..c13a52f0 100644 --- a/specification/resources/spaces/key_create.yml +++ b/specification/resources/spaces/key_create.yml @@ -14,7 +14,7 @@ requestBody: content: application/json: schema: - $ref: 'models/key_request.yml' + $ref: 'models/key.yml' examples: Read Only Key: diff --git a/specification/resources/spaces/key_patch.yml b/specification/resources/spaces/key_patch.yml index d28cbc1b..b654aac8 100644 --- a/specification/resources/spaces/key_patch.yml +++ b/specification/resources/spaces/key_patch.yml @@ -17,7 +17,7 @@ requestBody: content: application/json: schema: - $ref: 'models/key_request.yml' + $ref: 'models/key.yml' responses: '200': diff --git a/specification/resources/spaces/key_update.yml b/specification/resources/spaces/key_update.yml index 1ba7ece5..aec26d7e 100644 --- a/specification/resources/spaces/key_update.yml +++ b/specification/resources/spaces/key_update.yml @@ -17,7 +17,7 @@ requestBody: content: application/json: schema: - $ref: 'models/key_request.yml' + $ref: 'models/key.yml' responses: '200': diff --git a/specification/resources/spaces/models/key_response.yml b/specification/resources/spaces/models/key.yml similarity index 91% rename from specification/resources/spaces/models/key_response.yml rename to specification/resources/spaces/models/key.yml index ffe40e18..6648a404 100644 --- a/specification/resources/spaces/models/key_response.yml +++ b/specification/resources/spaces/models/key.yml @@ -25,9 +25,3 @@ properties: description: The date and time the key was created. example: '2018-07-19T15:04:16Z' readOnly: true - -required: -- name -- grants -- access_key -- created_at diff --git a/specification/resources/spaces/models/key_create_response.yml b/specification/resources/spaces/models/key_create_response.yml index 0f7338fd..5d7c7a92 100644 --- a/specification/resources/spaces/models/key_create_response.yml +++ b/specification/resources/spaces/models/key_create_response.yml @@ -1,39 +1,10 @@ -type: object - -properties: - name: - type: string - description: The name of your access key. - example: "my-access-key" - - grants: - type: array - description: The grants set to this access key. - items: - $ref: 'grant.yml' - default: [] - - access_key: - type: string - description: The access key. - example: DOACCESSKEYEXAMPLE - readOnly: true - - secret_key: - type: string - description: The secret key. - example: DOSECRETKEYEXAMPLE - - created_at: - type: string - format: date-time - description: The date and time the key was created. - example: '2018-07-19T15:04:16Z' - readOnly: true - -required: -- name -- grants -- access_key -- secret_key -- created_at +allOf: + - type: object + properties: + secret_key: + type: string + description: The secret key. This is the only time the secret key will be returned. + example: DOSECRETKEYEXAMPLE + readOnly: true + + - $ref: 'key.yml' \ No newline at end of file diff --git a/specification/resources/spaces/models/key_request.yml b/specification/resources/spaces/models/key_request.yml deleted file mode 100644 index 449db4d9..00000000 --- a/specification/resources/spaces/models/key_request.yml +++ /dev/null @@ -1,14 +0,0 @@ -type: object - -properties: - name: - type: string - description: The name of your access key. - example: "my-access-key" - - grants: - type: array - description: The grants to set to this access key. - items: - $ref: 'grant.yml' - default: [] diff --git a/specification/resources/spaces/responses/key_list.yml b/specification/resources/spaces/responses/key_list.yml index a7017398..d9c2b385 100644 --- a/specification/resources/spaces/responses/key_list.yml +++ b/specification/resources/spaces/responses/key_list.yml @@ -18,7 +18,7 @@ content: keys: type: array items: - $ref: '../models/key_response.yml' + $ref: '../models/key.yml' - $ref: '../../../shared/pages.yml#/pagination' - $ref: '../../../shared/meta.yml' diff --git a/specification/resources/spaces/responses/key_update.yml b/specification/resources/spaces/responses/key_update.yml index fcc1d10d..f03f978d 100644 --- a/specification/resources/spaces/responses/key_update.yml +++ b/specification/resources/spaces/responses/key_update.yml @@ -12,7 +12,7 @@ headers: content: application/json: schema: - $ref: '../models/key_response.yml' + $ref: '../models/key.yml' examples: Read Only Key: From 79b0cb6e6b5704def1ce08e3343479618b49a9ec Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Wed, 8 Jan 2025 13:27:21 -0800 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Andrew Starr-Bochicchio --- .../spaces/models/key_create_response.yml | 1 - .../resources/spaces/responses/key_create.yml | 19 +++++++++++-------- .../resources/spaces/responses/key_update.yml | 17 ++++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/specification/resources/spaces/models/key_create_response.yml b/specification/resources/spaces/models/key_create_response.yml index 71841aa9..38b142ed 100644 --- a/specification/resources/spaces/models/key_create_response.yml +++ b/specification/resources/spaces/models/key_create_response.yml @@ -8,4 +8,3 @@ allOf: readOnly: true - $ref: 'key.yml' - \ No newline at end of file diff --git a/specification/resources/spaces/responses/key_create.yml b/specification/resources/spaces/responses/key_create.yml index 987c5d64..4a2f4116 100644 --- a/specification/resources/spaces/responses/key_create.yml +++ b/specification/resources/spaces/responses/key_create.yml @@ -12,15 +12,18 @@ headers: content: application/json: schema: - $ref: '../models/key_create_response.yml' + properties: + key: + $ref: '../models/key_create_response.yml' examples: Read Only Key: value: - name: read-only-key - access_key: DOACCESSKEYEXAMPLE - secret_key: DOSECRETKEYEXAMPLE - grants: - - bucket: my-bucket - permission: read - created_at: '2018-07-19T15:04:16Z' + key: + name: read-only-key + access_key: DOACCESSKEYEXAMPLE + secret_key: DOSECRETKEYEXAMPLE + grants: + - bucket: my-bucket + permission: read + created_at: '2018-07-19T15:04:16Z' diff --git a/specification/resources/spaces/responses/key_update.yml b/specification/resources/spaces/responses/key_update.yml index f03f978d..3de853d7 100644 --- a/specification/resources/spaces/responses/key_update.yml +++ b/specification/resources/spaces/responses/key_update.yml @@ -12,14 +12,17 @@ headers: content: application/json: schema: - $ref: '../models/key.yml' + properties: + key: + $ref: '../models/key.yml' examples: Read Only Key: value: - name: read-only-key - access_key: DOACCESSKEYEXAMPLE - grants: - - bucket: my-bucket - permission: read - created_at: '2018-07-19T15:04:16Z' + key: + name: read-only-key + access_key: DOACCESSKEYEXAMPLE + grants: + - bucket: my-bucket + permission: read + created_at: '2018-07-19T15:04:16Z'