Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spaces Key API #958

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,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.

Expand Down Expand Up @@ -1630,6 +1636,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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
72 changes: 72 additions & 0 deletions specification/resources/spaces/key_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
operationId: spacesKey_create

summary: "[Beta] 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'

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

security:
- bearer_auth:
- 'spaces_key:create_credentials'
38 changes: 38 additions & 0 deletions specification/resources/spaces/key_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
operationId: spacesKey_delete

summary: "[Beta] 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'

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

security:
- bearer_auth:
- 'spaces_key:delete'
41 changes: 41 additions & 0 deletions specification/resources/spaces/key_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
operationId: spacesKey_list

summary: "[Beta] 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'

lee-aaron marked this conversation as resolved.
Show resolved Hide resolved
x-codeSamples:
- $ref: 'examples/curl/spaces_key_list.yml'

security:
- bearer_auth:
- 'spaces_key:read'
46 changes: 46 additions & 0 deletions specification/resources/spaces/key_patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
operationId: spacesKey_patch

summary: "[Beta] 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'

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

security:
- bearer_auth:
- 'spaces_key:update'
46 changes: 46 additions & 0 deletions specification/resources/spaces/key_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
operationId: spacesKey_update

summary: "[Beta] 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'

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

security:
- bearer_auth:
- 'spaces_key:update'
16 changes: 16 additions & 0 deletions specification/resources/spaces/models/grant.yml
Original file line number Diff line number Diff line change
@@ -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. Possible values are `read`, `readwrite`, `fullaccess`, or an empty string.
example: read

required:
- bucket
- permission
39 changes: 39 additions & 0 deletions specification/resources/spaces/models/key_create_response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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
14 changes: 14 additions & 0 deletions specification/resources/spaces/models/key_request.yml
Original file line number Diff line number Diff line change
@@ -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: []
Loading
Loading