labthings_fastapi.thing_description._model ========================================== .. py:module:: labthings_fastapi.thing_description._model .. autoapi-nested-parse:: Pydantic Models to describe DataSchema. :ref:`wot_td` defines a schema for describing Things, using JSONSchema-like syntax for data types. This file contains pydantic models that describe that schema. For the meaning of the various objects, please refer to the td_schema_definition_ within the W3C standard. .. _td_schema_definition: https://www.w3.org/TR/wot-thing-description11/ This file was automatically generated, but has been customised to improve the types and simplify/combine objects. I've added URLs to point to the schema documentation. These start with ``https://www.w3.org/TR/wot-thing-description11/``, meaning they refer to v1.1, the version current when it was written. Attributes ---------- .. autoapisummary:: labthings_fastapi.thing_description._model.AnyUri labthings_fastapi.thing_description._model.Description labthings_fastapi.thing_description._model.Descriptions labthings_fastapi.thing_description._model.Title labthings_fastapi.thing_description._model.Titles labthings_fastapi.thing_description._model.Security labthings_fastapi.thing_description._model.Scopes labthings_fastapi.thing_description._model.TypeDeclaration labthings_fastapi.thing_description._model.THING_CONTEXT_URL labthings_fastapi.thing_description._model.THING_CONTEXT_URL_v1 labthings_fastapi.thing_description._model.ThingContextType labthings_fastapi.thing_description._model.ThingContext labthings_fastapi.thing_description._model.Op labthings_fastapi.thing_description._model.OpT labthings_fastapi.thing_description._model.Links labthings_fastapi.thing_description._model.SecurityScheme labthings_fastapi.thing_description._model.ThingDescription Classes ------- .. autoapisummary:: labthings_fastapi.thing_description._model.Version labthings_fastapi.thing_description._model.Subprotocol labthings_fastapi.thing_description._model.Type labthings_fastapi.thing_description._model.DataSchema labthings_fastapi.thing_description._model.Response labthings_fastapi.thing_description._model.PropertyOp labthings_fastapi.thing_description._model.ActionOp labthings_fastapi.thing_description._model.EventOp labthings_fastapi.thing_description._model.RootOp labthings_fastapi.thing_description._model.Form labthings_fastapi.thing_description._model.InteractionAffordance labthings_fastapi.thing_description._model.PropertyAffordance labthings_fastapi.thing_description._model.ActionAffordance labthings_fastapi.thing_description._model.EventAffordance labthings_fastapi.thing_description._model.LinkElement labthings_fastapi.thing_description._model.SecuritySchemeEnum labthings_fastapi.thing_description._model.In labthings_fastapi.thing_description._model.Qop labthings_fastapi.thing_description._model.Flow labthings_fastapi.thing_description._model.BaseSecurityScheme labthings_fastapi.thing_description._model.NoSecurityScheme labthings_fastapi.thing_description._model.NameAndIn labthings_fastapi.thing_description._model.BasicSecurityScheme labthings_fastapi.thing_description._model.DigestSecurityScheme labthings_fastapi.thing_description._model.APISecurityScheme labthings_fastapi.thing_description._model.BearerSecurityScheme labthings_fastapi.thing_description._model.PskSecurityScheme labthings_fastapi.thing_description._model.Oauth2SecurityScheme labthings_fastapi.thing_description._model.WotTdSchema16October2019 Functions --------- .. autoapisummary:: labthings_fastapi.thing_description._model.uses_thing_context Module Contents --------------- .. py:class:: Version(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Version info for a Thing. See https://www.w3.org/TR/wot-thing-description11/#versioninfo. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: instance :type: str .. py:data:: AnyUri .. py:data:: Description .. py:data:: Descriptions .. py:data:: Title .. py:data:: Titles .. py:data:: Security .. py:data:: Scopes .. py:data:: TypeDeclaration .. py:class:: Subprotocol(*args, **kwds) Bases: :py:obj:`enum.Enum` HTTP sub-protocols. .. py:attribute:: longpoll :value: 'longpoll' .. py:attribute:: websub :value: 'websub' .. py:attribute:: sse :value: 'sse' .. py:data:: THING_CONTEXT_URL :value: 'https://www.w3.org/2022/wot/td/v1.1' .. py:data:: THING_CONTEXT_URL_v1 :value: 'https://www.w3.org/2019/wot/td/v1' .. py:data:: ThingContextType .. py:function:: uses_thing_context(v: ThingContextType) -> None Check the URLs in the ThingContextType are valid. This function checks a valid context URL is provided. See the JSONSchema for Thing Description (`td-json-schema-validation.json`) for more details. See https://www.w3.org/TR/wot-thing-description11/#thing Specifically, the ``@context`` property is what this function validates. :param v: the ThingContextType object. :raises ValueError: if the URL is not correct. .. py:data:: ThingContext .. py:class:: Type(*args, **kwds) Bases: :py:obj:`enum.Enum` ``type`` property of a DataSchema. .. py:attribute:: boolean :value: 'boolean' .. py:attribute:: integer :value: 'integer' .. py:attribute:: number :value: 'number' .. py:attribute:: string :value: 'string' .. py:attribute:: object :value: 'object' .. py:attribute:: array :value: 'array' .. py:attribute:: null :value: 'null' .. py:class:: DataSchema(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Base for several classes describing datatypes. See https://www.w3.org/TR/wot-thing-description11/#dataschema. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: field_type :type: Optional[TypeDeclaration] :value: None .. py:attribute:: description :type: Optional[Description] :value: None .. py:attribute:: title :type: Optional[Title] :value: None .. py:attribute:: descriptions :type: Optional[Descriptions] :value: None .. py:attribute:: titles :type: Optional[Titles] :value: None .. py:attribute:: writeOnly :type: Optional[bool] :value: None .. py:attribute:: readOnly :type: Optional[bool] :value: None .. py:attribute:: oneOf :type: Optional[list[DataSchema]] :value: None .. py:attribute:: unit :type: Optional[str] :value: None .. py:attribute:: enum :type: Optional[list] :value: None .. py:attribute:: format :type: Optional[str] :value: None .. py:attribute:: const :type: Optional[Any] :value: None .. py:attribute:: default :type: Optional[Any] :value: None .. py:attribute:: type :type: Optional[Type] :value: None .. py:attribute:: items :type: Optional[Union[DataSchema, List[DataSchema]]] :value: None .. py:attribute:: maxItems :type: Optional[int] :value: None .. py:attribute:: minItems :type: Optional[int] :value: None .. py:attribute:: minimum :type: Optional[Union[int, float]] :value: None .. py:attribute:: maximum :type: Optional[Union[int, float]] :value: None .. py:attribute:: exclusiveMinimum :type: Optional[Union[int, float]] :value: None .. py:attribute:: exclusiveMaximum :type: Optional[Union[int, float]] :value: None .. py:attribute:: multipleOf :type: Optional[Union[int, float]] :value: None .. py:attribute:: properties :type: Optional[Mapping[str, DataSchema]] :value: None .. py:attribute:: required :type: Optional[list[str]] :value: None .. py:attribute:: minLength :type: Optional[int] :value: None .. py:attribute:: maxLength :type: Optional[int] :value: None .. py:attribute:: pattern :type: Optional[str] :value: None .. py:attribute:: contentEncoding :type: Optional[str] :value: None .. py:attribute:: contentMediaType :type: Optional[str] :value: None .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:class:: Response(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#expectedresponse. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: contentType :type: Optional[str] :value: None .. py:class:: PropertyOp(*args, **kwds) Bases: :py:obj:`enum.Enum` ``op`` values for Forms on Properties. See https://www.w3.org/TR/wot-thing-description11/#propertyaffordance .. py:attribute:: readproperty :value: 'readproperty' .. py:attribute:: writeproperty :value: 'writeproperty' .. py:attribute:: observeproperty :value: 'observeproperty' .. py:attribute:: unobserveproperty :value: 'unobserveproperty' .. py:class:: ActionOp(*args, **kwds) Bases: :py:obj:`enum.Enum` ``op`` values for Forms on Actions. See https://www.w3.org/TR/wot-thing-description11/#actionaffordance .. py:attribute:: invokeaction :value: 'invokeaction' .. py:class:: EventOp(*args, **kwds) Bases: :py:obj:`enum.Enum` ``op`` values for Forms on Events. See https://www.w3.org/TR/wot-thing-description11/#eventaffordance .. py:attribute:: subscribeevent :value: 'subscribeevent' .. py:attribute:: unsubscribeevent :value: 'unsubscribeevent' .. py:class:: RootOp(*args, **kwds) Bases: :py:obj:`enum.Enum` ``op`` values for Forms on Things. See https://www.w3.org/TR/wot-thing-description11/#thing .. py:attribute:: readallproperties :value: 'readallproperties' .. py:attribute:: writeallproperties :value: 'writeallproperties' .. py:attribute:: readmultipleproperties :value: 'readmultipleproperties' .. py:attribute:: writemultipleproperties :value: 'writemultipleproperties' .. py:data:: Op .. py:data:: OpT .. py:class:: Form(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel`, :py:obj:`Generic`\ [\ :py:obj:`OpT`\ ] See https://www.w3.org/TR/wot-thing-description11/#form. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: href :type: labthings_fastapi.middleware.url_for.URLFor | AnyUri .. py:attribute:: op :type: Optional[Union[OpT, List[OpT]]] :value: None .. py:attribute:: contentType :type: Optional[str] :value: None .. py:attribute:: contentCoding :type: Optional[str] :value: None .. py:attribute:: subprotocol :type: Optional[Subprotocol] :value: None .. py:attribute:: security :type: Optional[Security] :value: None .. py:attribute:: scopes :type: Optional[Scopes] :value: None .. py:attribute:: response :type: Optional[Response] :value: None .. py:class:: InteractionAffordance(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#interactionaffordance. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: description :type: Optional[Description] :value: None .. py:attribute:: descriptions :type: Optional[Descriptions] :value: None .. py:attribute:: title :type: Optional[Title] :value: None .. py:attribute:: titles :type: Optional[Titles] :value: None .. py:attribute:: forms :type: List[Form] :value: None .. py:attribute:: uriVariables :type: Optional[Dict[str, DataSchema]] :value: None .. py:class:: PropertyAffordance(/, **data: Any) Bases: :py:obj:`InteractionAffordance`, :py:obj:`DataSchema` See https://www.w3.org/TR/wot-thing-description11/#propertyaffordance. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: observable :type: Optional[bool] :value: None .. py:attribute:: forms :type: List[Form[PropertyOp]] :value: None .. py:class:: ActionAffordance(/, **data: Any) Bases: :py:obj:`InteractionAffordance` See https://www.w3.org/TR/wot-thing-description11/#actionaffordance. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: field_type :type: Optional[TypeDeclaration] :value: None .. py:attribute:: input :type: Optional[DataSchema] :value: None .. py:attribute:: output :type: Optional[DataSchema] :value: None .. py:attribute:: safe :type: Optional[bool] :value: None .. py:attribute:: idempotent :type: Optional[bool] :value: None .. py:attribute:: forms :type: List[Form[ActionOp]] :value: None .. py:class:: EventAffordance(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#eventaffordance. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: field_type :type: Optional[TypeDeclaration] :value: None .. py:attribute:: subscription :type: Optional[DataSchema] :value: None .. py:attribute:: data :type: Optional[DataSchema] :value: None .. py:attribute:: cancellation :type: Optional[DataSchema] :value: None .. py:attribute:: forms :type: List[Form[EventOp]] :value: None .. py:class:: LinkElement(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#link. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: href :type: labthings_fastapi.middleware.url_for.URLFor | AnyUri .. py:attribute:: type :type: Optional[str] :value: None .. py:attribute:: rel :type: Optional[str] :value: None .. py:attribute:: anchor :type: Optional[AnyUri] :value: None .. py:data:: Links .. py:class:: SecuritySchemeEnum(*args, **kwds) Bases: :py:obj:`enum.Enum` See https://www.w3.org/TR/wot-thing-description11/#securityscheme. .. py:attribute:: nosec :value: 'nosec' .. py:attribute:: basic :value: 'basic' .. py:attribute:: digest :value: 'digest' .. py:attribute:: apikey :value: 'apikey' .. py:attribute:: bearer :value: 'bearer' .. py:attribute:: psk :value: 'psk' .. py:attribute:: oauth2 :value: 'oauth2' .. py:class:: In(*args, **kwds) Bases: :py:obj:`enum.Enum` Where a parameter is found. .. py:attribute:: header :value: 'header' .. py:attribute:: query :value: 'query' .. py:attribute:: body :value: 'body' .. py:attribute:: cookie :value: 'cookie' .. py:class:: Qop(*args, **kwds) Bases: :py:obj:`enum.Enum` See https://www.w3.org/TR/wot-thing-description11/#digestsecurityscheme. .. py:attribute:: auth :value: 'auth' .. py:attribute:: auth_int :value: 'auth-int' .. py:class:: Flow(*args, **kwds) Bases: :py:obj:`enum.Enum` See https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme. .. py:attribute:: code :value: 'code' .. py:class:: BaseSecurityScheme(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#securityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: field_type :type: Optional[TypeDeclaration] :value: None .. py:attribute:: description :type: Optional[Description] :value: None .. py:attribute:: descriptions :type: Optional[Descriptions] :value: None .. py:attribute:: proxy :type: Optional[AnyUri] :value: None .. py:attribute:: scheme :type: SecuritySchemeEnum .. py:class:: NoSecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme` See https://www.w3.org/TR/wot-thing-description11/#nosecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:attribute:: description :type: Optional[Description] :value: None .. py:class:: NameAndIn(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Fields used by various security schemas. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: in_ :type: Optional[In] :value: None .. py:attribute:: name :type: Optional[str] :value: None .. py:class:: BasicSecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme`, :py:obj:`NameAndIn` See https://www.w3.org/TR/wot-thing-description11/#basicsecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:class:: DigestSecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme`, :py:obj:`NameAndIn` See https://www.w3.org/TR/wot-thing-description11/#digestsecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:attribute:: qop :type: Optional[Qop] :value: None .. py:class:: APISecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme`, :py:obj:`NameAndIn` See https://www.w3.org/TR/wot-thing-description11/#apisecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:class:: BearerSecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme`, :py:obj:`NameAndIn` See https://www.w3.org/TR/wot-thing-description11/#bearersecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:attribute:: authorization :type: Optional[AnyUri] :value: None .. py:attribute:: alg :type: Optional[str] :value: None .. py:attribute:: format :type: Optional[str] :value: None .. py:class:: PskSecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme` See https://www.w3.org/TR/wot-thing-description11/#psksecurityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:attribute:: identity :type: Optional[str] :value: None .. py:class:: Oauth2SecurityScheme(/, **data: Any) Bases: :py:obj:`BaseSecurityScheme` See https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: scheme :type: Literal[SecuritySchemeEnum] .. py:attribute:: authorization :type: Optional[AnyUri] :value: None .. py:attribute:: token :type: Optional[AnyUri] :value: None .. py:attribute:: refresh :type: Optional[AnyUri] :value: None .. py:attribute:: scopes :type: Optional[Union[List[str], str]] :value: None .. py:attribute:: flow :type: Optional[Flow] :value: None .. py:data:: SecurityScheme .. py:class:: WotTdSchema16October2019(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` See https://www.w3.org/TR/wot-thing-description11/#thing. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: id :type: Optional[pydantic.AnyUrl] :value: None .. py:attribute:: title :type: Title .. py:attribute:: titles :type: Optional[Titles] :value: None .. py:attribute:: properties :type: Optional[Dict[str, PropertyAffordance]] :value: None .. py:attribute:: actions :type: Optional[Dict[str, ActionAffordance]] :value: None .. py:attribute:: events :type: Optional[Dict[str, EventAffordance]] :value: None .. py:attribute:: description :type: Optional[Description] :value: None .. py:attribute:: descriptions :type: Optional[Descriptions] :value: None .. py:attribute:: version :type: Optional[Version] :value: None .. py:attribute:: links :type: Links :value: None .. py:attribute:: forms :type: Optional[List[Form[RootOp]]] :value: None .. py:attribute:: base :type: Optional[labthings_fastapi.middleware.url_for.URLFor | AnyUri] :value: None .. py:attribute:: securityDefinitions :type: Dict[str, SecurityScheme] .. py:attribute:: support :type: Optional[AnyUri] :value: None .. py:attribute:: created :type: Optional[datetime.datetime] :value: None .. py:attribute:: modified :type: Optional[datetime.datetime] :value: None .. py:attribute:: security :type: Union[str, List[str]] .. py:attribute:: field_type :type: Optional[TypeDeclaration] :value: None .. py:attribute:: field_context :type: ThingContext :value: None .. py:data:: ThingDescription