/
webd.apib
301 lines (190 loc) · 8.28 KB
/
webd.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
FORMAT: 1A
# webd API
the web management server (`webd`) provides a REST HTTP API to control
multiple `elektrad` instances and serves the `client`
as a result of the client being served at `/`, the api is prefixed with `/api` to avoid conflicts
# get versions [GET /api/version]
returns the current version of the API and elektra
The API version is increased whenever breaking changes
(i.e. changes that prevent backward compatibility) are made.
The Elektra version is directly taken from the Elektra library,
for further information and explanation see [doc/VERSION.md](https://github.com/ElektraInitiative/libelektra/blob/master/doc/VERSION.md).
+ Response 200 (application/json; charset=utf-8)
+ Attributes (object)
+ api: 1 (number) - The version of the API itself
+ elektra (object) - Detailed version information about the used Elektra library
+ version: 0.8.23 (string) - The currently used version in its complete format
+ major: 0 (number) - The currently used major version
+ minor: 8 (number) - The currently used minor version
+ patch: 23 (number) - The currently used patch version
# Group instances
## instances endpoint [/api/instances]
### list all instances [GET]
+ Response 200 (application/json; charset=utf-8)
+ Attributes (array[Instance])
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
### create a new instance [POST]
+ Request (application/json)
+ Attributes (Instance)
+ Response 201
+ Attributes (Instance)
+ Request (application/json)
+ Attributes (Minimal Instance)
+ Response 201
+ Attributes (Minimal Instance)
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
## single instance [/api/instances/{instance_id}]
+ Attributes (Instance)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
### get information about a single instance [GET]
+ Response 200 (application/json; charset=utf-8)
+ Attributes (Instance)
+ Response 404
### edit a single instance [PUT]
+ Request update host of instance (application/json)
+ Attributes (Minimal Instance)
+ Body
{ "host": "http://localhost:33333" }
+ Response 200
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
### delete a single instance [DELETE]
+ Request
+ Parameters
+ instance_id: `0d8b3c29-88a5-4681-ad7a-17f5689e31f3` (string) - id of an instance
+ Response 200
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
### get version of a single instance [GET /api/instances/{instance_id}/version]
+ Response 200 (application/json; charset=utf-8)
+ Attributes (Version)
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
## single instance key database [/api/instances/{instance_id}/kdb/{+path}]
you can access a single instances' configuration via `clusterd` the same way you would directly access it
if the `INSTANCE` env var is used, webd creates a virtual instance with the id `my`. It can be requested via: `/instances/my/kdb`
### get configuration [GET]
get the content and subkeys of the specified `path` in the elektra key database
this actually does `kdb get`, `kdb ls` and `kdb meta-ls`/`kdb meta-get` at once and is used to browse the kdb
+ Request
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ path: `user/hello` (string) - path to the elektra config
+ Response 200 (application/json; charset=utf-8)
+ Attributes (KDBResponse)
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
### set configuration [PUT]
set the content of the specified `path` in the elektra key database - works like `kdb set`
+ Request (text/plain)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ path: `user/hello` (string) - path to the elektra config
+ Body
hello world
+ Response 200
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
### delete configuration [DELETE]
delete the key (and all its subkeys) on the specified `path` from the elektra key database - works like `kdb rm -r`
+ Request
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ path: `user/hello` (string) - path to the elektra config
+ Response 200
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
+ Response 404
## find keys [GET /api/instances/{instance_id}/kdbFind/{+query}]
+ Request (application/json)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ query: `hello` (string) - search query
+ Response 200 (application/json; charset=utf-8)
+ Body
[
"user/hello",
"user/helloWorld"
]
## metakeys [/api/instances/{instance_id}/kdbMeta/{+path}]
### create metakey [POST]
+ Attributes (Metakey)
+ Request (application/json)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ path: `user/hello` (string) - path to the elektra config
+ Response 204
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
### delete metakey [DELETE]
+ Attributes (Metakey)
+ Request (application/json)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ path: `user/hello` (string) - path to the elektra config
+ Response 204
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
## move operation [POST /api/instances/{instance_id}/kdbMv/{+from}]
move a key (and all its subkeys) to a new path - works like `kdb mv -r`
+ Request (text/plain)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ from: `user/hello` (string) - path to the elektra config
+ Body
user/toPath
+ Response 204
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
## copy operation [POST /api/instances/{instance_id}/kdbCp/{+from}]
copy a key (and all its subkeys) to a new path - works like `kdb cp -r`
+ Request (text/plain)
+ Parameters
+ instance_id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string) - id of an instance
+ from: `user/hello` (string) - path to the elektra config
+ Body
user/toPath
+ Response 204
+ Response 400 (application/json; charset=utf-8)
+ Attributes (Error)
# Data Structures
## Base Version (object)
+ api (number) - The version of the API itself
## Version (Base Version)
+ elektra (object) - Detailed version information about the used Elektra library
+ version (string) - The currently used version in its complete format
+ major (number) - The currently used major version
+ minor (number) - The currently used minor version
+ patch (number) - The currently used patch version
## Instance (object)
+ id: `46a288ae-7475-4cdd-a04c-3826c9a4b5f5` (string, required)
+ name: test instance (string, required)
+ host: `http://localhost:33333` (string, required)
+ visibility: user (string, required)
+ description: longer text describing the instance (string)
## Minimal Instance (object)
+ id: `0d8b3c29-88a5-4681-ad7a-17f5689e31f3` (string, required)
+ name: minimal instance (string, required)
+ host: `http://127.0.0.1:33333` (string, required)
+ visibility: user (string, required)
## KDBResponse (object)
+ exists: true (boolean, required) - `true` if the key exists in the kdb
+ name: hello (string, required) - name of the requested key
+ path: user/hello (string, required) - full path of the requested key
+ ls: user/hello, user/hello/world (array[string], required) - subkeys of the requested path, similar to `kdb ls`
+ value: hello world (string) - value of the key. Note: a key can exist but not have a value!
+ meta (object) - metadata of the requested path
## Error (object)
+ name (string) - description of the error, e.g. KDBError
+ message (string) - detailed error information, e.g. hint about malformed request
## Metakey (object)
+ key: metaName (string, required)
+ value: meta value (string, required)