minos.plugins.aiohttp.requests

Classes

AioHttpRequest

Aiohttp Request class.

AioHttpResponse

Aiohttp Response class.

Exceptions

AioHttpResponseException

Aiohttp Response Exception class.

class AioHttpRequest[source]

Bases: HttpRequest

Aiohttp Request class.

__init__(raw, *args, **kwargs)[source]
Parameters

raw (Request) –

raw
property raw_request: aiohttp.web_request.Request

Get the raw request within the instance.

Returns

An aiohttp.web.Request instance.

property user: Optional[uuid.UUID]

Returns the UUID of the user making the Request.

headers

Get the headers of the request.

Returns

A dictionary in which keys are str instances and values are str instances.

property has_content: bool

Check if the request has content.

Returns

True if it has content or False otherwise.

property content_type: str

Get the content type.

Returns

A str value.

property has_params: bool

Check if the request has params.

Returns

True if it has params or False otherwise.

async url_params(type_=None, **kwargs)[source]

Get the url params.

Parameters
  • type – Optional type or str (classname) that defines the request content type.

  • kwargs – Additional named arguments.

  • type_ (Optional[Union[type, str]]) –

Returns

A dictionary instance.

Return type

Any

property has_url_params: bool

Check if the request has url params.

Returns

True if it has url params or False otherwise.

async query_params(type_=None, **kwargs)[source]

Get the query params.

Parameters
  • type – Optional type or str (classname) that defines the request content type.

  • kwargs – Additional named arguments.

  • type_ (Optional[Union[type, str]]) –

Returns

A dictionary instance.

Return type

Any

property has_query_params: bool

Check if the request has query params.

Returns

True if it has query params or False otherwise.

async content(**kwargs)

Get the request content.

Parameters

kwargs – Additional named arguments.

Returns

The request content.

Return type

Any

async params(**kwargs)

Get the request params.

Parameters

kwargs – Additional named arguments.

Returns

The request params.

Return type

dict[str, Any]

class AioHttpResponse[source]

Bases: HttpResponse

Aiohttp Response class.

async content(**kwargs)[source]

Raw response content.

Parameters

kwargs – Additional named arguments.

Returns

The raw content as a bytes instance.

Return type

Optional[bytes]

__init__(*args, content_type='application/json', **kwargs)
Parameters

content_type (str) –

property content_type: str

Get the content type.

Returns

A str value.

classmethod from_response(response)

Build a new RestRequest from another response.

Parameters

response (Optional[Response]) – The base response.

Returns

A RestResponse instance.

Return type

HttpResponse

property has_content: bool

Check if the request has content.

Returns

True if it has content or False otherwise.

property status: int

The status code of the response.

Returns

An int value.

exception AioHttpResponseException[source]

Bases: HttpResponseException

Aiohttp Response Exception class.

__init__(*args, status=400)
Parameters

status (int) –

__new__(**kwargs)
args
property status: int

The status code of the response.

Returns

An int value.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.