ft3.api.events.obj module

Objects module.

class Error(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

A stimple error message object.

error_message: Field[str]
error_code: Field[Literal[400, 401, 403, 404, 405, 423, 429, 500, 501]]
classmethod from_exception(exception: ExceptionType | type[ExceptionType]) Self

Populate error object from an exception.

enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('error_code', 'error_message')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Handler(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

A simple request handler.

api: Field[Api]
file_paths: Field[list[str]]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('api', 'file_paths')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Pattern

Bases: object

Compiled regex patterns.

PathId = re.compile('({[a-zA-Z0-9]{1,256}})')

Matches resource ids within a path uri.

class Request(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

A simple request object.

id_: Field[str]
url: Field[str]
path: Field[str]
method: Field[str]
headers: Field[dict[str, str]]
body: Field[Any]
path_params: Field[dict[str | string[StringType], str]]
query_params: Field[dict[str | string[StringType], Any]]
parse_body(operation: Operation, obj_: type[objects.Object] | None = None) Never | None

Parse JSON body from url string and optionally an Object.

Automatically handles translation and injection of id params for PUT requests.

parse_query_params(method: string[snake_case], operation: Operation, obj_: type[objects.Object] | None = None) None

Parse query parameters from url string and optionally an Object.

parse_path_params(uri: str, operation: Operation) None

Parse path parameters from a matched path uri.

enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('body', 'headers', 'id_', 'method', 'path', 'path_params', 'query_params', 'url')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ('id_',)
class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Response(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

A simple response object.

request_id: Field[str]
status_code: Field[Literal[200, 201, 204, 301, 400, 401, 403, 404, 405, 423, 429, 500, 501]]
headers: Field[dict[str, str]]
body: Field[Any]
serialize() bytes | str

JSON serialize body if not already a string.

enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('body', 'headers', 'request_id', 'status_code')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ('request_id',)
class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Api(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI OpenAPI Object.

info: Field[Info]
openapi: Field[str]
paths: Field[dict[str, Path]]
tags: Field[list[Tag]]
servers: Field[list[ServerObject] | None]
components: Field[dict[str, dict[str, Any]] | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'components', 'info', 'openapi', 'paths', 'servers', 'tags')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
classmethod register(obj_: type[ObjectType]) type[ObjectType]

Register an Object to be served from the API.

class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Component(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

OpenAPI Component.

_ref_: Field[string[StringType] | str | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_',)
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Content(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI content for ContentType.

schema: Field[Schema | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'schema')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class File(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

A file object, useful for serving static files.

path: Field[str]

The path at which to serve the file.

content: Field[bytes | str]

File content.

content_type: Field[str]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('content', 'content_type', 'path')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Header(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Header Object.

description: Field[str | None]
schema: Field[Schema | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'description', 'schema')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
classmethod request(name: str, description: str | None, *methods: str) Callable[[type[ObjectType]], type[ObjectType]]

Register a request header for Object.

classmethod response(name: str, description: str | None, *methods: str) Callable[[type[ObjectType]], type[ObjectType]]

Register a response header for Object.

class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class Healthz(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Object

Default application heartbeat.

status: Field[str]

Application status.

enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('status',)
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Info(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Info Object.

title: Field[str]
version: Field[str]
summary: Field[str | None]
description: Field[str | None]
terms_of_service: Field[str | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'description', 'summary', 'terms_of_service', 'title', 'version')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Operation(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Operation Object.

description: Field[str | None]
summary: Field[str | None]
tags: Field[list[str] | None]
parameters: Field[list[Parameter] | None]
request_body: Field[RequestBody | None]
responses: Field[dict[str, ResponseObject] | None]
security: Field[list[dict[str, list[str]]] | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'description', 'parameters', 'request_body', 'responses', 'security', 'summary', 'tags')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
property path_uri: str

Path URI.

class Parameter(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Parameter Object.

in_: Field[str]
name: Field[str | string[StringType]]
description: Field[str | None]
required: Field[bool]
deprecated: Field[bool | None]
schema: Field[Schema | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {'in_': ('path', 'query', 'header', 'cookie')}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'deprecated', 'description', 'in_', 'name', 'required', 'schema')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ('name',)
class Path(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Path Item Object.

_resource_: Field[type[Object]]
summary: Field[str]
description: Field[str | None]
delete: Field[Operation | None]
get_: Field[Operation | None]
options: Field[Operation | None]
patch: Field[Operation | None]
post: Field[Operation | None]
put: Field[Operation | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', '_resource_', 'delete', 'description', 'get_', 'options', 'patch', 'post', 'put', 'summary')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
update_options(cls: type[Object], include_default_response_headers: bool) None

Update options operation for the endpoint.

class RequestBody(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Request Body Object.

description: Field[str | None]
content: Field[dict[Literal['*/*', 'text/html', 'image/x-icon', 'application/json', 'image/png', 'text/plain'], Content]]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'content', 'description')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class ResponseObject(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Request Body Object.

description: Field[str]
headers: Field[dict[str, Header] | None]
content: Field[dict[Literal['*/*', 'text/html', 'image/x-icon', 'application/json', 'image/png', 'text/plain'], Content | None]]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'content', 'description', 'headers')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Schema(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Schema Object.

type_: Field[list[Literal['array', 'boolean', 'integer', 'null', 'number', 'object', 'string']] | None]
format_: Field[Literal['boolean'] | Literal['byte'] | Literal['date'] | Literal['datetime'] | Literal['double'] | Literal['float'] | Literal['int32'] | Literal['uuid'] | None]
description: Field[str | None]
default: Field[Any | None]
enum: Field[Any | None]
required: Field[list[string[camelCase]] | None]
min_length: Field[int | None]
max_length: Field[int | None]
pattern: Field[str | None]
minimum: Field[float | None]
exclusive_minimum: Field[bool | None]
maximum: Field[float | None]
exclusive_maximum: Field[bool | None]
multiple_of: Field[float | None]
min_items: Field[int | None]
max_items: Field[int | None]
unique_items: Field[bool | None]
read_only: Field[bool | None]
write_only: Field[bool | None]
items_: Field[Schema | None]
properties: Field[dict[string[camelCase], Schema] | None]
all_of: Field[list[Schema] | None]
any_of: Field[list[Schema] | None]
one_of: Field[list[Schema] | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {'format_': ('boolean', 'byte', 'date', 'datetime', 'double', 'float', 'int32', 'uuid', None), 'type_': ('array', 'boolean', 'integer', 'null', 'number', 'object', 'string', None)}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'all_of', 'any_of', 'default', 'description', 'enum', 'exclusive_maximum', 'exclusive_minimum', 'format_', 'items_', 'max_items', 'max_length', 'maximum', 'min_items', 'min_length', 'minimum', 'multiple_of', 'one_of', 'pattern', 'properties', 'read_only', 'required', 'type_', 'unique_items', 'write_only')
classmethod from_obj(obj: type[Object], /, **kwargs: Any) Schema

Parse Schema definition from Object.

classmethod from_type(*, type_: Any = None, **kwargs: Any) Schema

Parse Schema definition from python type.

hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class SecurityScheme(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Security Scheme Object.

type_: Field[str]
in_: Field[str | None]
scheme: Field[str | None]
name_: Field[str]
description: Field[str | None]
content: Field[dict[Literal['*/*', 'text/html', 'image/x-icon', 'application/json', 'image/png', 'text/plain'], Content]]
classmethod api_key(name: str, description: str | None, *methods: str) Callable[[type[ObjectType]], type[ObjectType]]

Register API Key SecurityScheme for Object.

enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {'in_': ('header', 'query', 'cookie', None), 'scheme': ('basic', 'bearer', None), 'type_': ('http', 'apiKey', 'oauth2', 'openIdConnect')}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'content', 'description', 'in_', 'name_', 'scheme', 'type_')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ('name_',)
class_as_dict: lib.t.Final[lib.t.Optional[dict[typ.AnyString, lib.t.Any]]] = {}

Instantiate class directly from passed dict (assumed to be version of class in dict form).

class ServerObject(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Server Object.

url: Field[str]
description: Field[str | None]
variables: Field[dict[str, ServerVariable] | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'description', 'url', 'variables')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class ServerVariable(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Server Variable Object.

default: Field[str]
description: Field[str | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'default', 'description')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ()
class Tag(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)

Bases: Component

OpenAPI Tag Object.

name: Field[str]
description: Field[str | None]
enumerations: lib.t.ClassVar[dict[str, tuple[typ.Primitive, ...]]] = {}
fields: lib.t.ClassVar[typ.FieldsTuple] = ('_ref_', 'description', 'name')
hash_fields: lib.t.ClassVar[typ.FieldsTuple] = ('name',)