1import abc
2import typing as t
3
4from typing_extensions import Protocol
5
6
7class Framework(Protocol):
8 @staticmethod
9 @abc.abstractmethod
10 def is_framework_response(response: t.Any) -> bool:
11 """Return True if provided response is a framework type"""
12 raise NotImplementedError
13
14 @classmethod
15 @abc.abstractmethod
16 def connexion_to_framework_response(cls, response):
17 """Cast ConnexionResponse to framework response class"""
18 raise NotImplementedError
19
20 @classmethod
21 @abc.abstractmethod
22 def build_response(
23 cls,
24 data: t.Any,
25 *,
26 content_type: str = None,
27 headers: dict = None,
28 status_code: int = None
29 ):
30 raise NotImplementedError
31
32 @staticmethod
33 @abc.abstractmethod
34 def get_request(*args, **kwargs):
35 """Return a framework request from the context."""
36 raise NotImplementedError
37
38 @staticmethod
39 @abc.abstractmethod
40 def get_body(request):
41 """Get body from a framework request"""
42 raise NotImplementedError