From f8e6020be698b9265ca864c2ff9c6d32db18673e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Sep 2020 13:22:28 +0200 Subject: [PATCH] endpoint versions --- ereuse_devicehub/config.py | 4 ++- .../resources/versions/__init__.py | 0 .../resources/versions/versions.py | 35 +++++++++++++++++++ setup.py | 4 +-- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 ereuse_devicehub/resources/versions/__init__.py create mode 100644 ereuse_devicehub/resources/versions/versions.py diff --git a/ereuse_devicehub/config.py b/ereuse_devicehub/config.py index b1db6e9e..c8ff9e44 100644 --- a/ereuse_devicehub/config.py +++ b/ereuse_devicehub/config.py @@ -12,6 +12,7 @@ from ereuse_devicehub.resources import action, agent, deliverynote, inventory, \ from ereuse_devicehub.resources.device import definitions from ereuse_devicehub.resources.documents import documents from ereuse_devicehub.resources.enums import PriceSoftware +from ereuse_devicehub.resources.versions import versions class DevicehubConfig(Config): @@ -24,7 +25,8 @@ class DevicehubConfig(Config): import_resource(deliverynote), import_resource(proof), import_resource(documents), - import_resource(inventory)), + import_resource(inventory), + import_resource(versions)), ) PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str] SQLALCHEMY_DATABASE_URI = 'postgresql://dhub:ereuse@localhost/devicehub' # type: str diff --git a/ereuse_devicehub/resources/versions/__init__.py b/ereuse_devicehub/resources/versions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ereuse_devicehub/resources/versions/versions.py b/ereuse_devicehub/resources/versions/versions.py new file mode 100644 index 00000000..516a08c6 --- /dev/null +++ b/ereuse_devicehub/resources/versions/versions.py @@ -0,0 +1,35 @@ +import flask +import teal.marshmallow +import ereuse_utils + +from typing import Callable, Iterable, Tuple +from flask import make_response, g +from teal.resource import Resource + + +class VersionDef(Resource): + __type__ = 'Version' + SCHEMA = None + VIEW = None # We do not want to create default / documents endpoint + AUTH = False + + def __init__(self, app, + import_name=__name__, + static_url_path=None, + url_prefix=None, + subdomain=None, + url_defaults=None, + root_path=None, + cli_commands: Iterable[Tuple[Callable, str or None]] = tuple()): + + super().__init__(app, import_name, static_url_path, + url_prefix, subdomain, url_defaults, root_path, cli_commands) + d = {'id': None} + get = {'GET'} + + self.add_url_rule('/', defaults=d, view_func=self.view, methods=get) + + def view(self): + #import pdb; pdb.set_trace() + v = "{}".format(ereuse_utils.version('ereuse-devicehub')) + return {'devicehub': v} diff --git a/setup.py b/setup.py index 2ef5907b..5d7871a4 100644 --- a/setup.py +++ b/setup.py @@ -9,10 +9,10 @@ test_requires = [ setup( name='ereuse-devicehub', - version='1.0a1', + version='0.1.0a1', url='https://github.com/ereuse/devicehub-teal', project_urls={ - 'Documentation': 'http://devicheub.ereuse.org', + 'Documentation': 'http://devicehub.ereuse.org', 'Code': 'http://github.com/ereuse/devicehub-teal', 'Issue tracker': 'https://tree.taiga.io/project/ereuseorg-devicehub/issues?q=rules' },