fastiot.core.data_models module

pydantic model fastiot.core.data_models.FastIoTData[source]

Basemodel for all data types / data models to be transferred over the broker between the services. This is basically a Pydantic model with the additional handling of subjects. So any Pydantic model should work here, as long as it can be serialized using the library msgpack.

The subject is constructed from the model name, e.g. if your data model is called MySpecialModel a subject v1.my_special_subject will be created. If you want to have more control over the subject name you may overwrite the method fastiot.core.data_models.FastIoTData.get_subject() in your data model or create a new model based on Pydantic’s pydantic.BaseModel. See Publish, subscribe, request and reply in your service for more details about publish and subscribe.

For your own data models please use fastiot.core.data_models.FastIoTPublish for data that is simply published over the broker. For Request and Response please use fastiot.core.data_models.FastIoTRequest and fastiot.core.data_models.FastIoTResponse.

This class also implements the magic methode __setattr__, there is a known bug in BaseModel, the private attributes cannot be set with the @property, this overrode methode makes it possible.

validator set_timezones  »  all fields[source]
pydantic model fastiot.core.data_models.FastIoTPublish[source]

Base datatype for publishing data. Please refer to Creating your own data types for more information about creating your own data types.

classmethod get_subject(name='')[source]

This method returns the corresponding subject for the data model as fastiot.core.data_models.Subject.

Parameters:

name (str) – The name of the subject. Please pay special attention to this parameter: The default is set to "". This works well for data models without hierarchies. In this case you will just subscribe to v1.my_special_data_model. If you use many sensors, like in the data model fastiot.msg.ting.Thing you have to provide a name. Then you can subscribe to v1.thing.my_sensor. If you want to subscribe to all sensors use * as name. See more in Publish, subscribe, request and reply in your service

Return type:

Subject

pydantic model fastiot.core.data_models.FastIoTResponse[source]

Base datatype for answering requests based on :class: fastiot.core.data_models.FastIoTRequest. Please refer to Creating your own data types for more information about creating your custom data types.

classmethod get_subject()[source]
pydantic model fastiot.core.data_models.FastIoTRequest[source]

Base datatype for handling requests. Please refer to Creating your own data types for more information about creating your own data types.

classmethod get_reply_subject(name='')[source]
This method returns the corresponding reply subject for the data model as

fastiot.core.data_models.ReplySubject.

Parameters:

name (str) – The name of the subject. Please pay special attention to this parameter: The default is set to "". This works well for data models without hierarchies. In this case you will just subscribe to v1.my_special_data_model. If you use many sensors, like in the data model fastiot.msg.ting.Thing you have to provide a name. Then you can subscribe to v1.thing.my_sensor. If you want to subscribe to all sensors use * as name. See more in Publish, subscribe, request and reply in your service

Return type:

ReplySubject

pydantic model fastiot.core.data_models.Subject[source]

General model to handle subjects for subscriptions within the framework.

field name: str [Required]

Name of the subject, s. fastiot.core.data_models.FastIoTData.get_subject() for details about subscription names.

field msg_cls: Type[Union[FastIoTData, dict]] [Required]

Datatype the message will provide.

pydantic model fastiot.core.data_models.ReplySubject[source]

Model for handle subject subscription which also have a reply to cls

field reply_cls: Type[Union[FastIoTData, dict]] [Required]

Set to a datatype, not the default None to expect a reply in this datatype.

make_generic_reply_inbox()[source]
Return type:

Subject

get_reply_inbox(reply_to)[source]
Return type:

Subject