-
Notifications
You must be signed in to change notification settings - Fork 123
elektra-web HTTP API #912
elektra-web HTTP API #912
Conversation
@Namoshek Can you take a look? |
* **GET /instances** - get a list of all instances | ||
* **POST /instances** - create a new instance | ||
* **GET /instances/:id** - get information about a single instance | ||
* **POST /instances/:id** - edit a single instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For updating/patching you should use PUT or PATCH.
You will also need a method for deleting instances, I guess. Use DELETE for this task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both PUT or PATCH make sense, but we cannot use json merge patch because in Elektra null and absent is something different.
With put we might not need DELETE, if everything missing in PUT is deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to PUT
and added DELETE
. I'll still keep POST
for the /kdb/:path
commands, because the same method will be used for creating and editing keys (could additionally add PUT
which doesn't allow setting keys that don't exist, not sure if there's a use case for that, though)
I am missing how to update parts of the configuration tree and how to select different configuration formats for transfer. |
So far the API descriptions seems clear and well thought, except for the HTTP methods here and there. When you change them, make sure you only use either PUT or PATCH, but not both. I think they are interchangable, although some might say that PATCH is used for modifications and PUT for replacements (although this differentiation is quite hard in most scenarios). For removing resources obviously use DELETE. Concerning the rest of your proposal and the structure, I think I would have chosen a similar approach. For further definition of the REST API, I have some thoughs on my mind that might be helpful for you:
I think that is enough to think about for the moment. 😄 |
Which configuration tree are you talking about? Shouldn't this be easily possible with his
operation? (For this operation I think POST is an appropriate HTTP method by the way.) |
@Namoshek Thank you for the detailed feedback!
There are configuration formats that handle both config+metadata within the same syntax, so if we have support for arbitrary syntax, we would also handle metadata without more API. It won't work with JSON though.
Which one do you refer to? mounting and such? All of them are basically only key-value operations, but you are right that non-trivial algorithms are involved you want to avoid reimplementing in every language. @BernhardDenner is looking for a good solution here, too.
The hierarchy built up within Elektra separated with Namespace support is also unclear. |
... which also depends on the storage plugin you use. The old story, you know. 😄
Yes, that is what i meant. Implementing these functions within his REST API a second time doesn't sound good, because it would potentially lead to unintended and unexpected behavior in later versions (if something of the plugin system changes). Of course you could leave this task open to the end-user, so he could simply use the normal interface, but I'm not sure if this is userfriendly at all.
Ah yes, that is what I'm talking about in the first paragraph. Abstracting the import/export function could be done via an additional HTTP parameter repesenting the way how to handle the supplied value (e.g. no parameter = simple value, parameter set = use storage plugin for parameter or something similar). |
This should only be a workaround for non-supported formats (actually even in this case the line-plugin would be preferable). It would not be possible to transform snippets to other formats nor to validate them if the whole snippet is within a key. |
What I actually meant was that you can place the configuration encapsulated by a snippet in the hierarchy below a certain key, not the snippet as standalone value. But it should still be possible to set single values as well, in my opinion. So the interface would actually offer two operations. Import of snippets
as ini-script imported for path
In other words, the provided path would be the root key for the snippet. Namespaces could be done via an optional parameter as well. Setting of basic values
as single value set for path
Of course there must be some way to tell the API how the provided value has to be treated. |
Thanks for clarifying the It would definitely be possible to save snippets under a sub-tree (specified via All additional features could be added as HTTP parameters, e.g. |
I have updated the document, please re-review.
I would combine the responses from the
200, 404 for non-existing keys, 403 for authorization failures
Good idea!
I haven't considered that and I'm not sure if there's a use case for it, but it's an interesting idea. |
I would prefer to directly review the blueprint version where the tools say the syntax is ok and which already has examples. Please make sure to respond to all concerns in the new document. If unsure you can add TODO markers. |
There is definitely a use-case to not have a clusterd (to connect a browser to
To make recursive nesting easily possible, the API for elektrad and clusterd must be identical. Then you need something like |
For me, hierarchical clusters does not imply running several But with the current design even better abstractions are already possible. For example you could create clusters for each software-bundle you use on your servers, e.g. a |
The question is if clusterd is needed at all (either elektrad can manage clusters or the browser can also connect to several elektrad). But that is a different architectural decisions which should not be a part of this document (as already stated).
It would be a better design to only use different APIs if it really abstracts something inherently different. It does not seem like that the abstraction differs if the API only merges some results together.
Up to now I do not see a reason why we should forbid them. Btw. @omnidan Please do not squash commits (as you have in the TODO above). |
Although you could connect with the browser to multiple machines, you'd still need to store the configuration for your clusters somewhere. The browsers local cache doesn't seem appropriate to me, but with a configuration export & import feature, it could be interesting again. Maybe make another issue for such a discussion and brainstorming, @omnidan?
Be careful with that, I already wrote something about multi-status for a reason. Inventing a multi-status for single resources is not a good design and the other way round you would invent lots of possible bugs and inconveniences when using only a single status code for a whole batch of operations. So there is actually a good reason to use two interfaces. |
@markus2330 @Namoshek I have updated the blueprints, please let me know if everything is fine now. About the kdb errors - is there anything besides plugins that trigger them? I'm not sure if it'll make sense to deal with them specifically in my API (I would just output the error in my frontend), I would just put the stderr result into the |
|
||
_an API and web user interface to remotely manage multiple elektra instances_ | ||
the cluster management server (`clusterd`) provides a REST HTTP API to control | ||
multiple `elektrad` instances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elektrad instances and also clusterd instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #983 (comment)
* (multiple) servers running an elektra daemon (`elektrad`) | ||
* a single cluster management server to communicate with the elektra daemons (`clusterd`) | ||
* a client (web browser) that accesses the Web UI on the cluster management server | ||
returns the current version of the API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
### get configuration [GET] | ||
|
||
this is the same as calling `kdb get {path}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only the split-up or did you already update these parts? You should describe the behaviour with text or by means of C-API, not by referring to other implementations.
And we should not repeat problems already known: e.g. #401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is already updated, but I forgot to remove these descriptions (which aren't accurate anymore now)
@markus2330 please re-review |
|
||
### delete configuration [DELETE] | ||
|
||
this is the same as calling `kdb rm {path}` on the instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I missed that - fixed now!
@Namoshek Can you check if everything is fine now and consistent with your API? |
+ Attributes (Error) | ||
+ i18n | ||
A comprehensive list of possible errors: | ||
- `APIKEY_MISSING` api key not specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does drafter accept this / it is rendered correctly? I thought you need an empty line before the "extended description" (i.e. add empty line between 46 and 47).
I also think you should write the type to i18n
even if string is the default type, it makes the whole thing more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and yes, it is rendered correctly. Thanks for the notice, I added the string type now!
|
||
+ Request (application/json) | ||
|
||
"hello world" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to have an import/export interface where someone can directly upload/download snippets without packaging it into JSON.
The mime type should be fixed then, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like I've done it where you send the plain text snippet in one field and its format in another field (of a json object)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean the format encoded in the URL, and the content is the configuration file as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Namoshek yes, it is valid json (simply a json string)
@markus2330 more mime types could be implemented the same way as json is implemented right now (distinguish via request header) - which formats were you thinking of? which ones should be specified in the blueprint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means something like
POST [...]/set/path/to/var?format=augeas%20lens=Hosts.lns
Content-Type: text/plain
Body:
127.0.0.1 localhost loopback-adapter
192.168.0.1 gateway
Or in other words: Give format as GET parameter + whole payload is the snippet in plain text.
But normally one would avoid GET parameters in a POST request I think...
|
||
+ Request update host of instance (application/json) | ||
+ Attributes (object) | ||
+ host: 192.168.0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make type string
explicit and add a description for the field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch - I did that now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small things I've noticed, but all in all it looks good!
@Namoshek thanks for reviewing! let me know if everything looks fine now 😁 |
To me it looks fine now. 👍 |
Thanks! Added #1234 for issues to be addressed later (after first version of implementation is merged). |
Purpose
This is a proposal to allow remote configuration of (multiple) elektra instances.
Checklist
{+path}
instead of{path}
- https://apiblueprint.org/documentation/specification.html#variable-with-reserved-characters-valuesls
/value
/meta
when accessing kdb paths viaGET
output kdb errors via apidoes this really make sense since we're not dealing with plugins?change links to point to the official repo@markus2330 please review my pull request