ft3.api package¶
Api Overview¶
Author: dan@1howardcapital.com
Summary: Api module.
Usage¶
$ ft3 api ${PACKAGE_NAME}
- api_from_package(name: str, version: str, api_path: str, include_heartbeat: bool = True, include_version_prefix: bool = False, include_default_response_headers: bool = True, lazy_docs: bool = True) Api¶
Generate a RESTful API from passed python package name.
- runtime_api_from_package(name: str, version: str, api_path: str, include_heartbeat: bool = True, include_version_prefix: bool = False, include_default_response_headers: bool = True) Api¶
Generate a RESTful API with only runtime dispatch metadata.
- class Api(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ComponentOpenAPI OpenAPI Object.
- servers: Field[list[ServerObject] | 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
Objectto 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 indictform).
- class File(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ObjectA file object, useful for serving static files.
- 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 indictform).
- class Handler(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ObjectA simple request handler.
- 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 Header(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ComponentOpenAPI Header Object.
- 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 Request(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ObjectA simple request object.
- 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_',)¶
- 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
idparams forPUTrequests.
- parse_path_params(uri: str, operation: Operation) None¶
Parse path parameters from a matched path uri.
- 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.
- class Response(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ObjectA simple response object.
- 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',)¶
- serialize() bytes | str¶
JSON serialize body if not already a string.
- class SecurityScheme(class_as_dict: dict[str | string[StringType], Any] | None = None, /, **kwargs: Any)¶
Bases:
ComponentOpenAPI Security Scheme Object.
- 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
SecuritySchemeforObject.
- 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_',)¶
Subpackages¶
Submodules¶
- ft3.api.cfg module
- ft3.api.enm module
- ft3.api.exc module
- ft3.api.lib module
- ft3.api.obj module
ApiComponentContentFileHeaderHealthzInfoOperationParameterPathRequestBodyResponseObjectSchemaSchema.type_Schema.format_Schema.descriptionSchema.defaultSchema.enumSchema.requiredSchema.min_lengthSchema.max_lengthSchema.patternSchema.minimumSchema.exclusive_minimumSchema.maximumSchema.exclusive_maximumSchema.multiple_ofSchema.min_itemsSchema.max_itemsSchema.unique_itemsSchema.read_onlySchema.write_onlySchema.items_Schema.propertiesSchema.all_ofSchema.any_ofSchema.one_ofSchema.from_obj()Schema.from_type()Schema.enumerationsSchema.fieldsSchema.hash_fieldsSchema.class_as_dict
SecuritySchemeServerObjectServerVariableTagFILESDEFAULT_RESPONSE_HEADERSREQUEST_HEADERSRESPONSE_HEADERSOBJECTSSECURITY
- ft3.api.typ module
stringstring.capitalize()string.casefold()string.center()string.expandtabs()string.format()string.format_map()string.join()string.ljust()string.lower()string.lstrip()string.partition()string.removeprefix()string.removesuffix()string.replace()string.rjust()string.rpartition()string.rsplit()string.rstrip()string.split()string.splitlines()string.strip()string.swapcase()string.title()string.translate()string.upper()string.zfill()
NoneTypeTypedUnionGenericAlias
- ft3.api.utl module