Source code for luna_api.app.handlers.tasks_proxy_handler

from luna3.common.requests import makeRequest

from app.handlers.base_handler import TasksServiceBaseHandler
from crutches_on_wheels.cow.utils.streamer import streamResponse


[docs]class TaskProxyHandler(TasksServiceBaseHandler): """ Proxy task handler. GET: See `spec_get_task`_. .. _`spec_get_task`: _static/api.html#operation/getTask PATCH: See `spec_cancel_task`_. .. _`spec_cancel_task`: _static/api.html#operation/cancelTask DELETE: See `spec_delete_task`_. .. _`spec_delete_task`: _static/api.html#operation/deleteTask """ allowedMethods = ("GET", "PATCH", "DELETE")
[docs]class TasksProxyHandler(TasksServiceBaseHandler): """ Proxy tasks handler.See `spec_get_tasks`_. .. _`spec_get_tasks`: _static/api.html#operation/getTasks """ allowedMethods = ("GET",)
[docs]class TasksCountProxyHandler(TasksServiceBaseHandler): """ Proxy tasks count handler. See `spec_get_tasks_count`_. .. _`spec_get_tasks_count`: _static/api.html#operation/getTasksCount """ allowedMethods = ("GET",)
[docs]class TaskResultProxyHandler(TasksServiceBaseHandler): """ Proxy task result handler. See `spec_get_task_result`_. .. _`spec_get_task_result`: _static/api.html#operation/getTaskResult """ allowedMethods = ("GET",)
[docs] async def get(self, taskId): """ Proxy request with GET method to luna-tasks. See `spec_get_task_result`_. .. spec_get_task_result: _static/api.html#operation/getTaskResult """ self.request.streamResponse = True self.checkTokenPermissions() url = self.prepareUrl() preparedRequest = await self.prepareProxyRequest() reply = await makeRequest( url=url, method=self.request.method, queryParams=preparedRequest.query, headers=preparedRequest.headers, asyncRequest=True, connectTimeout=self.serviceTimeouts.connectTimeout, sockConnectTimeout=self.serviceTimeouts.sockConnectTimeout, sockReadTimeout=self.serviceTimeouts.sockReadTimeout, session=self.session, totalTimeout=0, stream=True, ) async with reply.sendRequest() as taskResp: statusCode, error = await streamResponse( request=self.request, response=taskResp, headers=self.filterAllowedHeaders(taskResp.headers), ) if statusCode != 200: return self.error(statusCode, error)
[docs]class TaskSubTaskProxyHandler(TasksServiceBaseHandler): """ Proxy task result handler. See `spec_get_task_sub_tasks`_. .. _`spec_get_task_sub_tasks`: _static/api.html#operation/getSubTasks """ allowedMethods = ("GET",)
[docs]class TaskErrorProxyHandler(TasksServiceBaseHandler): """ Proxy task result handler. See `spec_get_task_errors`_. .. _`spec_get_task_errors`: _static/api.html#operation/getErrors """ allowedMethods = ("GET",)
[docs]class TasksErrorsProxyHandler(TasksServiceBaseHandler): """ Proxy task handler. See `spec_tasks_errors`_. .. _`spec_tasks_errors`: _static/api.html#operation/getTasksErrors """ allowedMethods = ("GET",)
[docs]class TasksErrorsCountProxyHandler(TasksServiceBaseHandler): """ Proxy task handler. See `spec_tasks_errors_count`_. .. _`spec_tasks_errors_count`: _static/api.html#operation/getTasksErrorsCount """ allowedMethods = ("GET",)
[docs]class TasksErrorProxyHandler(TasksServiceBaseHandler): """ Proxy task handler. See `spec_tasks_error`_. .. _`spec_tasks_error`: _static/api.html#operation/getTasksError """ allowedMethods = ("GET",)