diff --git a/docs/api-reference/api-keys/create-an-api-key.md b/docs/api-reference/api-keys/create-an-api-key.md index cca72b5..2dd527f 100644 --- a/docs/api-reference/api-keys/create-an-api-key.md +++ b/docs/api-reference/api-keys/create-an-api-key.md @@ -22,6 +22,30 @@ api: **Creates** a new API key and returns the actual key. +An API Key may have various scopes attached to it. If no scopes get passed +a default set of scopes will be assigned. **Please note**: By default the +scopes are very permissive to support a wide range of use cases. + +As an example, a restrictive scope might look like this: +```json + scopes: [{ + resource: 'listeners', + access: 'write', + targets: [ + 'MbCS6UB_m7NdvyDOE8stT', + 'YKOuoR5IIUUWxZeZLKf2O' + ] + }, { + resource: 'queues', + access: 'write', + targets: '*' + }, { + resource: 'messages', + access: 'read', + targets: '*' + }] +``` + For security reasons, the API key will only be returned once after its creation. @@ -39,8 +63,36 @@ See also: [Authentication](/getting-started/#prerequisites). ```shell curl -X POST http://api.discue.io/v1/api_keys \ + -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ - -H 'X-API-KEY: API_KEY' + -H 'X-API-KEY: API_KEY' \ + -d '{ + "name": "string", + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] +}' ``` @@ -48,13 +100,42 @@ curl -X POST http://api.discue.io/v1/api_keys \ ```javascript +const body = { + "name": "string", + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] +} + const headers = { + 'Content-Type':'application/json', 'Accept':'application/json', 'X-API-KEY':'API_KEY' } const response = await fetch('http://api.discue.io/v1/api_keys', { - method: 'POST', headers + method: 'POST', body, headers }) const body = await response.json() @@ -67,6 +148,7 @@ const body = await response.json() ```python import requests headers = { + 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-API-KEY': 'API_KEY' } @@ -89,6 +171,7 @@ import ( func main() { headers := map[string][]string{ + "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "X-API-KEY": []string{"API_KEY"}, } @@ -106,10 +189,70 @@ func main() { +## Body + +```json +{ + "name": "string", + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] +} +``` + ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| |pretty|query|boolean| ❌ |Return the response pretty printed| +|body|body|[PostApiKeyRequest](#schemapostapikeyrequest)| ❌ |none| +|» name|body|[ResourceName](#resourcename)| ❌ |none| +|» status|body|string| ❌ |none| +|» scopes|body|[ApiKeyScope](#apikeyscope)| ❌ |none| +|»» resource|body|string| ❌ |none| +|»» access|body|string| ❌ |none| +|»» targets|body|any| ❌ |none| +|»»» *anonymous*|body|[ResourceId](#resourceid)| ❌ |none| +|»»» *anonymous*|body|string| ❌ |none| + +## Enumerated Values + +|Parameter|Value| +|---|---| +|» status|disabled| +|» status|enabled| +|»» resource|api_clients| +|»» resource|api_keys| +|»» resource|events| +|»» resource|queues| +|»» resource|listeners| +|»» resource|messages| +|»» resource|schemas| +|»» resource|stats| +|»» resource|subscriptions| +|»» access|read| +|»» access|write| +|»»» *anonymous*|*| ## Responses diff --git a/docs/api-reference/api-keys/delete-an-api-key-by-id.md b/docs/api-reference/api-keys/delete-an-api-key-by-id.md index 4c8d0b8..512feee 100644 --- a/docs/api-reference/api-keys/delete-an-api-key-by-id.md +++ b/docs/api-reference/api-keys/delete-an-api-key-by-id.md @@ -117,7 +117,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|api_key_id|path|string(uuid)|✔|Id of the api key| +|api_key_id|path|[ResourceId](#schemaresourceid)|✔|Id of the api key| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/api-keys/get-all-api-keys.md b/docs/api-reference/api-keys/get-all-api-keys.md index 235e953..5590083 100644 --- a/docs/api-reference/api-keys/get-all-api-keys.md +++ b/docs/api-reference/api-keys/get-all-api-keys.md @@ -130,7 +130,16 @@ func main() { "updated_at": 1644616838173, "last_used_at": 1644616838173, "key": "ep1", - "status": "disabled" + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "_A36cABAOqhBdNeZeXB0l" + ] + } + ] } ], "_links": { diff --git a/docs/api-reference/api-keys/get-an-api-key-by-id.md b/docs/api-reference/api-keys/get-an-api-key-by-id.md index a14f648..5e255bf 100644 --- a/docs/api-reference/api-keys/get-an-api-key-by-id.md +++ b/docs/api-reference/api-keys/get-an-api-key-by-id.md @@ -117,7 +117,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|api_key_id|path|string(uuid)|✔|Id of the api key| +|api_key_id|path|[ResourceId](#schemaresourceid)|✔|Id of the api key| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses @@ -134,7 +134,16 @@ func main() { "updated_at": 1644616838173, "last_used_at": 1644616838173, "key": "ep1", - "status": "disabled" + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "_A36cABAOqhBdNeZeXB0l" + ] + } + ] }, "_links": { "self": { diff --git a/docs/api-reference/api-keys/update-an-api-key-by-id.md b/docs/api-reference/api-keys/update-an-api-key-by-id.md index 17b6af6..c02fb74 100644 --- a/docs/api-reference/api-keys/update-an-api-key-by-id.md +++ b/docs/api-reference/api-keys/update-an-api-key-by-id.md @@ -23,13 +23,20 @@ api: **Updates** an api key by id. **Requires** the target `api_key_id` as a path parameter. +An API Key can be `disabled` by passing `status: disabled`. By passing `status: enabled`, +you can ``enable`` the key again. + +Always pass the the whole array of `scopes` you want this key to have. At this moment there is no way +to make incremental updates. Whenever the `scopes` array is passed to the endpoint, the previous `scopes` +array will be overriden. + A valid `api_key_id` is one that was returned by the [api key creation endpoint](/api-reference/api-keys/create-an-api-key.html). If no api key can be found with the given `api_key_id`, the endpoint returns status `404`. Returns `404` if no api key was found with the given `api_key_id`. -Only mutable properties like `name` can be updated. +Only mutable properties like `name`, `status`, and `scopes` can be updated. ::: tip Authentication **The target organization for this request will be determined by the supplied access token.** @@ -50,7 +57,30 @@ curl -X PUT http://api.discue.io/v1/api_keys/{api_key_id} \ -H 'X-API-KEY: API_KEY' \ -d '{ "name": "string", - "status": "disabled" + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] }' ``` @@ -61,7 +91,30 @@ curl -X PUT http://api.discue.io/v1/api_keys/{api_key_id} \ ```javascript const body = { "name": "string", - "status": "disabled" + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] } const headers = { @@ -130,18 +183,47 @@ func main() { ```json { "name": "string", - "status": "disabled" + "status": "disabled", + "scopes": [ + { + "resource": "queues", + "access": "write", + "targets": [ + "*" + ] + }, + { + "resource": "listeners", + "access": "write", + "targets": [ + "_Tzrg1O3jk4_FZTAEThNq" + ] + }, + { + "resource": "messages", + "access": "read", + "targets": [ + "*" + ] + } + ] } ``` ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|api_key_id|path|string(uuid)|✔|Id of the api key| +|api_key_id|path|[ResourceId](#schemaresourceid)|✔|Id of the api key| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[UpdateApiKeyRequest](#schemaupdateapikeyrequest)| ❌ |none| |» name|body|[ResourceName](#resourcename)| ❌ |none| |» status|body|string| ❌ |none| +|» scopes|body|[ApiKeyScope](#apikeyscope)| ❌ |none| +|»» resource|body|string| ❌ |none| +|»» access|body|string| ❌ |none| +|»» targets|body|any| ❌ |none| +|»»» *anonymous*|body|[ResourceId](#resourceid)| ❌ |none| +|»»» *anonymous*|body|string| ❌ |none| ## Enumerated Values @@ -149,6 +231,18 @@ func main() { |---|---| |» status|disabled| |» status|enabled| +|»» resource|api_clients| +|»» resource|api_keys| +|»» resource|events| +|»» resource|queues| +|»» resource|listeners| +|»» resource|messages| +|»» resource|schemas| +|»» resource|stats| +|»» resource|subscriptions| +|»» access|read| +|»» access|write| +|»»» *anonymous*|*| ## Responses diff --git a/docs/api-reference/organizations/update-an-api-client.md b/docs/api-reference/organizations/update-an-api-client.md index 3a3f8d5..3622bc2 100644 --- a/docs/api-reference/organizations/update-an-api-client.md +++ b/docs/api-reference/organizations/update-an-api-client.md @@ -130,7 +130,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|api_client_id|path|string(uuid)|✔|none| +|api_client_id|path|[ResourceId](#schemaresourceid)|✔|none| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[ApiClientRef](#schemaapiclientref)| ❌ |none| |» name|body|string| ❌ |none| diff --git a/docs/api-reference/queue-listeners/add-a-listener-to-a-queue.md b/docs/api-reference/queue-listeners/add-a-listener-to-a-queue.md index d678cee..27ee40d 100644 --- a/docs/api-reference/queue-listeners/add-a-listener-to-a-queue.md +++ b/docs/api-reference/queue-listeners/add-a-listener-to-a-queue.md @@ -144,7 +144,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[CreateListenerRequest](#schemacreatelistenerrequest)|✔|none| |» name|body|string|✔|none| diff --git a/docs/api-reference/queue-listeners/delete-a-listener-by-id.md b/docs/api-reference/queue-listeners/delete-a-listener-by-id.md index 32742aa..e7db00c 100644 --- a/docs/api-reference/queue-listeners/delete-a-listener-by-id.md +++ b/docs/api-reference/queue-listeners/delete-a-listener-by-id.md @@ -114,8 +114,8 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| -|listener_id|path|string(uuid)|✔|Id of the target listener| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| +|listener_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target listener| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-listeners/get-a-listener-by-id.md b/docs/api-reference/queue-listeners/get-a-listener-by-id.md index b0a8a48..6e2c5e7 100644 --- a/docs/api-reference/queue-listeners/get-a-listener-by-id.md +++ b/docs/api-reference/queue-listeners/get-a-listener-by-id.md @@ -114,8 +114,8 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| -|listener_id|path|string(uuid)|✔|Id of the target listener| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| +|listener_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target listener| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-listeners/update-a-listener-by-id.md b/docs/api-reference/queue-listeners/update-a-listener-by-id.md index c27794f..cf90109 100644 --- a/docs/api-reference/queue-listeners/update-a-listener-by-id.md +++ b/docs/api-reference/queue-listeners/update-a-listener-by-id.md @@ -138,7 +138,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[UpdateListenerRequest](#schemaupdatelistenerrequest)|✔|none| |» name|body|string| ❌ |none| diff --git a/docs/api-reference/queue-messages/add-a-message-to-a-queue.md b/docs/api-reference/queue-messages/add-a-message-to-a-queue.md index d7f73b5..b331aeb 100644 --- a/docs/api-reference/queue-messages/add-a-message-to-a-queue.md +++ b/docs/api-reference/queue-messages/add-a-message-to-a-queue.md @@ -143,7 +143,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[CreateMessageRequest](#schemacreatemessagerequest)| ❌ |none| |» name|body|[ResourceName](#resourcename)| ❌ |none| diff --git a/docs/api-reference/queue-messages/delete-a-message-by-id.md b/docs/api-reference/queue-messages/delete-a-message-by-id.md index 1ebb4cd..1bef0da 100644 --- a/docs/api-reference/queue-messages/delete-a-message-by-id.md +++ b/docs/api-reference/queue-messages/delete-a-message-by-id.md @@ -115,8 +115,8 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| -|message_id|path|string(uuid)|✔|Id of the target message| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| +|message_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target message| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-messages/get-a-message-by-id.md b/docs/api-reference/queue-messages/get-a-message-by-id.md index 54dc5bc..70e83fe 100644 --- a/docs/api-reference/queue-messages/get-a-message-by-id.md +++ b/docs/api-reference/queue-messages/get-a-message-by-id.md @@ -115,8 +115,8 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| -|message_id|path|string(uuid)|✔|Id of the target message| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| +|message_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target message| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-messages/get-all-messages.md b/docs/api-reference/queue-messages/get-all-messages.md index b2f1df4..d4d267a 100644 --- a/docs/api-reference/queue-messages/get-all-messages.md +++ b/docs/api-reference/queue-messages/get-all-messages.md @@ -114,7 +114,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-messages/get-messages-by-queue-id.md b/docs/api-reference/queue-messages/get-messages-by-queue-id.md index 1440a8f..52e77f9 100644 --- a/docs/api-reference/queue-messages/get-messages-by-queue-id.md +++ b/docs/api-reference/queue-messages/get-messages-by-queue-id.md @@ -116,7 +116,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queue-messages/update-a-message-by-id.md b/docs/api-reference/queue-messages/update-a-message-by-id.md index dff1cd2..8dac75f 100644 --- a/docs/api-reference/queue-messages/update-a-message-by-id.md +++ b/docs/api-reference/queue-messages/update-a-message-by-id.md @@ -123,8 +123,8 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| -|message_id|path|string(uuid)|✔|Id of the target message| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| +|message_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target message| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[UpdateMessageRequest](#schemaupdatemessagerequest)| ❌ |none| |» name|body|[ResourceName](#resourcename)| ❌ |none| diff --git a/docs/api-reference/queue-schemas/get-a-schema-by-id.md b/docs/api-reference/queue-schemas/get-a-schema-by-id.md index 319142a..58fc151 100644 --- a/docs/api-reference/queue-schemas/get-a-schema-by-id.md +++ b/docs/api-reference/queue-schemas/get-a-schema-by-id.md @@ -23,6 +23,10 @@ api: **Returns** a queue schema by id. Requires a valid `queue_id` and `schema_id` as path parameters. If no queue or schema with the given ids can be found, the endpoint returns status `404`. +Currently there is no way to `create`, `update`, or `delete` schemas, because a schema +has to be assigned to a queue. You can use the `update` endpoint of the queue in question, +to update, or remove its schema. + A valid `queue_id` is one that was returned by the [queue creation endpoint](/api-reference/queues/create-a-queue.html). The `schema_id` is computed during the creation of a queue, **if** an additional schema object was set. @@ -114,7 +118,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |schema_id|path|string(sha256)|✔|Id of the target schema| |pretty|query|boolean| ❌ |Return the response pretty printed| diff --git a/docs/api-reference/queues/delete-a-queue-by-id.md b/docs/api-reference/queues/delete-a-queue-by-id.md index 986f234..8176a80 100644 --- a/docs/api-reference/queues/delete-a-queue-by-id.md +++ b/docs/api-reference/queues/delete-a-queue-by-id.md @@ -114,7 +114,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queues/get-a-queue-by-id.md b/docs/api-reference/queues/get-a-queue-by-id.md index 8d658d0..222908c 100644 --- a/docs/api-reference/queues/get-a-queue-by-id.md +++ b/docs/api-reference/queues/get-a-queue-by-id.md @@ -113,7 +113,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| ## Responses diff --git a/docs/api-reference/queues/update-a-queue-by-id.md b/docs/api-reference/queues/update-a-queue-by-id.md index 71ac496..864c0f7 100644 --- a/docs/api-reference/queues/update-a-queue-by-id.md +++ b/docs/api-reference/queues/update-a-queue-by-id.md @@ -242,7 +242,7 @@ func main() { ## Parameters |Name|In|Type|Required|Description| |---|---|---|---|---| -|queue_id|path|string(uuid)|✔|Id of the target queue| +|queue_id|path|[ResourceId](#schemaresourceid)|✔|Id of the target queue| |pretty|query|boolean| ❌ |Return the response pretty printed| |body|body|[UpdateQueueRequest](#schemaupdatequeuerequest)|✔|none| |» name|body|string| ❌ |none|