diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-11-18 20:28:55 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-11-18 20:28:55 +0100 |
commit | 10edd83909027a647e256afb76dc6a09a55b553b (patch) | |
tree | 0bd4c7fa856ceab0513d6c81999daddd0b83a085 /ick2 | |
parent | ceae946c47b4ce34d9d66652b94df66d82fe8c69 (diff) | |
download | ick2-10edd83909027a647e256afb76dc6a09a55b553b.tar.gz |
Refactor: move VersionAPI into its own module
Diffstat (limited to 'ick2')
-rw-r--r-- | ick2/__init__.py | 2 | ||||
-rw-r--r-- | ick2/controllerapi.py | 35 | ||||
-rw-r--r-- | ick2/versionapi.py | 49 |
3 files changed, 51 insertions, 35 deletions
diff --git a/ick2/__init__.py b/ick2/__init__.py index 002ac3b..c48629b 100644 --- a/ick2/__init__.py +++ b/ick2/__init__.py @@ -29,10 +29,10 @@ from .responses import ( text_plain, ) from .apibase import APIbase +from .versionapi import VersionAPI from .controllerapi import ( ControllerAPI, ProjectAPI, - VersionAPI, WorkAPI, WorkerAPI, ) diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 1c482fe..7c54cad 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -29,7 +29,7 @@ class ControllerAPI: def find_missing_route(self, missing_path): # pragma: no cover apis = { - '/version': VersionAPI, + '/version': ick2.VersionAPI, '/builds': BuildsAPI, '/logs': LogAPI, '/projects': ProjectAPI, @@ -46,39 +46,6 @@ class ControllerAPI: return routes -class VersionAPI(ick2.APIbase): - - def __init__(self, state): - super().__init__(state) - - def get_routes(self, path): # pragma: no cover - return [ - { - 'method': 'GET', - 'path': path, - 'callback': self.GET(self.get_version), - } - ] - - def get_version(self): - return {'version': ick2.__version__} - - def create(self, *args): # pragma: no cover - pass - - def update(self, *args): # pragma: no cover - pass - - def delete(self, *args): # pragma: no cover - pass - - def list(self): # pragma: no cover - pass - - def show(self, *args): # pragma: no cover - pass - - class ResourceApiBase(ick2.APIbase): def __init__(self, type_name, state): diff --git a/ick2/versionapi.py b/ick2/versionapi.py new file mode 100644 index 0000000..f17c333 --- /dev/null +++ b/ick2/versionapi.py @@ -0,0 +1,49 @@ +# Copyright (C) 2017 Lars Wirzenius +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import ick2 + + +class VersionAPI(ick2.APIbase): + + def __init__(self, state): + super().__init__(state) + + def get_routes(self, path): # pragma: no cover + return [ + { + 'method': 'GET', + 'path': path, + 'callback': self.GET(self.get_version), + } + ] + + def get_version(self): + return {'version': ick2.__version__} + + def create(self, *args): # pragma: no cover + pass + + def update(self, *args): # pragma: no cover + pass + + def delete(self, *args): # pragma: no cover + pass + + def list(self): # pragma: no cover + pass + + def show(self, *args): # pragma: no cover + pass |