跳到主要内容
Reincubate

Keys

发布于 2019年6月27日· 更新于 2022年11月15日

Cover image for: Keys

A key gives access to the API at the organisation level via its token attribute. It is allowed to interact with all API endpoints on behalf of its organisation.

A key is generated for each newly created organisation.

Attributes

nametypedescription
idkey IDResource identifier.
resourcestring, always keyResource type specifier.
organisationorganisation IDThe organisation this key belongs to.
typestringOne of: standard, trial.
confignested objectKey-specific configuration settings.
storage_configoptional, storage config IDThe storage config used by the key.
webhook_configoptional, webhook config IDThe webhook config used by the key.
tokenstringThe auth material for this key. Is used to populate the AUTHORIZATION HTTP header in requests against the API.
statestringOne of: active, deactivated, blocked, expired.
date_createddatetimeWhen the resource was created.
date_expiresoptional, datetimeWhen the key will expire. Mainly applies to trial type keys.

Types

standard : the key type. Every organisation has at least one of these.

trial : a key generated by an API administrator to give the organisation trial access to additional permissions. These will typically have the date_expires field set.

Configuration

Key-level configuration can be set on the config attribute of the key. For the moment, this only accepts publish_source_files, related to the source file publishing mechanism.

Storage and webhook configs

A key resource can override the organisation default values for storage and webhook config. This can be helpful to split results and event notification between environments like dev and production.

Token

The value of a key's token attribute can be used to authenticate against the API on behalf of the owning organisation.

These values should be stored securely and never exposed publicly.

State

active : the key's standard state.

deactivated : the owning organisation has disabled the key.

blocked : the key has been disabled by an API admin.

expired : the key is disabled as the trial period has passed.

Create POST /keys

Parameters

nametypedescription
storage_configstorage config IDOverride the organisation's default storage config on this key.
webhook_configwebhook config IDOverride the organisation's default webhook config on this key.

Using cURL

curl 'https://ricloud-api.reincubate.com/keys' \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "storage_config": 2,
}'

Using ricloud-py

import ricloud

key = ricloud.Key.create(storage_config=2)

# OR

storage_config = ricloud.StorageConfig.retrieve(2)

key = ricloud.Key.create(storage_config=storage_config)

Retrieve GET /keys/{key ID}

Using cURL

curl 'https://ricloud-api.reincubate.com/keys/<key ID>' \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

key = ricloud.Key.retrieve(<key ID>)

List GET /keys

Parameters

nametypedescription
typestringFilter keys by their type.
statestringFilter keys by their state.

Using cURL

curl 'https://ricloud-api.reincubate.com/keys?limit=2' \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

keys = ricloud.Key.list(limit=2)

Update POST /keys/{key ID}

Parameters

nametypedescription
storage_configstorage config IDUpdate the storage config used by the key. If null will fall back to organisation default.
webhook_configwebhook config IDUpdate the webhook config used by the key. If null will fall back to organisation default.

Using cURL

curl 'https://ricloud-api.reincubate.com/keys/<key ID>' \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "webhook_config": 2
}'

Using ricloud-py

import ricloud

key = ricloud.Key.update_with_id(<key ID>, webhook_config=2)

# OR

key = ricloud.Key.retrieve(<key ID>)

key.update(webhook_config=2)

Rotate POST /keys/{key ID}/rotate

Rotate the value of a key's token. Although not required, it is recommended to do this on a fairly regular basis or immediately if it is suspected the key's token has been compromised.

Parameters

nametypedescription
forcebool, default: FalseIf the current token value should be deauthorized immediately. If not, the current rotation period is 6 hours after the call is made.

Using cURL

curl 'https://ricloud-api.reincubate.com/keys/<key ID>/rotate' \
  -X POST \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

key = ricloud.Key.rotate_with_id(<key ID>)

# OR

key = ricloud.Key.retrieve(<key ID>)

key.rotate()

相关文章

需要帮助吗?

我们会尽力在一个工作日内回复所有消息。

support@reincubate.com
帮助