diff options
-rw-r--r-- | ick2/__init__.py | 1 | ||||
-rw-r--r-- | ick2/controllerapi.py | 22 | ||||
-rw-r--r-- | ick2/logapi.py | 36 | ||||
-rw-r--r-- | without-tests | 1 |
4 files changed, 39 insertions, 21 deletions
diff --git a/ick2/__init__.py b/ick2/__init__.py index 3ed21c8..6c19bed 100644 --- a/ick2/__init__.py +++ b/ick2/__init__.py @@ -30,6 +30,7 @@ from .responses import ( ) from .apibase import APIbase, ResourceApiBase from .buildsapi import BuildsAPI +from .logapi import LogAPI from .versionapi import VersionAPI from .workerapi import WorkerAPI from .controllerapi import ( diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 433d3d0..5d5e86d 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -31,7 +31,7 @@ class ControllerAPI: apis = { '/version': ick2.VersionAPI, '/builds': ick2.BuildsAPI, - '/logs': LogAPI, + '/logs': ick2.LogAPI, '/projects': ProjectAPI, '/work': WorkAPI, '/workers': ick2.WorkerAPI, @@ -46,26 +46,6 @@ class ControllerAPI: return routes -class LogAPI(ick2.ResourceApiBase): # pragma: no cover - - def __init__(self, state): - super().__init__('log', state) - - def get_resource_name(self, resource): - return resource['log'] - - def create(self, body): # pragma: no cover - raise ick2.MethodNotAllowed('Creating builds directly is not allowed') - - def update(self, body, name): # pragma: no cover - raise ick2.MethodNotAllowed('Updating builds directly is not allowed') - - def show(self, name): - log = self._state.get_resource('log', str(name)) - ick2.log.log('info', msg_text='Returning log', log=log) - return log['log'] - - class ProjectAPI(ick2.ResourceApiBase): def __init__(self, state): diff --git a/ick2/logapi.py b/ick2/logapi.py new file mode 100644 index 0000000..2a6f2f4 --- /dev/null +++ b/ick2/logapi.py @@ -0,0 +1,36 @@ +# 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 LogAPI(ick2.ResourceApiBase): # pragma: no cover + + def __init__(self, state): + super().__init__('log', state) + + def get_resource_name(self, resource): + return resource['log'] + + def create(self, body): # pragma: no cover + raise ick2.MethodNotAllowed('Creating builds directly is not allowed') + + def update(self, body, name): # pragma: no cover + raise ick2.MethodNotAllowed('Updating builds directly is not allowed') + + def show(self, name): + log = self._state.get_resource('log', str(name)) + ick2.log.log('info', msg_text='Returning log', log=log) + return log['log'] diff --git a/without-tests b/without-tests index 6c767d5..51270a1 100644 --- a/without-tests +++ b/without-tests @@ -2,6 +2,7 @@ ick2/__init__.py ick2/apibase.py ick2/buildsapi.py ick2/exceptions.py +ick2/logapi.py ick2/logging.py ick2/responses.py ick2/version.py |