Schema¶
Schema entities are generated from the upstream schema specification.
Every API version has separate schema entities, to allow best-in-class typing support
for message models. Schema entities are exposed in sub-modules under the
kio.schema package, following this structure:
kio.schema.<api-name>.<version>.<type>. So for example, if you want to use the
response for version 12 of the metadata API, you would import it like so.
from kio.schema.metadata.v12.request import MetadataRequest
Introspection protocols¶
- class kio.static.protocol.Entity(*args, **kwargs)[source]¶
Bases:
DataclassInstance,ProtocolAll schema entities adhere to this protocol.
- __flexible__: ClassVar[bool]¶
Whether the API version is “flexible” or not, see upstream protocol documentation.
- class kio.static.protocol.Payload(*args, **kwargs)[source]¶
Bases:
DataclassInstance,ProtocolAll payload entities, i.e. requests and responses, adhere to this protocol.
- __flexible__: ClassVar[bool]¶
Whether the API version is “flexible” or not, see upstream protocol documentation.
- property __header_schema__: type[RequestHeader | RequestHeader | RequestHeader | ResponseHeader | ResponseHeader]¶
The header entity type that should be used when sending or receiving this payload.
- kio.static.protocol.ResponsePayload: TypeAlias = kio.static.protocol.HeaderV0ResponsePayload | kio.static.protocol.HeaderV1ResponsePayload¶
Convenient union type of all possible response payloads.
- kio.static.protocol.RequestPayload: TypeAlias = kio.static.protocol.HeaderV0RequestPayload | kio.static.protocol.HeaderV1RequestPayload | kio.static.protocol.HeaderV2RequestPayload¶
Convenient union type of all possible request payloads.
- kio.static.protocol.RequestHeader: TypeAlias = kio.schema.request_header.v0.header.RequestHeader | kio.schema.request_header.v1.header.RequestHeader | kio.schema.request_header.v2.header.RequestHeader¶
Convenient union type of all possible request header types.
- kio.static.protocol.ResponseHeader: TypeAlias = kio.schema.response_header.v0.header.ResponseHeader | kio.schema.response_header.v1.header.ResponseHeader¶
Convenient union type of all possible response header types.
- kio.static.protocol.Header: TypeAlias = kio.schema.request_header.v0.header.RequestHeader | kio.schema.request_header.v1.header.RequestHeader | kio.schema.request_header.v2.header.RequestHeader | kio.schema.response_header.v0.header.ResponseHeader | kio.schema.response_header.v1.header.ResponseHeader¶
Convenient union type of all possible request and response header types.
- class kio.static.protocol.HeaderV0RequestPayload(*args, **kwargs)[source]¶
Bases:
Payload,ProtocolProtocol describing a request payload entity type with a V0 header.
- class kio.static.protocol.HeaderV1RequestPayload(*args, **kwargs)[source]¶
Bases:
Payload,ProtocolProtocol describing a request payload entity type with a V1 header.
- class kio.static.protocol.HeaderV2RequestPayload(*args, **kwargs)[source]¶
Bases:
Payload,ProtocolProtocol describing a request payload entity type with a V2 header.
Primitives¶
- class kio.static.primitive.PhantomStr(instance)[source]¶
Bases:
str,PhantomPhantom base for nominal string types (e.g. TopicName, GroupId).
Any plain
strsatisfiesisinstance(x, SubClass)at runtime, so the Rust decoder can hand over a raw Pythonstrwithout an extra wrapping call-object allocation.
- class kio.static.primitive.TZAwareMicros(instance)[source]¶
Bases:
datetime,PhantomType describing all datetime.datetime instances that are timezone aware, and have a non-negative unix timestamp representation.
Timezone awareness means any object lacking timezone data is excluded.
Kafka uses -1 to represent NULL, so negative unix timestamps are not supported.
- class kio.static.primitive.TZAware(instance)[source]¶
Bases:
datetime,PhantomType describing all datetime.datetime instances that are timezone aware, have millisecond precision, and have a non-negative unix timestamp representation.
Timezone awareness means any object lacking timezone data is excluded.
Millisecond precision means any object with microsecond != 0 is excluded.
Kafka uses -1 to represent NULL, so negative unix timestamps are not supported.
Types¶
- class kio.schema.types.GroupId(instance)[source]¶
Bases:
PhantomStr
- class kio.schema.types.TopicName(instance)[source]¶
Bases:
PhantomStr
- class kio.schema.types.TransactionalId(instance)[source]¶
Bases:
PhantomStr