labthings_fastapi.thing_description._model

Pydantic Models to describe DataSchema.

Thing Description 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.

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

AnyUri

Description

Descriptions

Title

Titles

Security

Scopes

TypeDeclaration

THING_CONTEXT_URL

THING_CONTEXT_URL_v1

ThingContextType

ThingContext

Op

OpT

Links

SecurityScheme

ThingDescription

Classes

Version

Version info for a Thing.

Subprotocol

HTTP sub-protocols.

Type

type property of a DataSchema.

DataSchema

Base for several classes describing datatypes.

Response

See https://www.w3.org/TR/wot-thing-description11/#expectedresponse.

PropertyOp

op values for Forms on Properties.

ActionOp

op values for Forms on Actions.

EventOp

op values for Forms on Events.

RootOp

op values for Forms on Things.

Form

See https://www.w3.org/TR/wot-thing-description11/#form.

InteractionAffordance

See https://www.w3.org/TR/wot-thing-description11/#interactionaffordance.

PropertyAffordance

See https://www.w3.org/TR/wot-thing-description11/#propertyaffordance.

ActionAffordance

See https://www.w3.org/TR/wot-thing-description11/#actionaffordance.

EventAffordance

See https://www.w3.org/TR/wot-thing-description11/#eventaffordance.

LinkElement

See https://www.w3.org/TR/wot-thing-description11/#link.

SecuritySchemeEnum

See https://www.w3.org/TR/wot-thing-description11/#securityscheme.

In

Where a parameter is found.

Qop

See https://www.w3.org/TR/wot-thing-description11/#digestsecurityscheme.

Flow

See https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme.

BaseSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#securityscheme.

NoSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#nosecurityscheme.

NameAndIn

Fields used by various security schemas.

BasicSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#basicsecurityscheme.

DigestSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#digestsecurityscheme.

APISecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#apisecurityscheme.

BearerSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#bearersecurityscheme.

PskSecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#psksecurityscheme.

Oauth2SecurityScheme

See https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme.

WotTdSchema16October2019

See https://www.w3.org/TR/wot-thing-description11/#thing.

Functions

uses_thing_context(→ None)

Check the URLs in the ThingContextType are valid.

Module Contents

class labthings_fastapi.thing_description._model.Version(/, **data: Any)

Bases: 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.

instance: str
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
class labthings_fastapi.thing_description._model.Subprotocol(*args, **kwds)

Bases: enum.Enum

HTTP sub-protocols.

longpoll = 'longpoll'
websub = 'websub'
sse = 'sse'
labthings_fastapi.thing_description._model.THING_CONTEXT_URL = 'https://www.w3.org/2022/wot/td/v1.1'
labthings_fastapi.thing_description._model.THING_CONTEXT_URL_v1 = 'https://www.w3.org/2019/wot/td/v1'
labthings_fastapi.thing_description._model.ThingContextType
labthings_fastapi.thing_description._model.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.

Parameters:

v – the ThingContextType object.

Raises:

ValueError – if the URL is not correct.

labthings_fastapi.thing_description._model.ThingContext
class labthings_fastapi.thing_description._model.Type(*args, **kwds)

Bases: enum.Enum

type property of a DataSchema.

boolean = 'boolean'
integer = 'integer'
number = 'number'
string = 'string'
object = 'object'
array = 'array'
null = 'null'
class labthings_fastapi.thing_description._model.DataSchema(/, **data: Any)

Bases: 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.

field_type: TypeDeclaration | None = None
description: Description | None = None
title: Title | None = None
descriptions: Descriptions | None = None
titles: Titles | None = None
writeOnly: bool | None = None
readOnly: bool | None = None
oneOf: list[DataSchema] | None = None
unit: str | None = None
enum: list | None = None
format: str | None = None
const: Any | None = None
default: Any | None = None
type: Type | None = None
items: DataSchema | List[DataSchema] | None = None
maxItems: int | None = None
minItems: int | None = None
minimum: int | float | None = None
maximum: int | float | None = None
exclusiveMinimum: int | float | None = None
exclusiveMaximum: int | float | None = None
multipleOf: int | float | None = None
properties: Mapping[str, DataSchema] | None = None
required: list[str] | None = None
minLength: int | None = None
maxLength: int | None = None
pattern: str | None = None
contentEncoding: str | None = None
contentMediaType: str | None = None
model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class labthings_fastapi.thing_description._model.Response(/, **data: Any)

Bases: 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.

contentType: str | None = None
class labthings_fastapi.thing_description._model.PropertyOp(*args, **kwds)

Bases: enum.Enum

op values for Forms on Properties.

See https://www.w3.org/TR/wot-thing-description11/#propertyaffordance

readproperty = 'readproperty'
writeproperty = 'writeproperty'
observeproperty = 'observeproperty'
unobserveproperty = 'unobserveproperty'
class labthings_fastapi.thing_description._model.ActionOp(*args, **kwds)

Bases: enum.Enum

op values for Forms on Actions.

See https://www.w3.org/TR/wot-thing-description11/#actionaffordance

invokeaction = 'invokeaction'
class labthings_fastapi.thing_description._model.EventOp(*args, **kwds)

Bases: enum.Enum

op values for Forms on Events.

See https://www.w3.org/TR/wot-thing-description11/#eventaffordance

subscribeevent = 'subscribeevent'
unsubscribeevent = 'unsubscribeevent'
class labthings_fastapi.thing_description._model.RootOp(*args, **kwds)

Bases: enum.Enum

op values for Forms on Things.

See https://www.w3.org/TR/wot-thing-description11/#thing

readallproperties = 'readallproperties'
writeallproperties = 'writeallproperties'
readmultipleproperties = 'readmultipleproperties'
writemultipleproperties = 'writemultipleproperties'
labthings_fastapi.thing_description._model.Op
labthings_fastapi.thing_description._model.OpT
class labthings_fastapi.thing_description._model.Form(/, **data: Any)

Bases: pydantic.BaseModel, Generic[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.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

href: labthings_fastapi.middleware.url_for.URLFor | AnyUri
op: OpT | List[OpT] | None = None
contentType: str | None = None
contentCoding: str | None = None
subprotocol: Subprotocol | None = None
security: Security | None = None
scopes: Scopes | None = None
response: Response | None = None
class labthings_fastapi.thing_description._model.InteractionAffordance(/, **data: Any)

Bases: 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.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

description: Description | None = None
descriptions: Descriptions | None = None
title: Title | None = None
titles: Titles | None = None
forms: List[Form] = None
uriVariables: Dict[str, DataSchema] | None = None
class labthings_fastapi.thing_description._model.PropertyAffordance(/, **data: Any)

Bases: InteractionAffordance, 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.

observable: bool | None = None
forms: List[Form[PropertyOp]] = None
class labthings_fastapi.thing_description._model.ActionAffordance(/, **data: Any)

Bases: 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.

field_type: TypeDeclaration | None = None
input: DataSchema | None = None
output: DataSchema | None = None
safe: bool | None = None
idempotent: bool | None = None
forms: List[Form[ActionOp]] = None
class labthings_fastapi.thing_description._model.EventAffordance(/, **data: Any)

Bases: 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.

field_type: TypeDeclaration | None = None
subscription: DataSchema | None = None
data: DataSchema | None = None
cancellation: DataSchema | None = None
forms: List[Form[EventOp]] = None
class labthings_fastapi.thing_description._model.LinkElement(/, **data: Any)

Bases: 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.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

href: labthings_fastapi.middleware.url_for.URLFor | AnyUri
type: str | None = None
rel: str | None = None
anchor: AnyUri | None = None
class labthings_fastapi.thing_description._model.SecuritySchemeEnum(*args, **kwds)

Bases: enum.Enum

See https://www.w3.org/TR/wot-thing-description11/#securityscheme.

nosec = 'nosec'
basic = 'basic'
digest = 'digest'
apikey = 'apikey'
bearer = 'bearer'
psk = 'psk'
oauth2 = 'oauth2'
class labthings_fastapi.thing_description._model.In(*args, **kwds)

Bases: enum.Enum

Where a parameter is found.

header = 'header'
query = 'query'
body = 'body'
cookie = 'cookie'
class labthings_fastapi.thing_description._model.Qop(*args, **kwds)

Bases: enum.Enum

See https://www.w3.org/TR/wot-thing-description11/#digestsecurityscheme.

auth = 'auth'
auth_int = 'auth-int'
class labthings_fastapi.thing_description._model.Flow(*args, **kwds)

Bases: enum.Enum

See https://www.w3.org/TR/wot-thing-description11/#oauth2securityscheme.

code = 'code'
class labthings_fastapi.thing_description._model.BaseSecurityScheme(/, **data: Any)

Bases: 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.

field_type: TypeDeclaration | None = None
description: Description | None = None
descriptions: Descriptions | None = None
proxy: AnyUri | None = None
scheme: SecuritySchemeEnum
class labthings_fastapi.thing_description._model.NoSecurityScheme(/, **data: Any)

Bases: 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.

scheme: Literal[SecuritySchemeEnum]
description: Description | None = None
class labthings_fastapi.thing_description._model.NameAndIn(/, **data: Any)

Bases: 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.

in_: In | None = None
name: str | None = None
class labthings_fastapi.thing_description._model.BasicSecurityScheme(/, **data: Any)

Bases: BaseSecurityScheme, 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.

scheme: Literal[SecuritySchemeEnum]
class labthings_fastapi.thing_description._model.DigestSecurityScheme(/, **data: Any)

Bases: BaseSecurityScheme, 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.

scheme: Literal[SecuritySchemeEnum]
qop: Qop | None = None
class labthings_fastapi.thing_description._model.APISecurityScheme(/, **data: Any)

Bases: BaseSecurityScheme, 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.

scheme: Literal[SecuritySchemeEnum]
class labthings_fastapi.thing_description._model.BearerSecurityScheme(/, **data: Any)

Bases: BaseSecurityScheme, 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.

scheme: Literal[SecuritySchemeEnum]
authorization: AnyUri | None = None
alg: str | None = None
format: str | None = None
class labthings_fastapi.thing_description._model.PskSecurityScheme(/, **data: Any)

Bases: 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.

scheme: Literal[SecuritySchemeEnum]
identity: str | None = None
class labthings_fastapi.thing_description._model.Oauth2SecurityScheme(/, **data: Any)

Bases: 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.

scheme: Literal[SecuritySchemeEnum]
authorization: AnyUri | None = None
token: AnyUri | None = None
refresh: AnyUri | None = None
scopes: List[str] | str | None = None
flow: Flow | None = None
labthings_fastapi.thing_description._model.SecurityScheme
class labthings_fastapi.thing_description._model.WotTdSchema16October2019(/, **data: Any)

Bases: 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.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

id: pydantic.AnyUrl | None = None
title: Title
titles: Titles | None = None
properties: Dict[str, PropertyAffordance] | None = None
actions: Dict[str, ActionAffordance] | None = None
events: Dict[str, EventAffordance] | None = None
description: Description | None = None
descriptions: Descriptions | None = None
version: Version | None = None
forms: List[Form[RootOp]] | None = None
base: labthings_fastapi.middleware.url_for.URLFor | AnyUri | None = None
securityDefinitions: Dict[str, SecurityScheme]
support: AnyUri | None = None
created: datetime.datetime | None = None
modified: datetime.datetime | None = None
security: str | List[str]
field_type: TypeDeclaration | None = None
field_context: ThingContext = None
labthings_fastapi.thing_description._model.ThingDescription