Skip to main content

keys

Creates, updates, deletes, gets or lists a keys resource.

Overview

Namekeys
TypeResource
Iddigitalocean.spaces.keys

Fields

The following fields are returned by SELECT queries:

A JSON response containing details about the key.

NameDatatypeDescription
namestringThe access key's name. (example: my-access-key)
access_keystringThe Access Key ID used to access a bucket. (example: DOACCESSKEYEXAMPLE)
created_atstring (date-time)The date and time the key was created. (example: 2018-07-19T15:04:16Z)
grantsarrayThe list of permissions for the access key.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
spaces_key_getselectaccess_keyTo get a Spaces Access Key, send a GET request to /v2/spaces/keys/$ACCESS_KEY.

A successful request will return the Access Key.
spaces_key_listselectper_page, page, sort, sort_direction, name, bucket, permissionTo list Spaces Access Key, send a GET request to /v2/spaces/keys. Sort parameter must be used with Sort Direction.
spaces_key_createinsertTo create a new Spaces Access Key, send a POST request to /v2/spaces/keys.
At the moment, you cannot mix a fullaccess permission with scoped permissions.
A fullaccess permission will be prioritized if fullaccess and scoped permissions are both added.
spaces_key_patchupdateaccess_keyTo update Spaces Access Key, send a PUT or PATCH request to /v2/spaces/keys/$ACCESS_KEY. At the moment, you cannot convert a
fullaccess key to a scoped key or vice versa. You can only update the name of the key.
spaces_key_updatereplaceaccess_keyTo update Spaces Access Key, send a PUT or PATCH request to /v2/spaces/keys/$ACCESS_KEY. At the moment, you cannot convert a
fullaccess key to a scoped key or vice versa. You can only update the name of the key.
spaces_key_deletedeleteaccess_keyTo delete a Spaces Access Key, send a DELETE request to /v2/spaces/keys/$ACCESS_KEY.

A successful request will return a 204 No Content status code.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
access_keystringThe access key's ID. (example: DOACCESSKEYEXAMPLE)
bucketstringThe bucket's name. (example: my-bucket)
namestringThe access key's name. (example: my-access-key)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)
permissionstringThe permission of the access key. Possible values are read, readwrite, fullaccess, or an empty string. (example: read)
sortstringThe field to sort by. (example: created_at)
sort_directionstringThe direction to sort by. Possible values are asc or desc. (example: desc)

SELECT examples

To get a Spaces Access Key, send a GET request to /v2/spaces/keys/$ACCESS_KEY.

A successful request will return the Access Key.

SELECT
name,
access_key,
created_at,
grants
FROM digitalocean.spaces.keys
WHERE access_key = '{{ access_key }}' -- required;

INSERT examples

To create a new Spaces Access Key, send a POST request to /v2/spaces/keys.
At the moment, you cannot mix a fullaccess permission with scoped permissions.
A fullaccess permission will be prioritized if fullaccess and scoped permissions are both added.

INSERT INTO digitalocean.spaces.keys (
data__name,
data__grants
)
SELECT
'{{ name }}',
'{{ grants }}'
RETURNING
key
;

UPDATE examples

To update Spaces Access Key, send a PUT or PATCH request to /v2/spaces/keys/$ACCESS_KEY. At the moment, you cannot convert a
fullaccess key to a scoped key or vice versa. You can only update the name of the key.

UPDATE digitalocean.spaces.keys
SET
data__name = '{{ name }}',
data__grants = '{{ grants }}'
WHERE
access_key = '{{ access_key }}' --required
RETURNING
key;

REPLACE examples

To update Spaces Access Key, send a PUT or PATCH request to /v2/spaces/keys/$ACCESS_KEY. At the moment, you cannot convert a
fullaccess key to a scoped key or vice versa. You can only update the name of the key.

REPLACE digitalocean.spaces.keys
SET
data__name = '{{ name }}',
data__grants = '{{ grants }}'
WHERE
access_key = '{{ access_key }}' --required
RETURNING
key;

DELETE examples

To delete a Spaces Access Key, send a DELETE request to /v2/spaces/keys/$ACCESS_KEY.

A successful request will return a 204 No Content status code.

DELETE FROM digitalocean.spaces.keys
WHERE access_key = '{{ access_key }}' --required;