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

Merged
merged 3 commits into from Mar 27, 2018

Conversation

Projects
None yet
6 participants
@sebastian-philipp
Copy link
Member

sebastian-philipp commented Mar 13, 2018

Also provides a simple HTML form to POST
data to a RESTController's create() method.

obligatory Screenshot:

html-debug-view

Signed-off-by: Sebastian Wagner sebastian.wagner@suse.com

@rjfd

This comment has been minimized.

Copy link
Contributor

rjfd commented Mar 14, 2018

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 @debug_html_page decorator while developing a rest controller endpoint, but then remove the decorator when we push the commits to the PR? or should we leave the decorator in the code? (if it's the latter then we need some config option to disable the debug page in production)

@sebastian-philipp

This comment has been minimized.

Copy link
Member Author

sebastian-philipp commented Mar 14, 2018

@rjfd actually, I would keep it enabled also for production use.

  1. If you look at a page, if is obvious that this is not meant to be used in production
  2. It doesn't provide anything that you cannot use via curl.
  3. In openATTIC, we also didn't disable this API viewer.

Another idea would be to rephrase this as preliminary "API documentation" or "(incomplete) browsable API".

@LenzGr

This comment has been minimized.

Copy link
Contributor

LenzGr commented Mar 14, 2018

I like the basic idea behind this, but if it's supposed to be enabled by default, the name @debug_html_page is indeed misleading.

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?

@sebastian-philipp sebastian-philipp changed the title mgr/dashboard_v2: Add minimalistic HTML debug representation of the API mgr/dashboard_v2: Add minimalistic browsable API Mar 15, 2018

@sebastian-philipp sebastian-philipp force-pushed the sebastian-philipp:dashboard_v2-simple-html-debug branch from aa6894f to 30eb5e3 Mar 15, 2018

@sebastian-philipp

This comment has been minimized.

Copy link
Member Author

sebastian-philipp commented Mar 15, 2018

@rjfd : Just added ENABLE_BROWSABLE_API setting to our settings.
@LenzGr: Renamed the PR to "browsable API"

I'd favor this setting to be True by default, but I don't mind to set this to False

@sebastian-philipp sebastian-philipp force-pushed the sebastian-philipp:dashboard_v2-simple-html-debug branch from 30eb5e3 to 39ff41c Mar 16, 2018

@sebastian-philipp

This comment has been minimized.

Copy link
Member Author

sebastian-philipp commented Mar 16, 2018

@LenzGr: added a disclaimer

@sebastian-philipp sebastian-philipp requested a review from LenzGr Mar 16, 2018

@sebastian-philipp sebastian-philipp changed the title mgr/dashboard_v2: Add minimalistic browsable API mgr/dashboard: Add minimalistic browsable API Mar 16, 2018

@sebastian-philipp

This comment has been minimized.

Copy link
Member Author

sebastian-philipp commented Mar 20, 2018

jenkins retest this please

@sebastian-philipp sebastian-philipp force-pushed the sebastian-philipp:dashboard_v2-simple-html-debug branch from 39ff41c to a629d66 Mar 20, 2018

@votdev

votdev approved these changes Mar 23, 2018

@@ -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`

This comment has been minimized.

@s0nea

s0nea Mar 23, 2018

Member

I guess 'types' should here be 'n_types' as well?

This comment has been minimized.

@sebastian-philipp

sebastian-philipp Mar 23, 2018

Author Member

fixed

@sebastian-philipp sebastian-philipp force-pushed the sebastian-philipp:dashboard_v2-simple-html-debug branch from a629d66 to 19a9fd3 Mar 23, 2018

@s0nea

s0nea approved these changes Mar 23, 2018

@LenzGr

LenzGr approved these changes Mar 24, 2018

Copy link
Contributor

LenzGr left a comment

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):

This comment has been minimized.

@rjfd

rjfd Mar 26, 2018

Contributor

Can you put this renaming part into a separate commit?

This comment has been minimized.

@sebastian-philipp

sebastian-philipp Mar 26, 2018

Author Member

fixed

@@ -14,7 +14,7 @@
class Monitor(BaseController):
@cherrypy.expose
@cherrypy.tools.json_out()
def default(self):
def default(self, *_vpath, **_params):

This comment has been minimized.

@rjfd

rjfd Mar 26, 2018

Contributor

Is there a way to not require to add those parameters in all default methods?

This comment has been minimized.

@sebastian-philipp

sebastian-philipp Mar 26, 2018

Author Member

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.

sebastian-philipp added some commits Mar 26, 2018

mgr/dashboard: Renamed `types` as it clashes with std lib
This will lead to a name clash, when importing `types`

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
mgr/dashboard: Add minimalistic browsable API
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>
mgr/dashboard: New API tests for `perf_couters`
Added OSD and MDS tests.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>

@sebastian-philipp sebastian-philipp force-pushed the sebastian-philipp:dashboard_v2-simple-html-debug branch from 19a9fd3 to 7a7a17c Mar 26, 2018

@rjfd

rjfd approved these changes Mar 27, 2018

@p-na

p-na approved these changes Mar 27, 2018

Copy link
Contributor

p-na left a comment

Tested and works for me (except for those API endpoints which currently aren't supported yet).

@LenzGr LenzGr merged commit 43e5097 into ceph:master Mar 27, 2018

5 checks passed

Docs: build check OK - docs built
Details
Signed-off-by all commits in this PR are signed
Details
Unmodified Submodules submodules for project are unmodified
Details
make check make check succeeded
Details
make check (arm64) make check succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment