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
This commit is contained in:
parent
bc5a57c133
commit
fd9224393c
@ -51,11 +51,7 @@ class RunnableMixin(object):
|
|||||||
|
|
||||||
def process_result(res):
|
def process_result(res):
|
||||||
if route.type == "async":
|
if route.type == "async":
|
||||||
_data = {
|
_data = {}
|
||||||
"task_id": res["call_id"],
|
|
||||||
"message": ("App {} async route {} "
|
|
||||||
"execution started".format(app, path))
|
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
_data = {
|
_data = {
|
||||||
"result": res,
|
"result": res,
|
||||||
|
@ -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)
|
|
@ -21,7 +21,6 @@ from aioservice.http import service
|
|||||||
from ...api.controllers import apps
|
from ...api.controllers import apps
|
||||||
from ...api.controllers import routes
|
from ...api.controllers import routes
|
||||||
from ...api.controllers import runnable
|
from ...api.controllers import runnable
|
||||||
from ...api.controllers import tasks
|
|
||||||
from ...api.middleware import content_type
|
from ...api.middleware import content_type
|
||||||
|
|
||||||
from ...common import config
|
from ...common import config
|
||||||
@ -40,7 +39,6 @@ class FunctionalTestsBase(base.PicassoTestsBase, testtools.TestCase):
|
|||||||
[
|
[
|
||||||
apps.AppV1Controller,
|
apps.AppV1Controller,
|
||||||
routes.AppRouteV1Controller,
|
routes.AppRouteV1Controller,
|
||||||
tasks.TasksV1Controller,
|
|
||||||
runnable.RunnableV1Controller,
|
runnable.RunnableV1Controller,
|
||||||
], middleware=[
|
], middleware=[
|
||||||
content_type.content_type_validator
|
content_type.content_type_validator
|
||||||
|
@ -24,7 +24,6 @@ from aioservice.http import service
|
|||||||
from picasso.api.controllers import apps
|
from picasso.api.controllers import apps
|
||||||
from picasso.api.controllers import routes
|
from picasso.api.controllers import routes
|
||||||
from picasso.api.controllers import runnable
|
from picasso.api.controllers import runnable
|
||||||
from picasso.api.controllers import tasks
|
|
||||||
|
|
||||||
from picasso.api.middleware import content_type
|
from picasso.api.middleware import content_type
|
||||||
from picasso.api.middleware import keystone
|
from picasso.api.middleware import keystone
|
||||||
@ -48,7 +47,6 @@ class API(service.HTTPService):
|
|||||||
apps.AppV1Controller,
|
apps.AppV1Controller,
|
||||||
routes.AppRouteV1Controller,
|
routes.AppRouteV1Controller,
|
||||||
runnable.RunnableV1Controller,
|
runnable.RunnableV1Controller,
|
||||||
tasks.TasksV1Controller
|
|
||||||
], middleware=[
|
], middleware=[
|
||||||
keystone.auth_through_token,
|
keystone.auth_through_token,
|
||||||
content_type.content_type_validator
|
content_type.content_type_validator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user