Skip to content

Commit

Permalink
v0.5.1 Added the /info endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeares committed Dec 8, 2021
1 parent 5c9288b commit 13ae20f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/mkdocs/news/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This is the current release cycle, so future features will be updated below.
When installing plugins, the expected behavior of checking if it's already installed occurs.
- **Replaced `semver.match()` with `semver.VersionInfo.match()`.**
This change resolves depreciation warnings when building the package.
- **Added the `/info` endpoint to the API.**
This allows users to scrape tidbits of information about instances. The current dictionary returns the version and numbers of pipes, plugins, and users. More information will be added to this endpoint in future releases.

### v0.5.0
- **New syncing engine.**
Expand Down
23 changes: 22 additions & 1 deletion meerschaum/api/routes/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
Miscellaneous routes
"""

from __future__ import annotations
from meerschaum.utils.typing import Dict

import os
from meerschaum.api import app, endpoints, check_allow_chaining, SERVER_ID, debug
from meerschaum import get_pipes
from meerschaum.api import app, endpoints, check_allow_chaining, SERVER_ID, debug, get_api_connector
from starlette.responses import FileResponse

@app.get(endpoints['favicon'], tags=['Misc'])
Expand All @@ -22,6 +26,23 @@ def get_chaining_status() -> bool:
"""
return check_allow_chaining()


@app.get(endpoints['info'], tags=['Misc'])
def get_instance_info() -> Dict[str, str]:
"""
Return a dictionary of configuration information.
"""
from meerschaum import __version__ as version
num_plugins = len(get_api_connector().get_plugins(debug=debug))
num_users = len(get_api_connector().get_users(debug=debug))
num_pipes = len(get_pipes(mrsm_instance=get_api_connector(), as_list=True))
return {
'version': version,
'num_plugins': num_plugins,
'num_users': num_users,
'num_pipes': num_pipes,
}

if debug:
@app.get('/id', tags=['Misc'])
def get_ids() -> str:
Expand Down
2 changes: 1 addition & 1 deletion meerschaum/api/routes/_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def register_plugin(

@app.get(plugins_endpoint + '/{name}', tags=['Plugins'])
def get_plugin(
name : str
name: str
) -> Union[FileResponse, SuccessTuple]:
"""
Download a plugin's archive file
Expand Down
2 changes: 1 addition & 1 deletion meerschaum/api/routes/_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def read_current_user(
@app.get(users_endpoint, tags=['Users'])
def get_users() -> List[str]:
"""
Return a list of registered users
Return a list of registered users.
"""
return get_api_connector().get_users(debug=debug)

Expand Down
1 change: 1 addition & 0 deletions meerschaum/api/routes/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ def get_meerschaum_version():
"""
from meerschaum import __version__ as version
return version

1 change: 1 addition & 0 deletions meerschaum/config/static/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def _static_config():
'websocket': '/ws',
'dash': '/dash',
'term': '/term',
'info': '/info',
},
'oauth': {
'token_expires_minutes': 15,
Expand Down

0 comments on commit 13ae20f

Please sign in to comment.