Skip to content

Commit 39d8c8d

Browse files
committed
docs: update api docs
1 parent b8715e8 commit 39d8c8d

20 files changed

+290
-31
lines changed

docs/api-reference/api-keys/create-an-api-key.md

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ api:
2222

2323
**Creates** a new API key and returns the actual key.
2424

25+
An API Key may have various scopes attached to it. If no scopes get passed
26+
a default set of scopes will be assigned. **Please note**: By default the
27+
scopes are very permissive to support a wide range of use cases.
28+
29+
As an example, a restrictive scope might look like this:
30+
```json
31+
scopes: [{
32+
resource: 'listeners',
33+
access: 'write',
34+
targets: [
35+
'MbCS6UB_m7NdvyDOE8stT',
36+
'YKOuoR5IIUUWxZeZLKf2O'
37+
]
38+
}, {
39+
resource: 'queues',
40+
access: 'write',
41+
targets: '*'
42+
}, {
43+
resource: 'messages',
44+
access: 'read',
45+
targets: '*'
46+
}]
47+
```
48+
2549
<Badge type="warning" text="Note" vertical="middle"/> For security reasons, the
2650
API key will only be returned once after its creation.
2751

@@ -39,22 +63,79 @@ See also: [Authentication](/getting-started/#prerequisites).
3963

4064
```shell
4165
curl -X POST http://api.discue.io/v1/api_keys \
66+
-H 'Content-Type: application/json' \
4267
-H 'Accept: application/json' \
43-
-H 'X-API-KEY: API_KEY'
68+
-H 'X-API-KEY: API_KEY' \
69+
-d '{
70+
"name": "string",
71+
"status": "disabled",
72+
"scopes": [
73+
{
74+
"resource": "queues",
75+
"access": "write",
76+
"targets": [
77+
"*"
78+
]
79+
},
80+
{
81+
"resource": "listeners",
82+
"access": "write",
83+
"targets": [
84+
"_Tzrg1O3jk4_FZTAEThNq"
85+
]
86+
},
87+
{
88+
"resource": "messages",
89+
"access": "read",
90+
"targets": [
91+
"*"
92+
]
93+
}
94+
]
95+
}'
4496
```
4597

4698
</CodeGroupItem>
4799

48100
<CodeGroupItem title="javascript">
49101

50102
```javascript
103+
const body = {
104+
"name": "string",
105+
"status": "disabled",
106+
"scopes": [
107+
{
108+
"resource": "queues",
109+
"access": "write",
110+
"targets": [
111+
"*"
112+
]
113+
},
114+
{
115+
"resource": "listeners",
116+
"access": "write",
117+
"targets": [
118+
"_Tzrg1O3jk4_FZTAEThNq"
119+
]
120+
},
121+
{
122+
"resource": "messages",
123+
"access": "read",
124+
"targets": [
125+
"*"
126+
]
127+
}
128+
]
129+
}
130+
51131
const headers = {
132+
'Content-Type':'application/json',
52133
'Accept':'application/json',
53134
'X-API-KEY':'API_KEY'
54135
}
55136

56137
const response = await fetch('http://api.discue.io/v1/api_keys', {
57-
method: 'POST', headers
138+
method: 'POST', body, headers
58139
})
59140

60141
const body = await response.json()
@@ -67,6 +148,7 @@ const body = await response.json()
67148
```python
68149
import requests
69150
headers = {
151+
'Content-Type': 'application/json',
70152
'Accept': 'application/json',
71153
'X-API-KEY': 'API_KEY'
72154
}
@@ -89,6 +171,7 @@ import (
89171
func main() {
90172

91173
headers := map[string][]string{
174+
"Content-Type": []string{"application/json"},
92175
"Accept": []string{"application/json"},
93176
"X-API-KEY": []string{"API_KEY"},
94177
}
@@ -106,10 +189,70 @@ func main() {
106189

107190
</CodeGroup>
108191

192+
## Body
193+
194+
```json
195+
{
196+
"name": "string",
197+
"status": "disabled",
198+
"scopes": [
199+
{
200+
"resource": "queues",
201+
"access": "write",
202+
"targets": [
203+
"*"
204+
]
205+
},
206+
{
207+
"resource": "listeners",
208+
"access": "write",
209+
"targets": [
210+
"_Tzrg1O3jk4_FZTAEThNq"
211+
]
212+
},
213+
{
214+
"resource": "messages",
215+
"access": "read",
216+
"targets": [
217+
"*"
218+
]
219+
}
220+
]
221+
}
222+
```
223+
109224
## Parameters
110225
|Name|In|Type|Required|Description|
111226
|---|---|---|---|---|
112227
|pretty|query|boolean||Return the response pretty printed|
228+
|body|body|[PostApiKeyRequest](#schemapostapikeyrequest)||none|
229+
|» name|body|[ResourceName](#resourcename)||none|
230+
|» status|body|string||none|
231+
|» scopes|body|[ApiKeyScope](#apikeyscope)||none|
232+
|»» resource|body|string||none|
233+
|»» access|body|string||none|
234+
|»» targets|body|any||none|
235+
|»»» *anonymous*|body|[ResourceId](#resourceid)||none|
236+
|»»» *anonymous*|body|string||none|
237+
238+
## Enumerated Values
239+
240+
|Parameter|Value|
241+
|---|---|
242+
|» status|disabled|
243+
|» status|enabled|
244+
|»» resource|api_clients|
245+
|»» resource|api_keys|
246+
|»» resource|events|
247+
|»» resource|queues|
248+
|»» resource|listeners|
249+
|»» resource|messages|
250+
|»» resource|schemas|
251+
|»» resource|stats|
252+
|»» resource|subscriptions|
253+
|»» access|read|
254+
|»» access|write|
255+
|»»» *anonymous*|*|
113256

114257
## Responses
115258

docs/api-reference/api-keys/delete-an-api-key-by-id.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func main() {
117117
## Parameters
118118
|Name|In|Type|Required|Description|
119119
|---|---|---|---|---|
120-
|api_key_id|path|string(uuid)||Id of the api key|
120+
|api_key_id|path|[ResourceId](#schemaresourceid)||Id of the api key|
121121
|pretty|query|boolean||Return the response pretty printed|
122122

123123
## Responses

docs/api-reference/api-keys/get-all-api-keys.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,16 @@ func main() {
130130
"updated_at": 1644616838173,
131131
"last_used_at": 1644616838173,
132132
"key": "ep1",
133-
"status": "disabled"
133+
"status": "disabled",
134+
"scopes": [
135+
{
136+
"resource": "queues",
137+
"access": "write",
138+
"targets": [
139+
"_A36cABAOqhBdNeZeXB0l"
140+
]
141+
}
142+
]
134143
}
135144
],
136145
"_links": {

docs/api-reference/api-keys/get-an-api-key-by-id.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func main() {
117117
## Parameters
118118
|Name|In|Type|Required|Description|
119119
|---|---|---|---|---|
120-
|api_key_id|path|string(uuid)||Id of the api key|
120+
|api_key_id|path|[ResourceId](#schemaresourceid)||Id of the api key|
121121
|pretty|query|boolean||Return the response pretty printed|
122122

123123
## Responses
@@ -134,7 +134,16 @@ func main() {
134134
"updated_at": 1644616838173,
135135
"last_used_at": 1644616838173,
136136
"key": "ep1",
137-
"status": "disabled"
137+
"status": "disabled",
138+
"scopes": [
139+
{
140+
"resource": "queues",
141+
"access": "write",
142+
"targets": [
143+
"_A36cABAOqhBdNeZeXB0l"
144+
]
145+
}
146+
]
138147
},
139148
"_links": {
140149
"self": {

0 commit comments

Comments
 (0)