From fd9224393c9d6392fa4d5cf825b616b6fb7dc0b5 Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Tue, 13 Dec 2016 01:27:03 +0200 Subject: [PATCH] Cleanup controllers - drop /v1/tasks because IronFunctions /tasks should not be consumed by users - remove response rendering on async execution because async exec on IronFunctions return "call_id" that means nothing to users --- picasso/api/controllers/runnable.py | 6 +- picasso/api/controllers/tasks.py | 96 ----------------------------- picasso/tests/functional/base.py | 2 - service/picasso_api.py | 2 - 4 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 picasso/api/controllers/tasks.py diff --git a/picasso/api/controllers/runnable.py b/picasso/api/controllers/runnable.py index c896cd0..3fe24a8 100644 --- a/picasso/api/controllers/runnable.py +++ b/picasso/api/controllers/runnable.py @@ -51,11 +51,7 @@ class RunnableMixin(object): def process_result(res): if route.type == "async": - _data = { - "task_id": res["call_id"], - "message": ("App {} async route {} " - "execution started".format(app, path)) - } + _data = {} else: _data = { "result": res, diff --git a/picasso/api/controllers/tasks.py b/picasso/api/controllers/tasks.py deleted file mode 100644 index 43603a4..0000000 --- a/picasso/api/controllers/tasks.py +++ /dev/null @@ -1,96 +0,0 @@ -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from aiohttp import web - -# from ...models import app as app_model - -from aioservice.http import controller -from aioservice.http import requests - -# from ...common import config - - -# TODO(denismakogon): disabled until -# https://github.com/iron-io/functions/issues/275 -class TasksV1Controller(controller.ServiceController): - - controller_name = "tasks" - version = "v1" - - # TODO(denismakogon): - # - define subapp to process requests to tasks API: - # * extract tasks V1 controller to subapp - # - on each request check if route is public our private - # * reject with 401 if route is private - # * accept with 200 if route is public - @requests.api_action( - method='GET', route='{project_id}/tasks') - async def list(self, request, **kwargs): - """ - --- - description: Listing tasks - tags: - - Runnable tasks - produces: - - application/json - responses: - "401": - description: Not authorized. - "405": - description: Not implemented - """ - # c = config.Config.config_instance() - # fnclient = c.functions_client - # project_id = request.match_info.get('project_id') - # stored_apps = await app_model.Apps.find_by(project_id=project_id) - # final = [] - # for app in stored_apps: - # fn_app = await fnclient.apps.show(app.name, loop=c.event_loop) - - return web.json_response(data={ - "error": { - "message": "Not supported" - } - }, status=405) - - @requests.api_action( - method='GET', route='{project_id}/tasks/{task}') - async def show(self, request, **kwargs): - """ - --- - description: Pulling specific tasks by its ID - tags: - - Runnable tasks - produces: - - application/json - responses: - "401": - description: Not authorized. - "405": - description: Not implemented - """ - # c = config.Config.config_instance() - # fnclient = c.functions_client - # project_id = request.match_info.get('project_id') - # stored_apps = await app_model.Apps.find_by(project_id=project_id) - # final = [] - # for app in stored_apps: - # fn_app = await fnclient.apps.show(app.name, loop=c.event_loop) - - return web.json_response(data={ - "error": { - "message": "Not supported" - } - }, status=405) diff --git a/picasso/tests/functional/base.py b/picasso/tests/functional/base.py index 4e3db03..7bad210 100644 --- a/picasso/tests/functional/base.py +++ b/picasso/tests/functional/base.py @@ -21,7 +21,6 @@ from aioservice.http import service from ...api.controllers import apps from ...api.controllers import routes from ...api.controllers import runnable -from ...api.controllers import tasks from ...api.middleware import content_type from ...common import config @@ -40,7 +39,6 @@ class FunctionalTestsBase(base.PicassoTestsBase, testtools.TestCase): [ apps.AppV1Controller, routes.AppRouteV1Controller, - tasks.TasksV1Controller, runnable.RunnableV1Controller, ], middleware=[ content_type.content_type_validator diff --git a/service/picasso_api.py b/service/picasso_api.py index 6f370cf..f591750 100644 --- a/service/picasso_api.py +++ b/service/picasso_api.py @@ -24,7 +24,6 @@ from aioservice.http import service from picasso.api.controllers import apps from picasso.api.controllers import routes from picasso.api.controllers import runnable -from picasso.api.controllers import tasks from picasso.api.middleware import content_type from picasso.api.middleware import keystone @@ -48,7 +47,6 @@ class API(service.HTTPService): apps.AppV1Controller, routes.AppRouteV1Controller, runnable.RunnableV1Controller, - tasks.TasksV1Controller ], middleware=[ keystone.auth_through_token, content_type.content_type_validator