minos.aggregate.entities.refs.models

Classes

Ref

Model Reference.

class Ref[source]

Bases: DeclarativeModel, UUID, Generic[MT]

Model Reference.

data: Union[MT, UUID]
__init__(data, *args, **kwargs)[source]

Class constructor.

Parameters
  • kwargs – Named arguments to be set as model attributes.

  • data (Union[MT, UUID]) –

property int: int

Get the UUID as a 128-bit integer.

Returns

An integer value.

property is_safe: uuid.SafeUUID

Get an enum indicating whether the UUID has been generated in a way that is safe.

Returns

A SafeUUID value.

classmethod encode_schema(encoder, target, **kwargs)[source]

Encode schema with the given encoder.

Parameters
  • encoder (SchemaEncoder) – The encoder instance.

  • target (Any) – An optional pre-encoded schema.

Returns

The encoded schema of the instance.

Return type

Any

classmethod decode_schema(decoder, target, **kwargs)[source]

Decode schema with the given encoder.

Parameters
  • decoder (SchemaDecoder) – The decoder instance.

  • target (Any) – The schema to be decoded.

Returns

The decoded schema as a type.

Return type

ModelType

static encode_data(encoder, target, **kwargs)[source]

Encode data with the given encoder.

Parameters
  • encoder (DataEncoder) – The encoder instance.

  • target (Any) – An optional pre-encoded data.

Returns

The encoded data of the instance.

Return type

Any

classmethod decode_data(decoder, target, type_, **kwargs)[source]

Decode data with the given decoder.

Parameters
  • decoder (DataDecoder) – The decoder instance.

  • target (Any) – The data to be decoded.

  • type – The data type.

  • type_ (ModelType) –

Returns

A decoded instance.

Return type

Ref

property uuid: uuid.UUID

Get the UUID that identifies the Model.

Returns

property data_cls: Optional[type]

Get data class if available.

Returns

A model type.

async resolve(force=False, **kwargs)[source]

Resolve the instance.

Parameters
  • force (bool) – If True, the resolution will be performed also if it is not necessary.

  • kwargs – Additional named arguments.

Returns

This method does not return anything.

Return type

None

property resolved: bool

Check if the instance is already resolved.

Returns

True if resolved or False otherwise.

property avro_bytes: bytes

Generate bytes representation of the current instance.

Returns

A bytes object.

property avro_data: dict[str, Any]

Compute the avro data of the model.

Returns

A dictionary object.

avro_schema = {'logicalType': 'uuid', 'type': 'string'}
property avro_str: str

Generate bytes representation of the current instance.

Returns

A bytes object.

property bytes
property bytes_le
classname = 'minos.aggregate.entities.refs.models.Ref'
property clock_seq
property clock_seq_hi_variant
property clock_seq_low
property fields: dict[str, minos.common.model.fields.Field]

Fields getter

classmethod from_avro(schema, data)

Build a new instance from the avro schema and data.

Parameters
  • schema (Any) – The avro schema of the model.

  • data (Any) – The avro data of the model.

Returns

A new DynamicModel instance.

Return type

T

classmethod from_avro_bytes(raw, batch_mode=False, **kwargs)

Build a single instance or a sequence of instances from bytes.

Parameters
  • raw (bytes) – A bytes representation of the model.

  • batch_mode (bool) – If True the data is processed as a list of models, otherwise the data is processed as a single model.

  • kwargs – Additional named arguments.

Returns

A single instance or a sequence of instances.

Return type

Union[T, list[~T]]

classmethod from_avro_str(raw, **kwargs)

Build a single instance or a sequence of instances from bytes

Parameters

raw (str) – A str representation of the model.

Returns

A single instance or a sequence of instances.

Return type

Union[T, list[~T]]

classmethod from_model_type(model_type, *args, **kwargs)

Build a DeclarativeModel from a ModelType.

Parameters
  • model_type (ModelType) – ModelType object containing the model structure.

  • args – Positional arguments to be passed to the model constructor.

  • kwargs – Named arguments to be passed to the model constructor.

Returns

A new DeclarativeModel instance.

Return type

T

classmethod from_typed_dict(typed_dict, *args, **kwargs)

Build a Model from a TypeDict and data.

Parameters
  • typed_dict (TypedDict) – TypeDict object containing the DTO’s structure

  • args – Positional arguments to be passed to the model constructor.

  • kwargs – Named arguments to be passed to the model constructor.

Returns

A new DataTransferObject instance.

Return type

T

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
property hex
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
model_type

alias of Ref

property node
property time
property time_hi_version
property time_low
property time_mid
classmethod to_avro_bytes(models)

Create a bytes representation of the given object instances.

Parameters

models (list[~T]) – A sequence of minos models.

Returns

A bytes object.

Return type

bytes

classmethod to_avro_str(models)

Build the avro string representation of the given object instances.

Parameters

models (list[~T]) – A sequence of minos models.

Returns

A bytes object.

Return type

str

type_hints = {'data': typing.Union[~MT, uuid.UUID]}
type_hints_parameters = (~MT,)
property urn
values() an object providing a view on D's values
property variant
property version