#43 - fix the issues reported by flake8
This commit is contained in:
@@ -7,26 +7,25 @@ import asyncio
|
||||
import inspect
|
||||
import json
|
||||
from asyncio import AbstractEventLoop
|
||||
from typing import Dict, List, Callable, Coroutine, Any
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Coroutine, Dict, List
|
||||
|
||||
from aio_pika.abc import (
|
||||
AbstractExchange,
|
||||
AbstractRobustChannel,
|
||||
AbstractRobustConnection,
|
||||
AbstractExchange,
|
||||
)
|
||||
from aiohttp import ClientSession, ClientResponse
|
||||
from dataclasses import dataclass
|
||||
from aiohttp import ClientResponse, ClientSession
|
||||
from fastapi import HTTPException
|
||||
from pydantic import BaseModel
|
||||
from starlette.responses import FileResponse
|
||||
|
||||
from amqp.adapter import serializer, pydantic_serializer
|
||||
from amqp.adapter.data_parser import AMQDataParser
|
||||
from amqp.adapter import serializer
|
||||
from amqp.adapter.data_response_factory import DataResponseFactory
|
||||
from amqp.adapter.file_handler import FileHandler, StreamingFileHandler
|
||||
from amqp.adapter.logging_utils import logging_error, logging_debug, logging_info
|
||||
from amqp.adapter.logging_utils import logging_debug, logging_error, logging_info
|
||||
from amqp.config.amq_configuration import AMQConfiguration
|
||||
from amqp.model.model import DataMessage, DataResponse, AMQErrorMessage
|
||||
from amqp.model.model import AMQErrorMessage, DataMessage, DataResponse
|
||||
from amqp.router.router_base import AMQ_REPLY_TO_EXCHANGE
|
||||
from amqp.router.utils import await_result
|
||||
|
||||
@@ -97,7 +96,7 @@ async def _convert_file_response(
|
||||
_exchange, obj.path, _routing_key, loop
|
||||
)
|
||||
# as above, but luckily this time we don't need to wait for the result
|
||||
_future = asyncio.run_coroutine_threadsafe(_channel.close(), loop)
|
||||
asyncio.run_coroutine_threadsafe(_channel.close(), loop)
|
||||
return json.dumps(
|
||||
{
|
||||
"files": [
|
||||
@@ -262,7 +261,7 @@ class CleverThisServiceAdapter:
|
||||
:param auth_user: user authenticated by the API Gateway, as UserSchem
|
||||
:return: DataResponse to be sent back to the API Gateway via AMQP
|
||||
"""
|
||||
return await self.handle_possible_form(
|
||||
return await self._authorize_forward_request(
|
||||
message,
|
||||
self.session.put(
|
||||
f"http://{self.service_host}:{self.service_port}{message.path}",
|
||||
@@ -280,7 +279,7 @@ class CleverThisServiceAdapter:
|
||||
:param auth_user: user authenticated by the API Gateway, as UserSchem
|
||||
:return: DataResponse to be sent back to the API Gateway via AMQP
|
||||
"""
|
||||
return await self.handle_possible_form(
|
||||
return await self._authorize_forward_request(
|
||||
message,
|
||||
self.session.post(
|
||||
f"http://{self.service_host}:{self.service_port}{message.path}",
|
||||
@@ -290,10 +289,14 @@ class CleverThisServiceAdapter:
|
||||
auth_user,
|
||||
)
|
||||
|
||||
async def handle_possible_form(
|
||||
async def _authorize_forward_request(
|
||||
self, message: DataMessage, request_coroutine, auth_user: Any
|
||||
) -> DataResponse:
|
||||
_args = AMQDataParser.parse_request_body(message)
|
||||
"""
|
||||
This method is used to authorize the request and forward it to the CleverThis Service API.
|
||||
However, it is only used for loose / 3rd party mode of coupling with the Service
|
||||
"""
|
||||
# AMQDataParser.parse_request_body(message)
|
||||
return await request_coroutine
|
||||
|
||||
async def head(self, message: DataMessage, auth_user: Any) -> DataResponse:
|
||||
|
||||
Reference in New Issue
Block a user