New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/dashboard: Add minimalistic browsable API #20873
mgr/dashboard: Add minimalistic browsable API #20873
Conversation
This HTML form generator looks nice and helpful to test some API endpoints during development, but I have one question on how are we supposed to use this? should we add the |
@rjfd actually, I would keep it enabled also for production use.
Another idea would be to rephrase this as preliminary "API documentation" or "(incomplete) browsable API". |
I like the basic idea behind this, but if it's supposed to be enabled by default, the name Having an automated way of creating a browseable "API reference" is actually a nice side benefit that makes me want to have this :) In Django, this is a builtin-feature in the Django REST framework (IIRC), where it can be enabled/disabled on a global level. Maybe this would be a better approach than having to add a decorator to every controller endpoint? |
aa6894f
to
30eb5e3
Compare
30eb5e3
to
39ff41c
Compare
@LenzGr: added a disclaimer |
jenkins retest this please |
39ff41c
to
a629d66
Compare
src/pybind/mgr/dashboard/tools.py
Outdated
@@ -473,27 +636,27 @@ def stop(cls): | |||
logger.debug("notification queue stopped") | |||
|
|||
@classmethod | |||
def register(cls, func, types=None): | |||
def register(cls, func, n_types=None): | |||
"""Registers function to listen for notifications | |||
|
|||
If the second parameter `types` is omitted, the function in `func` |
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 guess 'types' should here be 'n_types' as well?
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.
fixed
a629d66
to
19a9fd3
Compare
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 tested this and it worked for me. Nice work!
@@ -473,27 +617,27 @@ def stop(cls): | |||
logger.debug("notification queue stopped") | |||
|
|||
@classmethod | |||
def register(cls, func, types=None): | |||
def register(cls, func, n_types=None): |
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.
Can you put this renaming part into a separate commit?
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.
fixed
@@ -14,7 +14,7 @@ | |||
class Monitor(BaseController): | |||
@cherrypy.expose | |||
@cherrypy.tools.json_out() | |||
def default(self): | |||
def default(self, *_vpath, **_params): |
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 there a way to not require to add those parameters in all default
methods?
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.
Pylint says; W:464, 4: Parameters differ from overridden 'default' method (arguments-differ)
. In general, I think, it's OK to have consistent method arguments for derived classes.
This will lead to a name clash, when importing `types` Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Also provides a simple HTML form to POST data to a `RESTController`'s `create()` method. Also added ENABLE_BROWSABLE_API setting to the dashboard Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Added OSD and MDS tests. Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
19a9fd3
to
7a7a17c
Compare
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.
Tested and works for me (except for those API endpoints which currently aren't supported yet).
Also provides a simple HTML form to POST
data to a
RESTController
'screate()
method.obligatory Screenshot:
Signed-off-by: Sebastian Wagner sebastian.wagner@suse.com