Source code for aas_core3_2.jsonization

"""
Provide de/serialization of meta-model classes to/from JSON.

We can not use one-pass deserialization for JSON since the object
properties do not have fixed order, and hence we can not read
``modelType`` property ahead of the remaining properties.
"""

# This code has been automatically generated by aas-core-codegen.
# Do NOT edit or append.


import base64
import collections.abc
import json
import math
import re
import sys
from typing import (
    Any,
    Callable,
    Dict,
    Iterable,
    List,
    Mapping,
    MutableMapping,
    Optional,
    Sequence,
    Tuple,
    TypeVar,
    Union,
)

if sys.version_info >= (3, 8):
    from typing import Final
else:
    from typing_extensions import Final

import aas_core3_2.common as our_common
import aas_core3_2.stringification as our_stringification
import aas_core3_2.types as our_types

# NOTE (mristin):
# The SDK defines three of these path vocabularies: this one, the one in
# :py:mod:`aas_core3_2.jsonization`, and the one in
# :py:mod:`aas_core3_2.xmlcommon`.
# They look alike, and it is tempting to merge them, but they are not
# interchangeable.
#
# Each of them points into a different thing, and every segment carries
# a back-pointer to the container it stepped through, so the type of that
# back-pointer differs from one to the next:
#
# * This one points into the instances which you built, so a property
#   segment holds a class of the meta-model.
# * The jsonization's points into the JSON-able structure being read or
#   written, so a property segment holds the JSON-able mapping instead:
#   while a document is being parsed, the instance which the property would
#   belong to does not exist yet.
# * The xmlcommon's points into the XML document, where there are no
#   properties at all, only elements, so it names an element instead.
#
# The three also render differently: a path into the instances is a Python
# access expression, a path into a JSON-able structure starts at the root of
# the document and carries no leading dot, and a path into an XML document
# is a relative XPath.
#
# Merging them would mean either dropping the back-pointers, which have been
# part of the public API of this SDK since before these modules were split
# apart, or defining a single path over the union of all the segment kinds --
# in which case every consumer would have to handle segments which can never
# occur in its world. Three small vocabularies which each say exactly what
# they can say cost less than one large one which lies about its range.


[docs]class PropertySegment: """Represent a property on a path to the erroneous value.""" #: Instance that contains the property instance: Final[Mapping[str, Any]] #: Name of the property name: Final[str]
[docs] def __init__(self, instance: Mapping[str, Any], name: str) -> None: """Initialize with the given values.""" self.instance = instance self.name = name
[docs]class IndexSegment: """Represent an index access on a path to the erroneous value.""" #: Container that contains the item container: Final[Iterable[Any]] #: Index of the item index: Final[int]
[docs] def __init__(self, container: Iterable[Any], index: int) -> None: """Initialize with the given values.""" self.container = container self.index = index
[docs]class KeySegment: """ Represent a member access on a path to the erroneous value. Unlike a :py:class:`PropertySegment`, which names a property of one of our classes, a key names a member of an open JSON-able object. It is known only at run time, and can be any string at all, so it is always rendered as a subscript. """ #: Mapping that contains the value at :py:attr:`~key` mapping: Final[Mapping[str, Any]] #: Key of the value key: Final[str]
[docs] def __init__(self, mapping: Mapping[str, Any], key: str) -> None: """Initialize with the given values.""" self.mapping = mapping self.key = key
Segment = Union[PropertySegment, IndexSegment, KeySegment] #: Match the property names which a path writes after a dot; the other names #: are written in brackets as JSON strings, *e.g.*, ``["$eq"]``. _VARIABLE_NAME_RE = re.compile(r"^[a-zA-Z_][a-zA-Z_0-9]*$")
[docs]class Path: """Represent the relative path to the erroneous value."""
[docs] def __init__(self) -> None: """Initialize as an empty path.""" self._segments: List[Segment] = []
@property def segments(self) -> Sequence[Segment]: """Get the segments of the path.""" return self._segments def _prepend(self, segment: Segment) -> None: """Insert the :paramref:`segment` in front of other segments.""" self._segments.insert(0, segment)
[docs] def __str__(self) -> str: if len(self._segments) == 0: return "" parts: List[str] = [] iterator = iter(self._segments) first = next(iterator) if isinstance(first, PropertySegment): if _VARIABLE_NAME_RE.match(first.name): parts.append(first.name) else: parts.append(f"[{json.dumps(first.name, ensure_ascii=False)}]") elif isinstance(first, IndexSegment): parts.append(f"[{first.index}]") elif isinstance(first, KeySegment): parts.append(f"[{json.dumps(first.key, ensure_ascii=False)}]") else: our_common.assert_never(first) for segment in iterator: if isinstance(segment, PropertySegment): if _VARIABLE_NAME_RE.match(segment.name): parts.append(f".{segment.name}") else: parts.append(f"[{json.dumps(segment.name, ensure_ascii=False)}]") elif isinstance(segment, IndexSegment): parts.append(f"[{segment.index}]") elif isinstance(segment, KeySegment): parts.append(f"[{json.dumps(segment.key, ensure_ascii=False)}]") else: our_common.assert_never(segment) return "".join(parts)
[docs]class DeserializationException(Exception): """Signal that the JSON de-serialization could not be performed.""" #: Human-readable explanation of the exception's cause cause: Final[str] #: Relative path to the erroneous value path: Final[Path]
[docs] def __init__(self, cause: str) -> None: """Initialize with the given :paramref:`cause` and an empty path.""" self.cause = cause self.path = Path()
# NOTE (mristin): # Recursive definitions are not yet available in mypy # (see https://github.com/python/mypy/issues/731). We have to use ``Any`` # here, instead of recursive type annotations. Jsonable = Union[None, bool, int, float, str, Sequence[Any], Mapping[str, Any]] MutableJsonable = Union[ None, bool, int, float, str, List[Any], MutableMapping[str, Any] ] # region De-serialization _ValueT = TypeVar("_ValueT") #: Parse a JSON-able value into a value of the meta-model _Parser = Callable[[Jsonable], _ValueT] def _as_mapping(jsonable: Jsonable) -> Mapping[str, Any]: """ Interpret :paramref:`jsonable` as a mapping. :param jsonable: JSON-able structure to be interpreted :return: :paramref:`jsonable`, as a mapping :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ # NOTE (mristin): # We check against ``dict`` first. That is what :py:mod:`json` gives us, and # ``isinstance`` against a concrete class costs a fraction of ``isinstance`` # against the abstract :py:class:`collections.abc.Mapping` -- measured on # CPython 3.10, 59 ns against 274 ns -- on a check which runs once for every # instance that we de-serialize. # # We give the mapping back, instead of only raising, so that the caller can # go on with a narrowed type. ``mypy --strict`` does not narrow a union # across a call which merely raises. if not isinstance(jsonable, dict) and not isinstance( jsonable, collections.abc.Mapping ): raise DeserializationException(f"Expected a mapping, but got: {type(jsonable)}") return jsonable def _dispatch_from_jsonable( jsonable: Jsonable, dispatch: Mapping[str, _Parser[_ValueT]], name: str ) -> _ValueT: """ Parse :paramref:`jsonable` by dispatching on its ``modelType``. :param jsonable: JSON-able structure to be parsed :param dispatch: to parse a concrete instance, by its model type :param name: of the parsed type, for the error message :return: parsed instance :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType") if model_type is None: raise DeserializationException( "Expected the property modelType, but found none" ) if not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception parse = dispatch.get(model_type) if parse is None: raise DeserializationException( f"Unexpected model type for {name}: {model_type}" ) return parse(mapping) def _bool_from_jsonable(jsonable: Jsonable) -> bool: """ Parse :paramref:`jsonable` as a boolean. :param jsonable: JSON-able structure to be parsed :return: parsed boolean :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, bool): raise DeserializationException(f"Expected a bool, but got: {type(jsonable)}") return jsonable def _float_from_jsonable(jsonable: Jsonable) -> float: """ Parse :paramref:`jsonable` as a floating-point number. An integer is accepted as well. JSON has a single number type, so ``3`` is every bit as good a floating-point number as ``3.0`` is, and :py:mod:`json` gives us an ``int`` for the former. :param jsonable: JSON-able structure to be parsed :return: parsed floating-point number :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ # NOTE (mristin): # ``bool`` is a subclass of ``int`` in Python, so it has to be excluded # explicitly. Otherwise ``True`` would be read as ``1.0``. if isinstance(jsonable, bool) or not isinstance(jsonable, (int, float)): raise DeserializationException(f"Expected a float, but got: {type(jsonable)}") try: value = float(jsonable) except OverflowError: raise DeserializationException( f"Expected a float, but got an integer too large for it: {jsonable}" ) from None # NOTE (mristin): # JSON knows neither an infinity nor a not-a-number, so a conformant parser # can never give us one. :py:mod:`json` is not conformant in this respect -- # it parses ``NaN``, ``Infinity`` and ``-Infinity`` out of the box -- so we # have to check here. if not math.isfinite(value): raise DeserializationException(f"Expected a finite float, but got: {value}") return value def _str_from_jsonable(jsonable: Jsonable) -> str: """ Parse :paramref:`jsonable` as a string. :param jsonable: JSON-able structure to be parsed :return: parsed string :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException(f"Expected a str, but got: {type(jsonable)}") return jsonable def _bytes_from_jsonable(jsonable: Jsonable) -> bytes: """ Decode :paramref:`jsonable` as base64 string to a ``bytearray``. :param jsonable: JSON-able structure to be decoded :return: decoded bytearray :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException(f"Expected a str, but got: {type(jsonable)}") return base64.b64decode(jsonable.encode("ascii")) def _list_from_jsonable( jsonable: Jsonable, parse_item: _Parser[_ValueT] ) -> List[_ValueT]: """ Parse :paramref:`jsonable` as a list, applying :paramref:`parse_item` on every item. :param jsonable: JSON-able structure to be parsed :param parse_item: to parse a single item of the array :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ array_like = our_common.try_to_cast_to_array_like(jsonable) if array_like is None: raise DeserializationException( f"Expected something array-like, but got: {type(jsonable)}" ) result: List[_ValueT] = [] for i, jsonable_item in enumerate(array_like): try: item = parse_item(jsonable_item) except DeserializationException as exception: exception.path._prepend(IndexSegment(array_like, i)) raise result.append(item) return result def _json_value_from_jsonable(jsonable: Jsonable) -> our_types.JsonValue: """ Parse :paramref:`jsonable` as a JSON-able value. A JSON-able value is, recursively, exactly as JSON itself is defined: a ``None`` (JSON null), a boolean, a number, a string, an array of JSON-able values or an object of JSON-able values with string keys. An infinity and a not-a-number are rejected at any depth, as JSON can not represent them at all. The result is a new structure, and never :paramref:`jsonable` itself, so that the parsed instance does not alias the document it came from. :param jsonable: JSON-able structure to be parsed :return: parsed JSON-able value :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ if jsonable is None: return None # NOTE (mristin): # A ``bool`` is an ``int`` in Python, so it has to be checked first -- # otherwise every boolean would come out as a number. if isinstance(jsonable, bool): return jsonable if isinstance(jsonable, int): # NOTE (mristin): # JSON knows a single numeric type, so :py:mod:`json` giving us # an ``int`` says nothing about the document: "1" and "1.0" are # the same number, and a JSON-able value holds it as a ``float``. number = our_common.try_to_convert_int_to_float(jsonable) if number is None: raise DeserializationException( f"Expected a JSON-able value, but got the integer {jsonable}, " f"which is not exactly representable as a JSON number" ) return number if isinstance(jsonable, float): # NOTE (mristin): # JSON knows neither an infinity nor a not-a-number. A conformant # parser never gives us one, but :paramref:`jsonable` may well have # been put together programmatically. if not math.isfinite(jsonable): raise DeserializationException( f"Expected a JSON-able value, but got the number {jsonable}, " f"which is neither finite nor representable in JSON" ) return jsonable if isinstance(jsonable, str): return jsonable if isinstance(jsonable, (dict, collections.abc.Mapping)): mapping: Dict[str, Any] = {} for key, jsonable_value in jsonable.items(): if not isinstance(key, str): raise DeserializationException( f"Expected only string keys in a JSON-able object, but got " f"a key of type: {type(key)}" ) try: mapping[key] = _json_value_from_jsonable(jsonable_value) except DeserializationException as exception: exception.path._prepend(KeySegment(jsonable, key)) raise return mapping array_like = our_common.try_to_cast_to_array_like(jsonable) if array_like is not None: items: List[Any] = [] for i, jsonable_item in enumerate(array_like): try: items.append(_json_value_from_jsonable(jsonable_item)) except DeserializationException as exception: exception.path._prepend(IndexSegment(array_like, i)) raise return items raise DeserializationException( f"Expected a JSON-able value (a null, a boolean, a number, a string, " f"an array or an object), but got: {type(jsonable)}" ) def _json_object_from_jsonable(jsonable: Jsonable) -> our_types.JsonObject: """ Parse :paramref:`jsonable` as a JSON-able object. :param jsonable: JSON-able structure to be parsed :return: parsed JSON-able object :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, (dict, collections.abc.Mapping)): raise DeserializationException( f"Expected a JSON-able object, but got: {type(jsonable)}" ) result = _json_value_from_jsonable(jsonable) assert isinstance(result, dict) return result _TupleItem1T = TypeVar("_TupleItem1T") _TupleItem2T = TypeVar("_TupleItem2T") def _tuple2_from_jsonable( jsonable: Jsonable, parse_item_1: _Parser[_TupleItem1T], parse_item_2: _Parser[_TupleItem2T], ) -> Tuple[_TupleItem1T, _TupleItem2T]: """ Parse :paramref:`jsonable` as a tuple of 2 item(s), applying the corresponding ``parse_item_*`` function on every item. :param jsonable: JSON-able structure to be parsed :param parse_item_1: to parse the item at the position 0 :param parse_item_2: to parse the item at the position 1 :return: parsed tuple :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ array_like = our_common.try_to_cast_to_array_like(jsonable) if array_like is None: raise DeserializationException( f"Expected something array-like, but got: {type(jsonable)}" ) # NOTE (mristin): # Unlike a list, a tuple is heterogeneous, so we need to index the individual # items by their fixed position, and a general ``Iterable`` does not support # that. if not isinstance(array_like, collections.abc.Sequence): raise DeserializationException( f"Expected something indexable to de-serialize a tuple, " f"but got: {type(jsonable)}" ) if len(array_like) != 2: raise DeserializationException( f"Expected exactly 2 item(s) in the array, " f"but got: {len(array_like)}" ) try: item_1 = parse_item_1(array_like[0]) except DeserializationException as exception: exception.path._prepend(IndexSegment(array_like, 0)) raise try: item_2 = parse_item_2(array_like[1]) except DeserializationException as exception: exception.path._prepend(IndexSegment(array_like, 1)) raise return (item_1, item_2) def _list_of__asset_administration_shell_descriptor_from_jsonable( jsonable: Jsonable, ) -> List[our_types.AssetAdministrationShellDescriptor]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.AssetAdministrationShellDescriptor`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, asset_administration_shell_descriptor_from_jsonable ) def _list_of__asset_administration_shell_from_jsonable( jsonable: Jsonable, ) -> List[our_types.AssetAdministrationShell]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.AssetAdministrationShell`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, asset_administration_shell_from_jsonable) def _list_of__asset_administration_shell_metadata_from_jsonable( jsonable: Jsonable, ) -> List[our_types.AssetAdministrationShellMetadata]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.AssetAdministrationShellMetadata`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, asset_administration_shell_metadata_from_jsonable ) def _list_of__asset_administration_shell_recent_change_from_jsonable( jsonable: Jsonable, ) -> List[our_types.AssetAdministrationShellRecentChange]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.AssetAdministrationShellRecentChange`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, asset_administration_shell_recent_change_from_jsonable ) def _list_of__concept_description_from_jsonable( jsonable: Jsonable, ) -> List[our_types.ConceptDescription]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.ConceptDescription`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, concept_description_from_jsonable) def _list_of__concept_description_recent_change_from_jsonable( jsonable: Jsonable, ) -> List[our_types.ConceptDescriptionRecentChange]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.ConceptDescriptionRecentChange`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, concept_description_recent_change_from_jsonable ) def _list_of__data_element_from_jsonable( jsonable: Jsonable, ) -> List[our_types.DataElement]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.DataElement`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, data_element_from_jsonable) def _list_of__definition_type_uom_from_jsonable( jsonable: Jsonable, ) -> List[our_types.DefinitionTypeUom]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.DefinitionTypeUom`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, definition_type_uom_from_jsonable) def _list_of__embedded_data_specification_from_jsonable( jsonable: Jsonable, ) -> List[our_types.EmbeddedDataSpecification]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.EmbeddedDataSpecification`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, embedded_data_specification_from_jsonable) def _list_of__endpoint_from_jsonable(jsonable: Jsonable) -> List[our_types.Endpoint]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Endpoint`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, endpoint_from_jsonable) def _list_of__extension_from_jsonable(jsonable: Jsonable) -> List[our_types.Extension]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Extension`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, extension_from_jsonable) def _list_of__json_object_from_jsonable( jsonable: Jsonable, ) -> List[our_types.JsonObject]: """ Parse :paramref:`jsonable` as a list of a JSON-able object. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, _json_object_from_jsonable) def _list_of__key_from_jsonable(jsonable: Jsonable) -> List[our_types.Key]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Key`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, key_from_jsonable) def _list_of__lang_string_definition_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringDefinitionTypeIEC61360]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringDefinitionTypeIEC61360`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, lang_string_definition_type_iec_61360_from_jsonable ) def _list_of__lang_string_name_type_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringNameType]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringNameType`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, lang_string_name_type_from_jsonable) def _list_of__lang_string_preferred_name_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringPreferredNameTypeIEC61360]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringPreferredNameTypeIEC61360`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, lang_string_preferred_name_type_iec_61360_from_jsonable ) def _list_of__lang_string_short_name_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringShortNameTypeIEC61360]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringShortNameTypeIEC61360`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, lang_string_short_name_type_iec_61360_from_jsonable ) def _list_of__lang_string_text_type_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringTextType]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringTextType`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, lang_string_text_type_from_jsonable) def _list_of__lang_string_uom_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LangStringUom]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LangStringUom`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, lang_string_uom_from_jsonable) def _list_of__logical_expression_from_jsonable( jsonable: Jsonable, ) -> List[our_types.LogicalExpression]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.LogicalExpression`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, logical_expression_from_jsonable) def _list_of__match_expression_from_jsonable( jsonable: Jsonable, ) -> List[our_types.MatchExpression]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.MatchExpression`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, match_expression_from_jsonable) def _list_of__message_from_jsonable(jsonable: Jsonable) -> List[our_types.Message]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Message`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, message_from_jsonable) def _list_of__operation_variable_from_jsonable( jsonable: Jsonable, ) -> List[our_types.OperationVariable]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.OperationVariable`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, operation_variable_from_jsonable) def _list_of__package_description_from_jsonable( jsonable: Jsonable, ) -> List[our_types.PackageDescription]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.PackageDescription`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, package_description_from_jsonable) def _list_of__qualifier_from_jsonable(jsonable: Jsonable) -> List[our_types.Qualifier]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Qualifier`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, qualifier_from_jsonable) def _list_of__query_filter_from_jsonable( jsonable: Jsonable, ) -> List[our_types.QueryFilter]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.QueryFilter`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, query_filter_from_jsonable) def _list_of__referable_from_jsonable(jsonable: Jsonable) -> List[our_types.Referable]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Referable`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, referable_from_jsonable) def _list_of__reference_from_jsonable(jsonable: Jsonable) -> List[our_types.Reference]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Reference`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, reference_from_jsonable) def _list_of__security_attribute_object_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SecurityAttributeObject]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SecurityAttributeObject`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, security_attribute_object_from_jsonable) def _list_of__service_specification_profile_enum_from_jsonable( jsonable: Jsonable, ) -> List[our_types.ServiceSpecificationProfileEnum]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.ServiceSpecificationProfileEnum`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable( jsonable, service_specification_profile_enum_from_jsonable ) def _list_of__specific_asset_id_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SpecificAssetID]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SpecificAssetID`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, specific_asset_id_from_jsonable) def _list_of__str_from_jsonable(jsonable: Jsonable) -> List[str]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.PathItem`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, _str_from_jsonable) def _list_of__submodel_descriptor_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SubmodelDescriptor]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SubmodelDescriptor`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_descriptor_from_jsonable) def _list_of__submodel_element_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SubmodelElement]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SubmodelElement`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_element_from_jsonable) def _list_of__submodel_element_metadata_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SubmodelElementMetadata]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SubmodelElementMetadata`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_element_metadata_from_jsonable) def _list_of__submodel_from_jsonable(jsonable: Jsonable) -> List[our_types.Submodel]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.Submodel`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_from_jsonable) def _list_of__submodel_metadata_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SubmodelMetadata]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SubmodelMetadata`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_metadata_from_jsonable) def _list_of__submodel_recent_change_from_jsonable( jsonable: Jsonable, ) -> List[our_types.SubmodelRecentChange]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.SubmodelRecentChange`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, submodel_recent_change_from_jsonable) def _list_of__value_reference_pair_from_jsonable( jsonable: Jsonable, ) -> List[our_types.ValueReferencePair]: """ Parse :paramref:`jsonable` as a list of :py:class:`.types.ValueReferencePair`. :param jsonable: JSON-able structure to be parsed :return: parsed list :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _list_from_jsonable(jsonable, value_reference_pair_from_jsonable) def _tuple2_of__string_value__string_value_from_jsonable( jsonable: Jsonable, ) -> Tuple[our_types.StringValue, our_types.StringValue]: """ Parse :paramref:`jsonable` as a tuple of 2 item(s). :param jsonable: JSON-able structure to be parsed :return: parsed tuple :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _tuple2_from_jsonable( jsonable, string_value_from_jsonable, string_value_from_jsonable ) def _tuple2_of__value__value_from_jsonable( jsonable: Jsonable, ) -> Tuple[our_types.Value, our_types.Value]: """ Parse :paramref:`jsonable` as a tuple of 2 item(s). :param jsonable: JSON-able structure to be parsed :return: parsed tuple :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _tuple2_from_jsonable(jsonable, value_from_jsonable, value_from_jsonable)
[docs]def has_semantics_from_jsonable(jsonable: Jsonable) -> our_types.HasSemantics: """ Parse an instance of :py:class:`.types.HasSemantics` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.HasSemantics` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _HAS_SEMANTICS_FROM_JSONABLE_DISPATCH, "HasSemantics" )
[docs]def extension_from_jsonable(jsonable: Jsonable) -> our_types.Extension: """ Parse an instance of :py:class:`.types.Extension` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Extension` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_name: Optional[str] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None the_value: Optional[str] = None the_refers_to: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "name": the_name = _str_from_jsonable(jsonable_value) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "refersTo": the_refers_to = _list_of__reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_name is None: raise DeserializationException("The required property 'name' is missing") return our_types.Extension( the_name, the_semantic_id, the_supplemental_semantic_ids, the_value_type, the_value, the_refers_to, )
[docs]def has_extensions_from_jsonable(jsonable: Jsonable) -> our_types.HasExtensions: """ Parse an instance of :py:class:`.types.HasExtensions` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.HasExtensions` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _HAS_EXTENSIONS_FROM_JSONABLE_DISPATCH, "HasExtensions" )
[docs]def referable_from_jsonable(jsonable: Jsonable) -> our_types.Referable: """ Parse an instance of :py:class:`.types.Referable` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.Referable` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _REFERABLE_FROM_JSONABLE_DISPATCH, "Referable" )
[docs]def identifiable_from_jsonable(jsonable: Jsonable) -> our_types.Identifiable: """ Parse an instance of :py:class:`.types.Identifiable` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.Identifiable` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _IDENTIFIABLE_FROM_JSONABLE_DISPATCH, "Identifiable" )
[docs]def modelling_kind_from_jsonable(jsonable: Jsonable) -> our_types.ModellingKind: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.ModellingKind`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.modelling_kind_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of ModellingKind: {jsonable}" ) return literal
[docs]def has_kind_from_jsonable(jsonable: Jsonable) -> our_types.HasKind: """ Parse an instance of :py:class:`.types.HasKind` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.HasKind` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _HAS_KIND_FROM_JSONABLE_DISPATCH, "HasKind" )
[docs]def has_data_specification_from_jsonable( jsonable: Jsonable, ) -> our_types.HasDataSpecification: """ Parse an instance of :py:class:`.types.HasDataSpecification` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.HasDataSpecification` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _HAS_DATA_SPECIFICATION_FROM_JSONABLE_DISPATCH, "HasDataSpecification" )
[docs]def administrative_information_from_jsonable( jsonable: Jsonable, ) -> our_types.AdministrativeInformation: """ Parse an instance of :py:class:`.types.AdministrativeInformation` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AdministrativeInformation` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_version: Optional[str] = None the_revision: Optional[str] = None the_creator: Optional[our_types.Reference] = None the_created_at: Optional[str] = None the_updated_at: Optional[str] = None the_template_id: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "version": the_version = _str_from_jsonable(jsonable_value) elif key == "revision": the_revision = _str_from_jsonable(jsonable_value) elif key == "creator": the_creator = reference_from_jsonable(jsonable_value) elif key == "createdAt": the_created_at = _str_from_jsonable(jsonable_value) elif key == "updatedAt": the_updated_at = _str_from_jsonable(jsonable_value) elif key == "templateId": the_template_id = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.AdministrativeInformation( the_embedded_data_specifications, the_version, the_revision, the_creator, the_created_at, the_updated_at, the_template_id, )
[docs]def qualifiable_from_jsonable(jsonable: Jsonable) -> our_types.Qualifiable: """ Parse an instance of :py:class:`.types.Qualifiable` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.Qualifiable` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _QUALIFIABLE_FROM_JSONABLE_DISPATCH, "Qualifiable" )
[docs]def qualifier_kind_from_jsonable(jsonable: Jsonable) -> our_types.QualifierKind: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.QualifierKind`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.qualifier_kind_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of QualifierKind: {jsonable}" ) return literal
[docs]def qualifier_from_jsonable(jsonable: Jsonable) -> our_types.Qualifier: """ Parse an instance of :py:class:`.types.Qualifier` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Qualifier` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_kind: Optional[our_types.QualifierKind] = None the_type: Optional[str] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None the_value: Optional[str] = None the_value_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "kind": the_kind = qualifier_kind_from_jsonable(jsonable_value) elif key == "type": the_type = _str_from_jsonable(jsonable_value) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "valueId": the_value_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type is None: raise DeserializationException("The required property 'type' is missing") if the_value_type is None: raise DeserializationException("The required property 'valueType' is missing") return our_types.Qualifier( the_type, the_value_type, the_semantic_id, the_supplemental_semantic_ids, the_kind, the_value, the_value_id, )
[docs]def asset_administration_shell_from_jsonable( jsonable: Jsonable, ) -> our_types.AssetAdministrationShell: """ Parse an instance of :py:class:`.types.AssetAdministrationShell` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AssetAdministrationShell` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "AssetAdministrationShell": raise DeserializationException( f"Expected modelType to be 'AssetAdministrationShell', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id: Optional[str] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_derived_from: Optional[our_types.Reference] = None the_asset_information: Optional[our_types.AssetInformation] = None the_submodels: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "derivedFrom": the_derived_from = reference_from_jsonable(jsonable_value) elif key == "assetInformation": the_asset_information = asset_information_from_jsonable(jsonable_value) elif key == "submodels": the_submodels = _list_of__reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") if the_asset_information is None: raise DeserializationException( "The required property 'assetInformation' is missing" ) return our_types.AssetAdministrationShell( the_id, the_asset_information, the_extensions, the_category, the_id_short, the_display_name, the_description, the_administration, the_embedded_data_specifications, the_derived_from, the_submodels, )
[docs]def asset_information_from_jsonable(jsonable: Jsonable) -> our_types.AssetInformation: """ Parse an instance of :py:class:`.types.AssetInformation` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AssetInformation` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_asset_kind: Optional[our_types.AssetKind] = None the_global_asset_id: Optional[str] = None the_specific_asset_ids: Optional[List[our_types.SpecificAssetID]] = None the_asset_type: Optional[str] = None the_default_thumbnail: Optional[our_types.Resource] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "assetKind": the_asset_kind = asset_kind_from_jsonable(jsonable_value) elif key == "globalAssetId": the_global_asset_id = _str_from_jsonable(jsonable_value) elif key == "specificAssetIds": the_specific_asset_ids = _list_of__specific_asset_id_from_jsonable( jsonable_value ) elif key == "assetType": the_asset_type = _str_from_jsonable(jsonable_value) elif key == "defaultThumbnail": the_default_thumbnail = resource_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_asset_kind is None: raise DeserializationException("The required property 'assetKind' is missing") return our_types.AssetInformation( the_asset_kind, the_global_asset_id, the_specific_asset_ids, the_asset_type, the_default_thumbnail, )
[docs]def resource_from_jsonable(jsonable: Jsonable) -> our_types.Resource: """ Parse an instance of :py:class:`.types.Resource` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Resource` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_path: Optional[str] = None the_content_type: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "path": the_path = _str_from_jsonable(jsonable_value) elif key == "contentType": the_content_type = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_path is None: raise DeserializationException("The required property 'path' is missing") return our_types.Resource(the_path, the_content_type)
[docs]def asset_kind_from_jsonable(jsonable: Jsonable) -> our_types.AssetKind: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.AssetKind`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.asset_kind_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of AssetKind: {jsonable}" ) return literal
[docs]def specific_asset_id_from_jsonable(jsonable: Jsonable) -> our_types.SpecificAssetID: """ Parse an instance of :py:class:`.types.SpecificAssetID` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SpecificAssetID` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_name: Optional[str] = None the_value: Optional[str] = None the_external_subject_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "name": the_name = _str_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "externalSubjectId": the_external_subject_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_name is None: raise DeserializationException("The required property 'name' is missing") if the_value is None: raise DeserializationException("The required property 'value' is missing") return our_types.SpecificAssetID( the_name, the_value, the_semantic_id, the_supplemental_semantic_ids, the_external_subject_id, )
[docs]def submodel_from_jsonable(jsonable: Jsonable) -> our_types.Submodel: """ Parse an instance of :py:class:`.types.Submodel` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Submodel` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Submodel": raise DeserializationException( f"Expected modelType to be 'Submodel', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id: Optional[str] = None the_kind: Optional[our_types.ModellingKind] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_submodel_elements: Optional[List[our_types.SubmodelElement]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "kind": the_kind = modelling_kind_from_jsonable(jsonable_value) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "submodelElements": the_submodel_elements = _list_of__submodel_element_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.Submodel( the_id, the_extensions, the_category, the_id_short, the_display_name, the_description, the_administration, the_kind, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_submodel_elements, )
[docs]def submodel_element_from_jsonable(jsonable: Jsonable) -> our_types.SubmodelElement: """ Parse an instance of :py:class:`.types.SubmodelElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.SubmodelElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _SUBMODEL_ELEMENT_FROM_JSONABLE_DISPATCH, "SubmodelElement" )
[docs]def relationship_element_from_jsonable( jsonable: Jsonable, ) -> our_types.RelationshipElement: """ Parse an instance of :py:class:`.types.RelationshipElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.RelationshipElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _RELATIONSHIP_ELEMENT_FROM_JSONABLE_DISPATCH, "RelationshipElement" )
def _relationship_element_from_jsonable_without_dispatch( jsonable: Jsonable, ) -> our_types.RelationshipElement: """ Parse an instance of :py:class:`.types.RelationshipElement` from the JSON-able structure :paramref:`jsonable`. This function performs no dispatch! It is used to parse the properties as-are, and already assumes the exact model type. Usually, this function is called from within a dispatching function, and you never call it directly. If you want to de-serialize an instance of :py:class:`.types.RelationshipElement`, call :py:func:`relationship_element_from_jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RelationshipElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_first: Optional[our_types.Reference] = None the_second: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The dispatch has already matched the model type. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "first": the_first = reference_from_jsonable(jsonable_value) elif key == "second": the_second = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.RelationshipElement( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_first, the_second, )
[docs]def aas_submodel_elements_from_jsonable( jsonable: Jsonable, ) -> our_types.AASSubmodelElements: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.AASSubmodelElements`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.aas_submodel_elements_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of AASSubmodelElements: {jsonable}" ) return literal
[docs]def submodel_element_list_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementList: """ Parse an instance of :py:class:`.types.SubmodelElementList` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelElementList` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "SubmodelElementList": raise DeserializationException( f"Expected modelType to be 'SubmodelElementList', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_order_relevant: Optional[bool] = None the_semantic_id_list_element: Optional[our_types.Reference] = None the_type_value_list_element: Optional[our_types.AASSubmodelElements] = None the_value_type_list_element: Optional[our_types.DataTypeDefXSD] = None the_value: Optional[List[our_types.SubmodelElement]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "orderRelevant": the_order_relevant = _bool_from_jsonable(jsonable_value) elif key == "semanticIdListElement": the_semantic_id_list_element = reference_from_jsonable(jsonable_value) elif key == "typeValueListElement": the_type_value_list_element = aas_submodel_elements_from_jsonable( jsonable_value ) elif key == "valueTypeListElement": the_value_type_list_element = data_type_def_xsd_from_jsonable( jsonable_value ) elif key == "value": the_value = _list_of__submodel_element_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type_value_list_element is None: raise DeserializationException( "The required property 'typeValueListElement' is missing" ) return our_types.SubmodelElementList( the_type_value_list_element, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_order_relevant, the_semantic_id_list_element, the_value_type_list_element, the_value, )
[docs]def submodel_element_collection_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementCollection: """ Parse an instance of :py:class:`.types.SubmodelElementCollection` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelElementCollection` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "SubmodelElementCollection": raise DeserializationException( f"Expected modelType to be 'SubmodelElementCollection', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value: Optional[List[our_types.SubmodelElement]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "value": the_value = _list_of__submodel_element_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.SubmodelElementCollection( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, )
[docs]def data_element_from_jsonable(jsonable: Jsonable) -> our_types.DataElement: """ Parse an instance of :py:class:`.types.DataElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.DataElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _DATA_ELEMENT_FROM_JSONABLE_DISPATCH, "DataElement" )
[docs]def property_from_jsonable(jsonable: Jsonable) -> our_types.Property: """ Parse an instance of :py:class:`.types.Property` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Property` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Property": raise DeserializationException( f"Expected modelType to be 'Property', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None the_value: Optional[str] = None the_value_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "valueId": the_value_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value_type is None: raise DeserializationException("The required property 'valueType' is missing") return our_types.Property( the_value_type, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, the_value_id, )
[docs]def multi_language_property_from_jsonable( jsonable: Jsonable, ) -> our_types.MultiLanguageProperty: """ Parse an instance of :py:class:`.types.MultiLanguageProperty` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.MultiLanguageProperty` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "MultiLanguageProperty": raise DeserializationException( f"Expected modelType to be 'MultiLanguageProperty', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value: Optional[List[our_types.LangStringTextType]] = None the_value_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "value": the_value = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "valueId": the_value_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.MultiLanguageProperty( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, the_value_id, )
[docs]def range_from_jsonable(jsonable: Jsonable) -> our_types.Range: """ Parse an instance of :py:class:`.types.Range` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Range` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Range": raise DeserializationException( f"Expected modelType to be 'Range', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None the_min: Optional[str] = None the_max: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) elif key == "min": the_min = _str_from_jsonable(jsonable_value) elif key == "max": the_max = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value_type is None: raise DeserializationException("The required property 'valueType' is missing") return our_types.Range( the_value_type, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_min, the_max, )
[docs]def reference_element_from_jsonable(jsonable: Jsonable) -> our_types.ReferenceElement: """ Parse an instance of :py:class:`.types.ReferenceElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ReferenceElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "ReferenceElement": raise DeserializationException( f"Expected modelType to be 'ReferenceElement', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "value": the_value = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.ReferenceElement( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, )
[docs]def blob_from_jsonable(jsonable: Jsonable) -> our_types.Blob: """ Parse an instance of :py:class:`.types.Blob` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Blob` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Blob": raise DeserializationException( f"Expected modelType to be 'Blob', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value: Optional[bytes] = None the_content_type: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "value": the_value = _bytes_from_jsonable(jsonable_value) elif key == "contentType": the_content_type = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Blob( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, the_content_type, )
[docs]def file_from_jsonable(jsonable: Jsonable) -> our_types.File: """ Parse an instance of :py:class:`.types.File` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.File` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "File": raise DeserializationException( f"Expected modelType to be 'File', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value: Optional[str] = None the_content_type: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "contentType": the_content_type = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.File( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_value, the_content_type, )
[docs]def annotated_relationship_element_from_jsonable( jsonable: Jsonable, ) -> our_types.AnnotatedRelationshipElement: """ Parse an instance of :py:class:`.types.AnnotatedRelationshipElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AnnotatedRelationshipElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "AnnotatedRelationshipElement": raise DeserializationException( f"Expected modelType to be 'AnnotatedRelationshipElement', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_first: Optional[our_types.Reference] = None the_second: Optional[our_types.Reference] = None the_annotations: Optional[List[our_types.DataElement]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "first": the_first = reference_from_jsonable(jsonable_value) elif key == "second": the_second = reference_from_jsonable(jsonable_value) elif key == "annotations": the_annotations = _list_of__data_element_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.AnnotatedRelationshipElement( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_first, the_second, the_annotations, )
[docs]def entity_from_jsonable(jsonable: Jsonable) -> our_types.Entity: """ Parse an instance of :py:class:`.types.Entity` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Entity` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Entity": raise DeserializationException( f"Expected modelType to be 'Entity', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_statements: Optional[List[our_types.SubmodelElement]] = None the_entity_type: Optional[our_types.EntityType] = None the_global_asset_id: Optional[str] = None the_specific_asset_ids: Optional[List[our_types.SpecificAssetID]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "statements": the_statements = _list_of__submodel_element_from_jsonable( jsonable_value ) elif key == "entityType": the_entity_type = entity_type_from_jsonable(jsonable_value) elif key == "globalAssetId": the_global_asset_id = _str_from_jsonable(jsonable_value) elif key == "specificAssetIds": the_specific_asset_ids = _list_of__specific_asset_id_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Entity( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_statements, the_entity_type, the_global_asset_id, the_specific_asset_ids, )
[docs]def entity_type_from_jsonable(jsonable: Jsonable) -> our_types.EntityType: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.EntityType`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.entity_type_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of EntityType: {jsonable}" ) return literal
[docs]def direction_from_jsonable(jsonable: Jsonable) -> our_types.Direction: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.Direction`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.direction_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of Direction: {jsonable}" ) return literal
[docs]def state_of_event_from_jsonable(jsonable: Jsonable) -> our_types.StateOfEvent: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.StateOfEvent`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.state_of_event_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of StateOfEvent: {jsonable}" ) return literal
[docs]def event_payload_from_jsonable(jsonable: Jsonable) -> our_types.EventPayload: """ Parse an instance of :py:class:`.types.EventPayload` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EventPayload` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_source: Optional[our_types.Reference] = None the_source_semantic_id: Optional[our_types.Reference] = None the_observable_reference: Optional[our_types.Reference] = None the_observable_semantic_id: Optional[our_types.Reference] = None the_topic: Optional[str] = None the_subject_id: Optional[our_types.Reference] = None the_time_stamp: Optional[str] = None the_payload: Optional[bytes] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "source": the_source = reference_from_jsonable(jsonable_value) elif key == "sourceSemanticId": the_source_semantic_id = reference_from_jsonable(jsonable_value) elif key == "observableReference": the_observable_reference = reference_from_jsonable(jsonable_value) elif key == "observableSemanticId": the_observable_semantic_id = reference_from_jsonable(jsonable_value) elif key == "topic": the_topic = _str_from_jsonable(jsonable_value) elif key == "subjectId": the_subject_id = reference_from_jsonable(jsonable_value) elif key == "timeStamp": the_time_stamp = _str_from_jsonable(jsonable_value) elif key == "payload": the_payload = _bytes_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_source is None: raise DeserializationException("The required property 'source' is missing") if the_observable_reference is None: raise DeserializationException( "The required property 'observableReference' is missing" ) if the_time_stamp is None: raise DeserializationException("The required property 'timeStamp' is missing") return our_types.EventPayload( the_source, the_observable_reference, the_time_stamp, the_source_semantic_id, the_observable_semantic_id, the_topic, the_subject_id, the_payload, )
[docs]def event_element_from_jsonable(jsonable: Jsonable) -> our_types.EventElement: """ Parse an instance of :py:class:`.types.EventElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.EventElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _EVENT_ELEMENT_FROM_JSONABLE_DISPATCH, "EventElement" )
[docs]def basic_event_element_from_jsonable( jsonable: Jsonable, ) -> our_types.BasicEventElement: """ Parse an instance of :py:class:`.types.BasicEventElement` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BasicEventElement` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "BasicEventElement": raise DeserializationException( f"Expected modelType to be 'BasicEventElement', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_observed: Optional[our_types.Reference] = None the_direction: Optional[our_types.Direction] = None the_state: Optional[our_types.StateOfEvent] = None the_message_topic: Optional[str] = None the_message_broker: Optional[our_types.Reference] = None the_last_update: Optional[str] = None the_min_interval: Optional[str] = None the_max_interval: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "observed": the_observed = reference_from_jsonable(jsonable_value) elif key == "direction": the_direction = direction_from_jsonable(jsonable_value) elif key == "state": the_state = state_of_event_from_jsonable(jsonable_value) elif key == "messageTopic": the_message_topic = _str_from_jsonable(jsonable_value) elif key == "messageBroker": the_message_broker = reference_from_jsonable(jsonable_value) elif key == "lastUpdate": the_last_update = _str_from_jsonable(jsonable_value) elif key == "minInterval": the_min_interval = _str_from_jsonable(jsonable_value) elif key == "maxInterval": the_max_interval = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_observed is None: raise DeserializationException("The required property 'observed' is missing") if the_direction is None: raise DeserializationException("The required property 'direction' is missing") if the_state is None: raise DeserializationException("The required property 'state' is missing") return our_types.BasicEventElement( the_observed, the_direction, the_state, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_message_topic, the_message_broker, the_last_update, the_min_interval, the_max_interval, )
[docs]def operation_from_jsonable(jsonable: Jsonable) -> our_types.Operation: """ Parse an instance of :py:class:`.types.Operation` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Operation` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Operation": raise DeserializationException( f"Expected modelType to be 'Operation', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_input_variables: Optional[List[our_types.OperationVariable]] = None the_output_variables: Optional[List[our_types.OperationVariable]] = None the_inoutput_variables: Optional[List[our_types.OperationVariable]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "inputVariables": the_input_variables = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "outputVariables": the_output_variables = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "inoutputVariables": the_inoutput_variables = _list_of__operation_variable_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Operation( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_input_variables, the_output_variables, the_inoutput_variables, )
[docs]def operation_variable_from_jsonable(jsonable: Jsonable) -> our_types.OperationVariable: """ Parse an instance of :py:class:`.types.OperationVariable` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationVariable` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_value: Optional[our_types.SubmodelElement] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "value": the_value = submodel_element_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value is None: raise DeserializationException("The required property 'value' is missing") return our_types.OperationVariable(the_value)
[docs]def capability_from_jsonable(jsonable: Jsonable) -> our_types.Capability: """ Parse an instance of :py:class:`.types.Capability` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Capability` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "Capability": raise DeserializationException( f"Expected modelType to be 'Capability', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Capability( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def concept_description_from_jsonable( jsonable: Jsonable, ) -> our_types.ConceptDescription: """ Parse an instance of :py:class:`.types.ConceptDescription` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ConceptDescription` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "ConceptDescription": raise DeserializationException( f"Expected modelType to be 'ConceptDescription', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id: Optional[str] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_is_case_of: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "isCaseOf": the_is_case_of = _list_of__reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.ConceptDescription( the_id, the_extensions, the_category, the_id_short, the_display_name, the_description, the_administration, the_embedded_data_specifications, the_is_case_of, )
[docs]def reference_types_from_jsonable(jsonable: Jsonable) -> our_types.ReferenceTypes: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.ReferenceTypes`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.reference_types_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of ReferenceTypes: {jsonable}" ) return literal
[docs]def reference_from_jsonable(jsonable: Jsonable) -> our_types.Reference: """ Parse an instance of :py:class:`.types.Reference` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Reference` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_type: Optional[our_types.ReferenceTypes] = None the_referred_semantic_id: Optional[our_types.Reference] = None the_keys: Optional[List[our_types.Key]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "type": the_type = reference_types_from_jsonable(jsonable_value) elif key == "referredSemanticId": the_referred_semantic_id = reference_from_jsonable(jsonable_value) elif key == "keys": the_keys = _list_of__key_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type is None: raise DeserializationException("The required property 'type' is missing") if the_keys is None: raise DeserializationException("The required property 'keys' is missing") return our_types.Reference(the_type, the_keys, the_referred_semantic_id)
[docs]def key_from_jsonable(jsonable: Jsonable) -> our_types.Key: """ Parse an instance of :py:class:`.types.Key` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Key` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_type: Optional[our_types.KeyTypes] = None the_value: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "type": the_type = key_types_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type is None: raise DeserializationException("The required property 'type' is missing") if the_value is None: raise DeserializationException("The required property 'value' is missing") return our_types.Key(the_type, the_value)
[docs]def key_types_from_jsonable(jsonable: Jsonable) -> our_types.KeyTypes: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.KeyTypes`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.key_types_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of KeyTypes: {jsonable}" ) return literal
[docs]def data_type_def_xsd_from_jsonable(jsonable: Jsonable) -> our_types.DataTypeDefXSD: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.DataTypeDefXSD`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.data_type_def_xsd_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of DataTypeDefXSD: {jsonable}" ) return literal
[docs]def abstract_lang_string_from_jsonable( jsonable: Jsonable, ) -> our_types.AbstractLangString: """ Parse an instance of :py:class:`.types.AbstractLangString` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.AbstractLangString` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _ABSTRACT_LANG_STRING_FROM_JSONABLE_DISPATCH, "AbstractLangString" )
[docs]def lang_string_name_type_from_jsonable( jsonable: Jsonable, ) -> our_types.LangStringNameType: """ Parse an instance of :py:class:`.types.LangStringNameType` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringNameType` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringNameType(the_language, the_text)
[docs]def lang_string_text_type_from_jsonable( jsonable: Jsonable, ) -> our_types.LangStringTextType: """ Parse an instance of :py:class:`.types.LangStringTextType` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringTextType` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringTextType(the_language, the_text)
[docs]def environment_from_jsonable(jsonable: Jsonable) -> our_types.Environment: """ Parse an instance of :py:class:`.types.Environment` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Environment` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_asset_administration_shells: Optional[ List[our_types.AssetAdministrationShell] ] = None the_submodels: Optional[List[our_types.Submodel]] = None the_concept_descriptions: Optional[List[our_types.ConceptDescription]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "assetAdministrationShells": the_asset_administration_shells = ( _list_of__asset_administration_shell_from_jsonable(jsonable_value) ) elif key == "submodels": the_submodels = _list_of__submodel_from_jsonable(jsonable_value) elif key == "conceptDescriptions": the_concept_descriptions = _list_of__concept_description_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Environment( the_asset_administration_shells, the_submodels, the_concept_descriptions )
[docs]def data_specification_content_from_jsonable( jsonable: Jsonable, ) -> our_types.DataSpecificationContent: """ Parse an instance of :py:class:`.types.DataSpecificationContent` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.DataSpecificationContent` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _DATA_SPECIFICATION_CONTENT_FROM_JSONABLE_DISPATCH, "DataSpecificationContent", )
[docs]def embedded_data_specification_from_jsonable( jsonable: Jsonable, ) -> our_types.EmbeddedDataSpecification: """ Parse an instance of :py:class:`.types.EmbeddedDataSpecification` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EmbeddedDataSpecification` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_data_specification: Optional[our_types.Reference] = None the_data_specification_content: Optional[our_types.DataSpecificationContent] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "dataSpecification": the_data_specification = reference_from_jsonable(jsonable_value) elif key == "dataSpecificationContent": the_data_specification_content = ( data_specification_content_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_data_specification is None: raise DeserializationException( "The required property 'dataSpecification' is missing" ) if the_data_specification_content is None: raise DeserializationException( "The required property 'dataSpecificationContent' is missing" ) return our_types.EmbeddedDataSpecification( the_data_specification, the_data_specification_content )
[docs]def data_type_iec_61360_from_jsonable(jsonable: Jsonable) -> our_types.DataTypeIEC61360: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.DataTypeIEC61360`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.data_type_iec_61360_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of DataTypeIEC61360: {jsonable}" ) return literal
[docs]def level_type_from_jsonable(jsonable: Jsonable) -> our_types.LevelType: """ Parse an instance of :py:class:`.types.LevelType` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LevelType` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_min: Optional[bool] = None the_nom: Optional[bool] = None the_typ: Optional[bool] = None the_max: Optional[bool] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "min": the_min = _bool_from_jsonable(jsonable_value) elif key == "nom": the_nom = _bool_from_jsonable(jsonable_value) elif key == "typ": the_typ = _bool_from_jsonable(jsonable_value) elif key == "max": the_max = _bool_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_min is None: raise DeserializationException("The required property 'min' is missing") if the_nom is None: raise DeserializationException("The required property 'nom' is missing") if the_typ is None: raise DeserializationException("The required property 'typ' is missing") if the_max is None: raise DeserializationException("The required property 'max' is missing") return our_types.LevelType(the_min, the_nom, the_typ, the_max)
[docs]def value_reference_pair_from_jsonable( jsonable: Jsonable, ) -> our_types.ValueReferencePair: """ Parse an instance of :py:class:`.types.ValueReferencePair` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ValueReferencePair` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_value: Optional[str] = None the_value_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "valueId": the_value_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value is None: raise DeserializationException("The required property 'value' is missing") return our_types.ValueReferencePair(the_value, the_value_id)
[docs]def value_list_from_jsonable(jsonable: Jsonable) -> our_types.ValueList: """ Parse an instance of :py:class:`.types.ValueList` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ValueList` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_value_reference_pairs: Optional[List[our_types.ValueReferencePair]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "valueReferencePairs": the_value_reference_pairs = ( _list_of__value_reference_pair_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value_reference_pairs is None: raise DeserializationException( "The required property 'valueReferencePairs' is missing" ) return our_types.ValueList(the_value_reference_pairs)
[docs]def lang_string_preferred_name_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> our_types.LangStringPreferredNameTypeIEC61360: """ Parse an instance of :py:class:`.types.LangStringPreferredNameTypeIEC61360` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringPreferredNameTypeIEC61360` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringPreferredNameTypeIEC61360(the_language, the_text)
[docs]def lang_string_short_name_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> our_types.LangStringShortNameTypeIEC61360: """ Parse an instance of :py:class:`.types.LangStringShortNameTypeIEC61360` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringShortNameTypeIEC61360` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringShortNameTypeIEC61360(the_language, the_text)
[docs]def lang_string_definition_type_iec_61360_from_jsonable( jsonable: Jsonable, ) -> our_types.LangStringDefinitionTypeIEC61360: """ Parse an instance of :py:class:`.types.LangStringDefinitionTypeIEC61360` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringDefinitionTypeIEC61360` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringDefinitionTypeIEC61360(the_language, the_text)
[docs]def lang_string_uom_from_jsonable(jsonable: Jsonable) -> our_types.LangStringUom: """ Parse an instance of :py:class:`.types.LangStringUom` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LangStringUom` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.LangStringUom(the_language, the_text)
[docs]def definition_type_uom_from_jsonable( jsonable: Jsonable, ) -> our_types.DefinitionTypeUom: """ Parse an instance of :py:class:`.types.DefinitionTypeUom` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DefinitionTypeUom` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_language: Optional[str] = None the_text: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "language": the_language = _str_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_language is None: raise DeserializationException("The required property 'language' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.DefinitionTypeUom(the_language, the_text)
[docs]def data_specification_uom_from_jsonable( jsonable: Jsonable, ) -> our_types.DataSpecificationUom: """ Parse an instance of :py:class:`.types.DataSpecificationUom` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DataSpecificationUom` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "DataSpecificationUom": raise DeserializationException( f"Expected modelType to be 'DataSpecificationUom', " f"but got: {model_type!r}" ) the_preferred_name: Optional[List[our_types.LangStringUom]] = None the_symbol: Optional[str] = None the_specific_unit_id: Optional[str] = None the_definition: Optional[List[our_types.DefinitionTypeUom]] = None the_preferred_name_quantity: Optional[List[our_types.LangStringUom]] = None the_quantity_id: Optional[str] = None the_classification_system: Optional[str] = None the_classification_system_version: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "preferredName": the_preferred_name = _list_of__lang_string_uom_from_jsonable( jsonable_value ) elif key == "symbol": the_symbol = _str_from_jsonable(jsonable_value) elif key == "specificUnitId": the_specific_unit_id = _str_from_jsonable(jsonable_value) elif key == "definition": the_definition = _list_of__definition_type_uom_from_jsonable( jsonable_value ) elif key == "preferredNameQuantity": the_preferred_name_quantity = _list_of__lang_string_uom_from_jsonable( jsonable_value ) elif key == "quantityId": the_quantity_id = _str_from_jsonable(jsonable_value) elif key == "classificationSystem": the_classification_system = _str_from_jsonable(jsonable_value) elif key == "classificationSystemVersion": the_classification_system_version = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_preferred_name is None: raise DeserializationException( "The required property 'preferredName' is missing" ) if the_symbol is None: raise DeserializationException("The required property 'symbol' is missing") return our_types.DataSpecificationUom( the_preferred_name, the_symbol, the_specific_unit_id, the_definition, the_preferred_name_quantity, the_quantity_id, the_classification_system, the_classification_system_version, )
[docs]def data_specification_iec_61360_from_jsonable( jsonable: Jsonable, ) -> our_types.DataSpecificationIEC61360: """ Parse an instance of :py:class:`.types.DataSpecificationIEC61360` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DataSpecificationIEC61360` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "DataSpecificationIec61360": raise DeserializationException( f"Expected modelType to be 'DataSpecificationIec61360', " f"but got: {model_type!r}" ) the_preferred_name: Optional[ List[our_types.LangStringPreferredNameTypeIEC61360] ] = None the_short_name: Optional[List[our_types.LangStringShortNameTypeIEC61360]] = None the_unit: Optional[str] = None the_unit_id: Optional[our_types.Reference] = None the_source_of_definition: Optional[str] = None the_symbol: Optional[str] = None the_data_type: Optional[our_types.DataTypeIEC61360] = None the_definition: Optional[List[our_types.LangStringDefinitionTypeIEC61360]] = None the_value_format: Optional[str] = None the_value_list: Optional[our_types.ValueList] = None the_value: Optional[str] = None the_level_type: Optional[our_types.LevelType] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "preferredName": the_preferred_name = ( _list_of__lang_string_preferred_name_type_iec_61360_from_jsonable( jsonable_value ) ) elif key == "shortName": the_short_name = ( _list_of__lang_string_short_name_type_iec_61360_from_jsonable( jsonable_value ) ) elif key == "unit": the_unit = _str_from_jsonable(jsonable_value) elif key == "unitId": the_unit_id = reference_from_jsonable(jsonable_value) elif key == "sourceOfDefinition": the_source_of_definition = _str_from_jsonable(jsonable_value) elif key == "symbol": the_symbol = _str_from_jsonable(jsonable_value) elif key == "dataType": the_data_type = data_type_iec_61360_from_jsonable(jsonable_value) elif key == "definition": the_definition = ( _list_of__lang_string_definition_type_iec_61360_from_jsonable( jsonable_value ) ) elif key == "valueFormat": the_value_format = _str_from_jsonable(jsonable_value) elif key == "valueList": the_value_list = value_list_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) elif key == "levelType": the_level_type = level_type_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_preferred_name is None: raise DeserializationException( "The required property 'preferredName' is missing" ) return our_types.DataSpecificationIEC61360( the_preferred_name, the_short_name, the_unit, the_unit_id, the_source_of_definition, the_symbol, the_data_type, the_definition, the_value_format, the_value_list, the_value, the_level_type, )
[docs]def serialization_format_from_jsonable( jsonable: Jsonable, ) -> our_types.SerializationFormat: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.SerializationFormat`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.serialization_format_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of SerializationFormat: {jsonable}" ) return literal
[docs]def descriptor_from_jsonable(jsonable: Jsonable) -> our_types.Descriptor: """ Parse an instance of :py:class:`.types.Descriptor` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.Descriptor` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _DESCRIPTOR_FROM_JSONABLE_DISPATCH, "Descriptor" )
[docs]def asset_administration_shell_descriptor_from_jsonable( jsonable: Jsonable, ) -> our_types.AssetAdministrationShellDescriptor: """ Parse an instance of :py:class:`.types.AssetAdministrationShellDescriptor` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AssetAdministrationShellDescriptor` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_description: Optional[List[our_types.LangStringTextType]] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_extensions: Optional[List[our_types.Extension]] = None the_id: Optional[str] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_asset_kind: Optional[our_types.AssetKind] = None the_asset_type: Optional[str] = None the_endpoints: Optional[List[our_types.Endpoint]] = None the_global_asset_id: Optional[str] = None the_id_short: Optional[str] = None the_specific_asset_ids: Optional[List[our_types.SpecificAssetID]] = None the_submodel_descriptors: Optional[List[our_types.SubmodelDescriptor]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "assetKind": the_asset_kind = asset_kind_from_jsonable(jsonable_value) elif key == "assetType": the_asset_type = _str_from_jsonable(jsonable_value) elif key == "endpoints": the_endpoints = _list_of__endpoint_from_jsonable(jsonable_value) elif key == "globalAssetId": the_global_asset_id = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "specificAssetIds": the_specific_asset_ids = _list_of__specific_asset_id_from_jsonable( jsonable_value ) elif key == "submodelDescriptors": the_submodel_descriptors = _list_of__submodel_descriptor_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.AssetAdministrationShellDescriptor( the_id, the_description, the_display_name, the_extensions, the_administration, the_asset_kind, the_asset_type, the_endpoints, the_global_asset_id, the_id_short, the_specific_asset_ids, the_submodel_descriptors, )
[docs]def submodel_descriptor_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelDescriptor: """ Parse an instance of :py:class:`.types.SubmodelDescriptor` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelDescriptor` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_description: Optional[List[our_types.LangStringTextType]] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_extensions: Optional[List[our_types.Extension]] = None the_endpoints: Optional[List[our_types.Endpoint]] = None the_id: Optional[str] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id_short: Optional[str] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "endpoints": the_endpoints = _list_of__endpoint_from_jsonable(jsonable_value) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_endpoints is None: raise DeserializationException("The required property 'endpoints' is missing") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.SubmodelDescriptor( the_endpoints, the_id, the_description, the_display_name, the_extensions, the_administration, the_id_short, the_semantic_id, the_supplemental_semantic_ids, )
[docs]def endpoint_from_jsonable(jsonable: Jsonable) -> our_types.Endpoint: """ Parse an instance of :py:class:`.types.Endpoint` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Endpoint` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_protocol_information: Optional[our_types.ProtocolInformation] = None the_interface: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "protocolInformation": the_protocol_information = protocol_information_from_jsonable( jsonable_value ) elif key == "interface": the_interface = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_protocol_information is None: raise DeserializationException( "The required property 'protocolInformation' is missing" ) if the_interface is None: raise DeserializationException("The required property 'interface' is missing") return our_types.Endpoint(the_protocol_information, the_interface)
[docs]def protocol_information_from_jsonable( jsonable: Jsonable, ) -> our_types.ProtocolInformation: """ Parse an instance of :py:class:`.types.ProtocolInformation` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ProtocolInformation` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_href: Optional[str] = None the_endpoint_protocol: Optional[str] = None the_endpoint_protocol_version: Optional[List[str]] = None the_subprotocol: Optional[str] = None the_subprotocol_body: Optional[str] = None the_subprotocol_body_encoding: Optional[str] = None the_security_attributes: Optional[List[our_types.SecurityAttributeObject]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "href": the_href = _str_from_jsonable(jsonable_value) elif key == "endpointProtocol": the_endpoint_protocol = _str_from_jsonable(jsonable_value) elif key == "endpointProtocolVersion": the_endpoint_protocol_version = _list_of__str_from_jsonable( jsonable_value ) elif key == "subprotocol": the_subprotocol = _str_from_jsonable(jsonable_value) elif key == "subprotocolBody": the_subprotocol_body = _str_from_jsonable(jsonable_value) elif key == "subprotocolBodyEncoding": the_subprotocol_body_encoding = _str_from_jsonable(jsonable_value) elif key == "securityAttributes": the_security_attributes = ( _list_of__security_attribute_object_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_href is None: raise DeserializationException("The required property 'href' is missing") return our_types.ProtocolInformation( the_href, the_endpoint_protocol, the_endpoint_protocol_version, the_subprotocol, the_subprotocol_body, the_subprotocol_body_encoding, the_security_attributes, )
[docs]def security_attribute_object_from_jsonable( jsonable: Jsonable, ) -> our_types.SecurityAttributeObject: """ Parse an instance of :py:class:`.types.SecurityAttributeObject` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SecurityAttributeObject` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_type: Optional[our_types.SecurityTypeEnum] = None the_key: Optional[str] = None the_value: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "type": the_type = security_type_enum_from_jsonable(jsonable_value) elif key == "key": the_key = _str_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type is None: raise DeserializationException("The required property 'type' is missing") if the_key is None: raise DeserializationException("The required property 'key' is missing") if the_value is None: raise DeserializationException("The required property 'value' is missing") return our_types.SecurityAttributeObject(the_type, the_key, the_value)
[docs]def security_type_enum_from_jsonable(jsonable: Jsonable) -> our_types.SecurityTypeEnum: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.SecurityTypeEnum`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.security_type_enum_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of SecurityTypeEnum: {jsonable}" ) return literal
[docs]def service_description_from_jsonable( jsonable: Jsonable, ) -> our_types.ServiceDescription: """ Parse an instance of :py:class:`.types.ServiceDescription` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ServiceDescription` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_profiles: Optional[List[our_types.ServiceSpecificationProfileEnum]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "profiles": the_profiles = ( _list_of__service_specification_profile_enum_from_jsonable( jsonable_value ) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_profiles is None: raise DeserializationException("The required property 'profiles' is missing") return our_types.ServiceDescription(the_profiles)
[docs]def service_specification_profile_enum_from_jsonable( jsonable: Jsonable, ) -> our_types.ServiceSpecificationProfileEnum: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.ServiceSpecificationProfileEnum`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.service_specification_profile_enum_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of ServiceSpecificationProfileEnum: {jsonable}" ) return literal
[docs]def recent_change_from_jsonable(jsonable: Jsonable) -> our_types.RecentChange: """ Parse an instance of :py:class:`.types.RecentChange` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.RecentChange` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _RECENT_CHANGE_FROM_JSONABLE_DISPATCH, "RecentChange" )
[docs]def asset_administration_shell_recent_change_from_jsonable( jsonable: Jsonable, ) -> our_types.AssetAdministrationShellRecentChange: """ Parse an instance of :py:class:`.types.AssetAdministrationShellRecentChange` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AssetAdministrationShellRecentChange` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_created_at: Optional[str] = None the_updated_at: Optional[str] = None the_id: Optional[str] = None the_global_asset_id: Optional[str] = None the_specific_asset_ids: Optional[List[our_types.SpecificAssetID]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "createdAt": the_created_at = _str_from_jsonable(jsonable_value) elif key == "updatedAt": the_updated_at = _str_from_jsonable(jsonable_value) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "globalAssetId": the_global_asset_id = _str_from_jsonable(jsonable_value) elif key == "specificAssetIds": the_specific_asset_ids = _list_of__specific_asset_id_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_created_at is None: raise DeserializationException("The required property 'createdAt' is missing") if the_updated_at is None: raise DeserializationException("The required property 'updatedAt' is missing") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.AssetAdministrationShellRecentChange( the_created_at, the_updated_at, the_id, the_global_asset_id, the_specific_asset_ids, )
[docs]def concept_description_recent_change_from_jsonable( jsonable: Jsonable, ) -> our_types.ConceptDescriptionRecentChange: """ Parse an instance of :py:class:`.types.ConceptDescriptionRecentChange` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ConceptDescriptionRecentChange` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_created_at: Optional[str] = None the_updated_at: Optional[str] = None the_id: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "createdAt": the_created_at = _str_from_jsonable(jsonable_value) elif key == "updatedAt": the_updated_at = _str_from_jsonable(jsonable_value) elif key == "id": the_id = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_created_at is None: raise DeserializationException("The required property 'createdAt' is missing") if the_updated_at is None: raise DeserializationException("The required property 'updatedAt' is missing") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.ConceptDescriptionRecentChange( the_created_at, the_updated_at, the_id )
[docs]def submodel_recent_change_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelRecentChange: """ Parse an instance of :py:class:`.types.SubmodelRecentChange` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelRecentChange` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_created_at: Optional[str] = None the_updated_at: Optional[str] = None the_id: Optional[str] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "createdAt": the_created_at = _str_from_jsonable(jsonable_value) elif key == "updatedAt": the_updated_at = _str_from_jsonable(jsonable_value) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_created_at is None: raise DeserializationException("The required property 'createdAt' is missing") if the_updated_at is None: raise DeserializationException("The required property 'updatedAt' is missing") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.SubmodelRecentChange( the_created_at, the_updated_at, the_id, the_semantic_id, the_supplemental_semantic_ids, )
[docs]def status_code_from_jsonable(jsonable: Jsonable) -> our_types.StatusCode: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.StatusCode`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.status_code_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of StatusCode: {jsonable}" ) return literal
[docs]def result_from_jsonable(jsonable: Jsonable) -> our_types.Result: """ Parse an instance of :py:class:`.types.Result` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Result` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_messages: Optional[List[our_types.Message]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "messages": the_messages = _list_of__message_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.Result(the_messages)
[docs]def message_from_jsonable(jsonable: Jsonable) -> our_types.Message: """ Parse an instance of :py:class:`.types.Message` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Message` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_message_type: Optional[our_types.MessageTypeEnum] = None the_text: Optional[str] = None the_code: Optional[str] = None the_correlation_id: Optional[str] = None the_timestamp: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "messageType": the_message_type = message_type_enum_from_jsonable(jsonable_value) elif key == "text": the_text = _str_from_jsonable(jsonable_value) elif key == "code": the_code = _str_from_jsonable(jsonable_value) elif key == "correlationId": the_correlation_id = _str_from_jsonable(jsonable_value) elif key == "timestamp": the_timestamp = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_message_type is None: raise DeserializationException("The required property 'messageType' is missing") if the_text is None: raise DeserializationException("The required property 'text' is missing") return our_types.Message( the_message_type, the_text, the_code, the_correlation_id, the_timestamp )
[docs]def message_type_enum_from_jsonable(jsonable: Jsonable) -> our_types.MessageTypeEnum: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.MessageTypeEnum`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.message_type_enum_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of MessageTypeEnum: {jsonable}" ) return literal
[docs]def operation_request_from_jsonable(jsonable: Jsonable) -> our_types.OperationRequest: """ Parse an instance of :py:class:`.types.OperationRequest` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationRequest` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_input_arguments: Optional[List[our_types.OperationVariable]] = None the_inoutput_arguments: Optional[List[our_types.OperationVariable]] = None the_client_timeout_duration: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "inputArguments": the_input_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "inoutputArguments": the_inoutput_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "clientTimeoutDuration": the_client_timeout_duration = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.OperationRequest( the_input_arguments, the_inoutput_arguments, the_client_timeout_duration )
[docs]def operation_request_async_from_jsonable( jsonable: Jsonable, ) -> our_types.OperationRequestAsync: """ Parse an instance of :py:class:`.types.OperationRequestAsync` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationRequestAsync` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_input_arguments: Optional[List[our_types.OperationVariable]] = None the_inoutput_arguments: Optional[List[our_types.OperationVariable]] = None the_client_timeout_duration: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "inputArguments": the_input_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "inoutputArguments": the_inoutput_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "clientTimeoutDuration": the_client_timeout_duration = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_client_timeout_duration is None: raise DeserializationException( "The required property 'clientTimeoutDuration' is missing" ) return our_types.OperationRequestAsync( the_client_timeout_duration, the_input_arguments, the_inoutput_arguments )
[docs]def operation_request_value_only_from_jsonable( jsonable: Jsonable, ) -> our_types.OperationRequestValueOnly: """ Parse an instance of :py:class:`.types.OperationRequestValueOnly` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationRequestValueOnly` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_input_arguments: Optional[our_types.JsonObject] = None the_inoutput_arguments: Optional[our_types.JsonObject] = None the_client_timeout_duration: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "inputArguments": the_input_arguments = _json_object_from_jsonable(jsonable_value) elif key == "inoutputArguments": the_inoutput_arguments = _json_object_from_jsonable(jsonable_value) elif key == "clientTimeoutDuration": the_client_timeout_duration = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.OperationRequestValueOnly( the_input_arguments, the_inoutput_arguments, the_client_timeout_duration )
[docs]def operation_request_async_value_only_from_jsonable( jsonable: Jsonable, ) -> our_types.OperationRequestAsyncValueOnly: """ Parse an instance of :py:class:`.types.OperationRequestAsyncValueOnly` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationRequestAsyncValueOnly` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_input_arguments: Optional[our_types.JsonObject] = None the_inoutput_arguments: Optional[our_types.JsonObject] = None the_client_timeout_duration: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "inputArguments": the_input_arguments = _json_object_from_jsonable(jsonable_value) elif key == "inoutputArguments": the_inoutput_arguments = _json_object_from_jsonable(jsonable_value) elif key == "clientTimeoutDuration": the_client_timeout_duration = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_client_timeout_duration is None: raise DeserializationException( "The required property 'clientTimeoutDuration' is missing" ) return our_types.OperationRequestAsyncValueOnly( the_client_timeout_duration, the_input_arguments, the_inoutput_arguments )
[docs]def base_operation_result_from_jsonable( jsonable: Jsonable, ) -> our_types.BaseOperationResult: """ Parse an instance of :py:class:`.types.BaseOperationResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BaseOperationResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_execution_state: Optional[our_types.ExecutionState] = None the_messages: Optional[List[our_types.Message]] = None the_success: Optional[bool] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "executionState": the_execution_state = execution_state_from_jsonable(jsonable_value) elif key == "messages": the_messages = _list_of__message_from_jsonable(jsonable_value) elif key == "success": the_success = _bool_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_execution_state is None: raise DeserializationException( "The required property 'executionState' is missing" ) return our_types.BaseOperationResult(the_execution_state, the_messages, the_success)
[docs]def operation_result_from_jsonable(jsonable: Jsonable) -> our_types.OperationResult: """ Parse an instance of :py:class:`.types.OperationResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_execution_state: Optional[our_types.ExecutionState] = None the_messages: Optional[List[our_types.Message]] = None the_success: Optional[bool] = None the_output_arguments: Optional[List[our_types.OperationVariable]] = None the_inoutput_arguments: Optional[List[our_types.OperationVariable]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "executionState": the_execution_state = execution_state_from_jsonable(jsonable_value) elif key == "messages": the_messages = _list_of__message_from_jsonable(jsonable_value) elif key == "success": the_success = _bool_from_jsonable(jsonable_value) elif key == "outputArguments": the_output_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) elif key == "inoutputArguments": the_inoutput_arguments = _list_of__operation_variable_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_execution_state is None: raise DeserializationException( "The required property 'executionState' is missing" ) return our_types.OperationResult( the_execution_state, the_messages, the_success, the_output_arguments, the_inoutput_arguments, )
[docs]def operation_result_value_only_from_jsonable( jsonable: Jsonable, ) -> our_types.OperationResultValueOnly: """ Parse an instance of :py:class:`.types.OperationResultValueOnly` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationResultValueOnly` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_execution_state: Optional[our_types.ExecutionState] = None the_messages: Optional[List[our_types.Message]] = None the_success: Optional[bool] = None the_output_arguments: Optional[our_types.JsonObject] = None the_inoutput_arguments: Optional[our_types.JsonObject] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "executionState": the_execution_state = execution_state_from_jsonable(jsonable_value) elif key == "messages": the_messages = _list_of__message_from_jsonable(jsonable_value) elif key == "success": the_success = _bool_from_jsonable(jsonable_value) elif key == "outputArguments": the_output_arguments = _json_object_from_jsonable(jsonable_value) elif key == "inoutputArguments": the_inoutput_arguments = _json_object_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_execution_state is None: raise DeserializationException( "The required property 'executionState' is missing" ) return our_types.OperationResultValueOnly( the_execution_state, the_messages, the_success, the_output_arguments, the_inoutput_arguments, )
[docs]def execution_state_from_jsonable(jsonable: Jsonable) -> our_types.ExecutionState: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.ExecutionState`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.execution_state_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of ExecutionState: {jsonable}" ) return literal
[docs]def operation_handle_from_jsonable(jsonable: Jsonable) -> our_types.OperationHandle: """ Parse an instance of :py:class:`.types.OperationHandle` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationHandle` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_handle_id: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "handleId": the_handle_id = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_handle_id is None: raise DeserializationException("The required property 'handleId' is missing") return our_types.OperationHandle(the_handle_id)
[docs]def level_from_jsonable(jsonable: Jsonable) -> our_types.Level: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.Level`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.level_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of Level: {jsonable}" ) return literal
[docs]def content_from_jsonable(jsonable: Jsonable) -> our_types.Content: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.Content`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.content_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of Content: {jsonable}" ) return literal
[docs]def extent_from_jsonable(jsonable: Jsonable) -> our_types.Extent: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.Extent`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.extent_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of Extent: {jsonable}" ) return literal
[docs]def paged_result_from_jsonable(jsonable: Jsonable) -> our_types.PagedResult: """ Parse an instance of :py:class:`.types.PagedResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.PagedResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_result: Optional[List[our_types.Referable]] = None the_paging_metadata: Optional[our_types.PagingMetadata] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "result": the_result = _list_of__referable_from_jsonable(jsonable_value) elif key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.PagedResult(the_paging_metadata, the_result)
[docs]def paging_metadata_from_jsonable(jsonable: Jsonable) -> our_types.PagingMetadata: """ Parse an instance of :py:class:`.types.PagingMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.PagingMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_cursor: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "cursor": the_cursor = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.PagingMetadata(the_cursor)
[docs]def package_description_from_jsonable( jsonable: Jsonable, ) -> our_types.PackageDescription: """ Parse an instance of :py:class:`.types.PackageDescription` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.PackageDescription` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_package_id: Optional[str] = None the_aas_ids: Optional[List[str]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "packageId": the_package_id = _str_from_jsonable(jsonable_value) elif key == "aasIds": the_aas_ids = _list_of__str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_package_id is None: raise DeserializationException("The required property 'packageId' is missing") return our_types.PackageDescription(the_package_id, the_aas_ids)
[docs]def submodel_element_attributes_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementAttributes: """ Parse an instance of :py:class:`.types.SubmodelElementAttributes` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.SubmodelElementAttributes` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _SUBMODEL_ELEMENT_ATTRIBUTES_FROM_JSONABLE_DISPATCH, "SubmodelElementAttributes", )
[docs]def submodel_element_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementMetadata: """ Parse an instance of :py:class:`.types.SubmodelElementMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance of :py:class:`.types.SubmodelElementMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ return _dispatch_from_jsonable( jsonable, _SUBMODEL_ELEMENT_METADATA_FROM_JSONABLE_DISPATCH, "SubmodelElementMetadata", )
[docs]def property_metadata_from_jsonable(jsonable: Jsonable) -> our_types.PropertyMetadata: """ Parse an instance of :py:class:`.types.PropertyMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.PropertyMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "PropertyMetadata": raise DeserializationException( f"Expected modelType to be 'PropertyMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value_type is None: raise DeserializationException("The required property 'valueType' is missing") return our_types.PropertyMetadata( the_value_type, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def range_metadata_from_jsonable(jsonable: Jsonable) -> our_types.RangeMetadata: """ Parse an instance of :py:class:`.types.RangeMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RangeMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "RangeMetadata": raise DeserializationException( f"Expected modelType to be 'RangeMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_value_type: Optional[our_types.DataTypeDefXSD] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "valueType": the_value_type = data_type_def_xsd_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_value_type is None: raise DeserializationException("The required property 'valueType' is missing") return our_types.RangeMetadata( the_value_type, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def blob_metadata_from_jsonable(jsonable: Jsonable) -> our_types.BlobMetadata: """ Parse an instance of :py:class:`.types.BlobMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BlobMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "BlobMetadata": raise DeserializationException( f"Expected modelType to be 'BlobMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.BlobMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def file_metadata_from_jsonable(jsonable: Jsonable) -> our_types.FileMetadata: """ Parse an instance of :py:class:`.types.FileMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.FileMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "FileMetadata": raise DeserializationException( f"Expected modelType to be 'FileMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.FileMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def multi_language_property_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.MultiLanguagePropertyMetadata: """ Parse an instance of :py:class:`.types.MultiLanguagePropertyMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.MultiLanguagePropertyMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "MultiLanguagePropertyMetadata": raise DeserializationException( f"Expected modelType to be 'MultiLanguagePropertyMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.MultiLanguagePropertyMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def reference_element_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.ReferenceElementMetadata: """ Parse an instance of :py:class:`.types.ReferenceElementMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ReferenceElementMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "ReferenceElementMetadata": raise DeserializationException( f"Expected modelType to be 'ReferenceElementMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.ReferenceElementMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def relationship_element_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.RelationshipElementMetadata: """ Parse an instance of :py:class:`.types.RelationshipElementMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RelationshipElementMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "RelationshipElementMetadata": raise DeserializationException( f"Expected modelType to be 'RelationshipElementMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.RelationshipElementMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def annotated_relationship_element_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.AnnotatedRelationshipElementMetadata: """ Parse an instance of :py:class:`.types.AnnotatedRelationshipElementMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AnnotatedRelationshipElementMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "AnnotatedRelationshipElementMetadata": raise DeserializationException( f"Expected modelType to be 'AnnotatedRelationshipElementMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.AnnotatedRelationshipElementMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def entity_metadata_from_jsonable(jsonable: Jsonable) -> our_types.EntityMetadata: """ Parse an instance of :py:class:`.types.EntityMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EntityMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "EntityMetadata": raise DeserializationException( f"Expected modelType to be 'EntityMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.EntityMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def capability_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.CapabilityMetadata: """ Parse an instance of :py:class:`.types.CapabilityMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.CapabilityMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "CapabilityMetadata": raise DeserializationException( f"Expected modelType to be 'CapabilityMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.CapabilityMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def operation_metadata_from_jsonable(jsonable: Jsonable) -> our_types.OperationMetadata: """ Parse an instance of :py:class:`.types.OperationMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OperationMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "OperationMetadata": raise DeserializationException( f"Expected modelType to be 'OperationMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.OperationMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def submodel_element_collection_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementCollectionMetadata: """ Parse an instance of :py:class:`.types.SubmodelElementCollectionMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelElementCollectionMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "SubmodelElementCollectionMetadata": raise DeserializationException( f"Expected modelType to be 'SubmodelElementCollectionMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.SubmodelElementCollectionMetadata( the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def basic_event_element_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.BasicEventElementMetadata: """ Parse an instance of :py:class:`.types.BasicEventElementMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BasicEventElementMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "BasicEventElementMetadata": raise DeserializationException( f"Expected modelType to be 'BasicEventElementMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_direction: Optional[our_types.Direction] = None the_state: Optional[our_types.StateOfEvent] = None the_message_topic: Optional[str] = None the_message_broker: Optional[our_types.Reference] = None the_last_update: Optional[str] = None the_min_interval: Optional[str] = None the_max_interval: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "direction": the_direction = direction_from_jsonable(jsonable_value) elif key == "state": the_state = state_of_event_from_jsonable(jsonable_value) elif key == "messageTopic": the_message_topic = _str_from_jsonable(jsonable_value) elif key == "messageBroker": the_message_broker = reference_from_jsonable(jsonable_value) elif key == "lastUpdate": the_last_update = _str_from_jsonable(jsonable_value) elif key == "minInterval": the_min_interval = _str_from_jsonable(jsonable_value) elif key == "maxInterval": the_max_interval = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_direction is None: raise DeserializationException("The required property 'direction' is missing") if the_state is None: raise DeserializationException("The required property 'state' is missing") return our_types.BasicEventElementMetadata( the_direction, the_state, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_message_topic, the_message_broker, the_last_update, the_min_interval, the_max_interval, )
[docs]def submodel_element_list_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.SubmodelElementListMetadata: """ Parse an instance of :py:class:`.types.SubmodelElementListMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelElementListMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "SubmodelElementListMetadata": raise DeserializationException( f"Expected modelType to be 'SubmodelElementListMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_order_relevant: Optional[bool] = None the_semantic_id_list_element: Optional[our_types.Reference] = None the_type_value_list_element: Optional[our_types.AASSubmodelElements] = None the_value_type_list_element: Optional[our_types.DataTypeDefXSD] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "orderRelevant": the_order_relevant = _bool_from_jsonable(jsonable_value) elif key == "semanticIdListElement": the_semantic_id_list_element = reference_from_jsonable(jsonable_value) elif key == "typeValueListElement": the_type_value_list_element = aas_submodel_elements_from_jsonable( jsonable_value ) elif key == "valueTypeListElement": the_value_type_list_element = data_type_def_xsd_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type_value_list_element is None: raise DeserializationException( "The required property 'typeValueListElement' is missing" ) return our_types.SubmodelElementListMetadata( the_type_value_list_element, the_extensions, the_category, the_id_short, the_display_name, the_description, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, the_order_relevant, the_semantic_id_list_element, the_value_type_list_element, )
[docs]def submodel_metadata_from_jsonable(jsonable: Jsonable) -> our_types.SubmodelMetadata: """ Parse an instance of :py:class:`.types.SubmodelMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.SubmodelMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "SubmodelMetadata": raise DeserializationException( f"Expected modelType to be 'SubmodelMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id: Optional[str] = None the_kind: Optional[our_types.ModellingKind] = None the_semantic_id: Optional[our_types.Reference] = None the_supplemental_semantic_ids: Optional[List[our_types.Reference]] = None the_qualifiers: Optional[List[our_types.Qualifier]] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "kind": the_kind = modelling_kind_from_jsonable(jsonable_value) elif key == "semanticId": the_semantic_id = reference_from_jsonable(jsonable_value) elif key == "supplementalSemanticIds": the_supplemental_semantic_ids = _list_of__reference_from_jsonable( jsonable_value ) elif key == "qualifiers": the_qualifiers = _list_of__qualifier_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.SubmodelMetadata( the_id, the_extensions, the_category, the_id_short, the_display_name, the_description, the_administration, the_kind, the_semantic_id, the_supplemental_semantic_ids, the_qualifiers, the_embedded_data_specifications, )
[docs]def asset_administration_shell_metadata_from_jsonable( jsonable: Jsonable, ) -> our_types.AssetAdministrationShellMetadata: """ Parse an instance of :py:class:`.types.AssetAdministrationShellMetadata` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AssetAdministrationShellMetadata` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) model_type = mapping.get("modelType", None) if model_type is not None and not isinstance(model_type, str): # NOTE (mristin): # A model type of a wrong type is reported at the property, as the type # errors of all the other properties are. exception = DeserializationException( f"Expected the property modelType to be a str, " f"but got: {type(model_type)}" ) exception.path._prepend(PropertySegment(mapping, "modelType")) raise exception if model_type != "AssetAdministrationShellMetadata": raise DeserializationException( f"Expected modelType to be 'AssetAdministrationShellMetadata', " f"but got: {model_type!r}" ) the_extensions: Optional[List[our_types.Extension]] = None the_category: Optional[str] = None the_id_short: Optional[str] = None the_display_name: Optional[List[our_types.LangStringNameType]] = None the_description: Optional[List[our_types.LangStringTextType]] = None the_administration: Optional[our_types.AdministrativeInformation] = None the_id: Optional[str] = None the_embedded_data_specifications: Optional[ List[our_types.EmbeddedDataSpecification] ] = None the_derived_from: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "modelType": # The model type has already been checked above. pass elif key == "extensions": the_extensions = _list_of__extension_from_jsonable(jsonable_value) elif key == "category": the_category = _str_from_jsonable(jsonable_value) elif key == "idShort": the_id_short = _str_from_jsonable(jsonable_value) elif key == "displayName": the_display_name = _list_of__lang_string_name_type_from_jsonable( jsonable_value ) elif key == "description": the_description = _list_of__lang_string_text_type_from_jsonable( jsonable_value ) elif key == "administration": the_administration = administrative_information_from_jsonable( jsonable_value ) elif key == "id": the_id = _str_from_jsonable(jsonable_value) elif key == "embeddedDataSpecifications": the_embedded_data_specifications = ( _list_of__embedded_data_specification_from_jsonable(jsonable_value) ) elif key == "derivedFrom": the_derived_from = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_id is None: raise DeserializationException("The required property 'id' is missing") return our_types.AssetAdministrationShellMetadata( the_id, the_extensions, the_category, the_id_short, the_display_name, the_description, the_administration, the_embedded_data_specifications, the_derived_from, )
[docs]def reference_element_value_from_jsonable( jsonable: Jsonable, ) -> our_types.ReferenceElementValue: """ Parse an instance of :py:class:`.types.ReferenceElementValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ReferenceElementValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_type: Optional[our_types.ReferenceTypes] = None the_keys: Optional[List[our_types.Key]] = None the_referred_semantic_id: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "type": the_type = reference_types_from_jsonable(jsonable_value) elif key == "keys": the_keys = _list_of__key_from_jsonable(jsonable_value) elif key == "referredSemanticId": the_referred_semantic_id = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_type is None: raise DeserializationException("The required property 'type' is missing") if the_keys is None: raise DeserializationException("The required property 'keys' is missing") return our_types.ReferenceElementValue(the_type, the_keys, the_referred_semantic_id)
[docs]def blob_value_from_jsonable(jsonable: Jsonable) -> our_types.BlobValue: """ Parse an instance of :py:class:`.types.BlobValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BlobValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_content_type: Optional[str] = None the_value: Optional[bytes] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "contentType": the_content_type = _str_from_jsonable(jsonable_value) elif key == "value": the_value = _bytes_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.BlobValue(the_content_type, the_value)
[docs]def file_value_from_jsonable(jsonable: Jsonable) -> our_types.FileValue: """ Parse an instance of :py:class:`.types.FileValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.FileValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_content_type: Optional[str] = None the_value: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "contentType": the_content_type = _str_from_jsonable(jsonable_value) elif key == "value": the_value = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.FileValue(the_content_type, the_value)
[docs]def range_value_from_jsonable(jsonable: Jsonable) -> our_types.RangeValue: """ Parse an instance of :py:class:`.types.RangeValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RangeValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_min: Optional[float] = None the_max: Optional[float] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "min": the_min = _float_from_jsonable(jsonable_value) elif key == "max": the_max = _float_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_min is None: raise DeserializationException("The required property 'min' is missing") if the_max is None: raise DeserializationException("The required property 'max' is missing") return our_types.RangeValue(the_min, the_max)
[docs]def relationship_element_value_from_jsonable( jsonable: Jsonable, ) -> our_types.RelationshipElementValue: """ Parse an instance of :py:class:`.types.RelationshipElementValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RelationshipElementValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_first: Optional[our_types.Reference] = None the_second: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "first": the_first = reference_from_jsonable(jsonable_value) elif key == "second": the_second = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.RelationshipElementValue(the_first, the_second)
[docs]def basic_event_element_value_from_jsonable( jsonable: Jsonable, ) -> our_types.BasicEventElementValue: """ Parse an instance of :py:class:`.types.BasicEventElementValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BasicEventElementValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_observed: Optional[our_types.Reference] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "observed": the_observed = reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_observed is None: raise DeserializationException("The required property 'observed' is missing") return our_types.BasicEventElementValue(the_observed)
[docs]def annotated_relationship_element_value_from_jsonable( jsonable: Jsonable, ) -> our_types.AnnotatedRelationshipElementValue: """ Parse an instance of :py:class:`.types.AnnotatedRelationshipElementValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AnnotatedRelationshipElementValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_first: Optional[our_types.Reference] = None the_second: Optional[our_types.Reference] = None the_annotations: Optional[our_types.JsonObject] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "first": the_first = reference_from_jsonable(jsonable_value) elif key == "second": the_second = reference_from_jsonable(jsonable_value) elif key == "annotations": the_annotations = _json_object_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.AnnotatedRelationshipElementValue( the_first, the_second, the_annotations )
[docs]def entity_value_from_jsonable(jsonable: Jsonable) -> our_types.EntityValue: """ Parse an instance of :py:class:`.types.EntityValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EntityValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_entity_type: Optional[our_types.EntityType] = None the_global_asset_id: Optional[str] = None the_specific_asset_ids: Optional[List[our_types.JsonObject]] = None the_statements: Optional[our_types.JsonObject] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "entityType": the_entity_type = entity_type_from_jsonable(jsonable_value) elif key == "globalAssetId": the_global_asset_id = _str_from_jsonable(jsonable_value) elif key == "specificAssetIds": the_specific_asset_ids = _list_of__json_object_from_jsonable( jsonable_value ) elif key == "statements": the_statements = _json_object_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") return our_types.EntityValue( the_entity_type, the_global_asset_id, the_specific_asset_ids, the_statements )
[docs]def get_asset_administration_shells_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAssetAdministrationShellsResult: """ Parse an instance of :py:class:`.types.GetAssetAdministrationShellsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAssetAdministrationShellsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.AssetAdministrationShell]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__asset_administration_shell_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAssetAdministrationShellsResult(the_paging_metadata, the_result)
[docs]def get_asset_administration_shells_metadata_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAssetAdministrationShellsMetadataResult: """ Parse an instance of :py:class:`.types.GetAssetAdministrationShellsMetadataResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAssetAdministrationShellsMetadataResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.AssetAdministrationShellMetadata]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = ( _list_of__asset_administration_shell_metadata_from_jsonable( jsonable_value ) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAssetAdministrationShellsMetadataResult( the_paging_metadata, the_result )
[docs]def get_all_asset_administration_shells_recent_changes_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAllAssetAdministrationShellsRecentChangesResult: """ Parse an instance of :py:class:`.types.GetAllAssetAdministrationShellsRecentChangesResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAllAssetAdministrationShellsRecentChangesResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.AssetAdministrationShellRecentChange]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = ( _list_of__asset_administration_shell_recent_change_from_jsonable( jsonable_value ) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAllAssetAdministrationShellsRecentChangesResult( the_paging_metadata, the_result )
[docs]def get_asset_administration_shell_descriptors_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAssetAdministrationShellDescriptorsResult: """ Parse an instance of :py:class:`.types.GetAssetAdministrationShellDescriptorsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAssetAdministrationShellDescriptorsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.AssetAdministrationShellDescriptor]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = ( _list_of__asset_administration_shell_descriptor_from_jsonable( jsonable_value ) ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAssetAdministrationShellDescriptorsResult( the_paging_metadata, the_result )
[docs]def get_concept_descriptions_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetConceptDescriptionsResult: """ Parse an instance of :py:class:`.types.GetConceptDescriptionsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetConceptDescriptionsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.ConceptDescription]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__concept_description_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetConceptDescriptionsResult(the_paging_metadata, the_result)
[docs]def get_all_concept_descriptions_recent_changes_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAllConceptDescriptionsRecentChangesResult: """ Parse an instance of :py:class:`.types.GetAllConceptDescriptionsRecentChangesResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAllConceptDescriptionsRecentChangesResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.ConceptDescriptionRecentChange]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__concept_description_recent_change_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAllConceptDescriptionsRecentChangesResult( the_paging_metadata, the_result )
[docs]def get_package_descriptions_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetPackageDescriptionsResult: """ Parse an instance of :py:class:`.types.GetPackageDescriptionsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetPackageDescriptionsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.PackageDescription]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__package_description_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetPackageDescriptionsResult(the_paging_metadata, the_result)
[docs]def get_path_items_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetPathItemsResult: """ Parse an instance of :py:class:`.types.GetPathItemsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetPathItemsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[str]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetPathItemsResult(the_paging_metadata, the_result)
[docs]def get_references_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetReferencesResult: """ Parse an instance of :py:class:`.types.GetReferencesResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetReferencesResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.Reference]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__reference_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetReferencesResult(the_paging_metadata, the_result)
[docs]def get_submodel_descriptors_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelDescriptorsResult: """ Parse an instance of :py:class:`.types.GetSubmodelDescriptorsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelDescriptorsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.SubmodelDescriptor]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_descriptor_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelDescriptorsResult(the_paging_metadata, the_result)
[docs]def get_submodel_elements_metadata_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelElementsMetadataResult: """ Parse an instance of :py:class:`.types.GetSubmodelElementsMetadataResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelElementsMetadataResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.SubmodelElementMetadata]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_element_metadata_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelElementsMetadataResult(the_paging_metadata, the_result)
[docs]def get_submodel_elements_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelElementsResult: """ Parse an instance of :py:class:`.types.GetSubmodelElementsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelElementsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.SubmodelElement]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_element_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelElementsResult(the_paging_metadata, the_result)
[docs]def get_submodel_elements_value_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelElementsValueResult: """ Parse an instance of :py:class:`.types.GetSubmodelElementsValueResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelElementsValueResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.JsonObject]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__json_object_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelElementsValueResult(the_paging_metadata, the_result)
[docs]def get_all_submodels_recent_changes_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetAllSubmodelsRecentChangesResult: """ Parse an instance of :py:class:`.types.GetAllSubmodelsRecentChangesResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetAllSubmodelsRecentChangesResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.SubmodelRecentChange]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_recent_change_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetAllSubmodelsRecentChangesResult(the_paging_metadata, the_result)
[docs]def get_submodels_metadata_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelsMetadataResult: """ Parse an instance of :py:class:`.types.GetSubmodelsMetadataResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelsMetadataResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.SubmodelMetadata]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_metadata_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelsMetadataResult(the_paging_metadata, the_result)
[docs]def get_submodels_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelsResult: """ Parse an instance of :py:class:`.types.GetSubmodelsResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelsResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.Submodel]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__submodel_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelsResult(the_paging_metadata, the_result)
[docs]def get_submodels_value_result_from_jsonable( jsonable: Jsonable, ) -> our_types.GetSubmodelsValueResult: """ Parse an instance of :py:class:`.types.GetSubmodelsValueResult` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GetSubmodelsValueResult` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_paging_metadata: Optional[our_types.PagingMetadata] = None the_result: Optional[List[our_types.JsonObject]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "paging_metadata": the_paging_metadata = paging_metadata_from_jsonable(jsonable_value) elif key == "result": the_result = _list_of__json_object_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_paging_metadata is None: raise DeserializationException( "The required property 'paging_metadata' is missing" ) return our_types.GetSubmodelsValueResult(the_paging_metadata, the_result)
[docs]def global_attribute_kind_from_jsonable( jsonable: Jsonable, ) -> our_types.GlobalAttributeKind: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.GlobalAttributeKind`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.global_attribute_kind_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of GlobalAttributeKind: {jsonable}" ) return literal
[docs]def date_time_global_attribute_kind_from_jsonable( jsonable: Jsonable, ) -> our_types.DateTimeGlobalAttributeKind: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.DateTimeGlobalAttributeKind`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.date_time_global_attribute_kind_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of DateTimeGlobalAttributeKind: {jsonable}" ) return literal
[docs]def claim_attribute_from_jsonable(jsonable: Jsonable) -> our_types.ClaimAttribute: """ Parse an instance of :py:class:`.types.ClaimAttribute` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ClaimAttribute` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_claim: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "CLAIM": the_claim = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_claim is None: raise DeserializationException("The required property 'CLAIM' is missing") return our_types.ClaimAttribute(the_claim)
[docs]def global_attribute_from_jsonable(jsonable: Jsonable) -> our_types.GlobalAttribute: """ Parse an instance of :py:class:`.types.GlobalAttribute` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GlobalAttribute` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_kind: Optional[our_types.GlobalAttributeKind] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "GLOBAL": the_kind = global_attribute_kind_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_kind is None: raise DeserializationException("The required property 'GLOBAL' is missing") return our_types.GlobalAttribute(the_kind)
[docs]def reference_attribute_from_jsonable( jsonable: Jsonable, ) -> our_types.ReferenceAttribute: """ Parse an instance of :py:class:`.types.ReferenceAttribute` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ReferenceAttribute` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_reference: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "REFERENCE": the_reference = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_reference is None: raise DeserializationException("The required property 'REFERENCE' is missing") return our_types.ReferenceAttribute(the_reference)
[docs]def date_time_attribute_item_from_jsonable( jsonable: Jsonable, ) -> our_types.DateTimeAttributeItem: """ Parse an instance of :py:class:`.types.DateTimeAttributeItem` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DateTimeAttributeItem` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_kind: Optional[our_types.DateTimeGlobalAttributeKind] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "GLOBAL": the_kind = date_time_global_attribute_kind_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_kind is None: raise DeserializationException("The required property 'GLOBAL' is missing") return our_types.DateTimeAttributeItem(the_kind)
[docs]def field_operand_from_jsonable(jsonable: Jsonable) -> our_types.FieldOperand: """ Parse an instance of :py:class:`.types.FieldOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.FieldOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_field: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$field": the_field = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_field is None: raise DeserializationException("The required property '$field' is missing") return our_types.FieldOperand(the_field)
[docs]def string_literal_from_jsonable(jsonable: Jsonable) -> our_types.StringLiteral: """ Parse an instance of :py:class:`.types.StringLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.StringLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_str_val: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$strVal": the_str_val = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_str_val is None: raise DeserializationException("The required property '$strVal' is missing") return our_types.StringLiteral(the_str_val)
[docs]def attribute_operand_from_jsonable(jsonable: Jsonable) -> our_types.AttributeOperand: """ Parse an instance of :py:class:`.types.AttributeOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AttributeOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_attribute: Optional[our_types.AttributeItem] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$attribute": the_attribute = attribute_item_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_attribute is None: raise DeserializationException("The required property '$attribute' is missing") return our_types.AttributeOperand(the_attribute)
[docs]def number_literal_from_jsonable(jsonable: Jsonable) -> our_types.NumberLiteral: """ Parse an instance of :py:class:`.types.NumberLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.NumberLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_num_val: Optional[float] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$numVal": the_num_val = _float_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_num_val is None: raise DeserializationException("The required property '$numVal' is missing") return our_types.NumberLiteral(the_num_val)
[docs]def hex_literal_from_jsonable(jsonable: Jsonable) -> our_types.HexLiteral: """ Parse an instance of :py:class:`.types.HexLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.HexLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_hex_val: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$hexVal": the_hex_val = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_hex_val is None: raise DeserializationException("The required property '$hexVal' is missing") return our_types.HexLiteral(the_hex_val)
[docs]def date_time_literal_from_jsonable(jsonable: Jsonable) -> our_types.DateTimeLiteral: """ Parse an instance of :py:class:`.types.DateTimeLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DateTimeLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_date_time_val: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$dateTimeVal": the_date_time_val = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_date_time_val is None: raise DeserializationException( "The required property '$dateTimeVal' is missing" ) return our_types.DateTimeLiteral(the_date_time_val)
[docs]def time_literal_from_jsonable(jsonable: Jsonable) -> our_types.TimeLiteral: """ Parse an instance of :py:class:`.types.TimeLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.TimeLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_time_val: Optional[str] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$timeVal": the_time_val = _str_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_time_val is None: raise DeserializationException("The required property '$timeVal' is missing") return our_types.TimeLiteral(the_time_val)
[docs]def boolean_literal_from_jsonable(jsonable: Jsonable) -> our_types.BooleanLiteral: """ Parse an instance of :py:class:`.types.BooleanLiteral` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BooleanLiteral` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_boolean: Optional[bool] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$boolean": the_boolean = _bool_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_boolean is None: raise DeserializationException("The required property '$boolean' is missing") return our_types.BooleanLiteral(the_boolean)
[docs]def string_cast_from_jsonable(jsonable: Jsonable) -> our_types.StringCast: """ Parse an instance of :py:class:`.types.StringCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.StringCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_str_cast: Optional[our_types.Value] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$strCast": the_str_cast = value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_str_cast is None: raise DeserializationException("The required property '$strCast' is missing") return our_types.StringCast(the_str_cast)
[docs]def number_cast_from_jsonable(jsonable: Jsonable) -> our_types.NumberCast: """ Parse an instance of :py:class:`.types.NumberCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.NumberCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_num_cast: Optional[our_types.Value] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$numCast": the_num_cast = value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_num_cast is None: raise DeserializationException("The required property '$numCast' is missing") return our_types.NumberCast(the_num_cast)
[docs]def hex_cast_from_jsonable(jsonable: Jsonable) -> our_types.HexCast: """ Parse an instance of :py:class:`.types.HexCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.HexCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_hex_cast: Optional[our_types.Value] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$hexCast": the_hex_cast = value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_hex_cast is None: raise DeserializationException("The required property '$hexCast' is missing") return our_types.HexCast(the_hex_cast)
[docs]def boolean_cast_from_jsonable(jsonable: Jsonable) -> our_types.BooleanCast: """ Parse an instance of :py:class:`.types.BooleanCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.BooleanCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_bool_cast: Optional[our_types.Value] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$boolCast": the_bool_cast = value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_bool_cast is None: raise DeserializationException("The required property '$boolCast' is missing") return our_types.BooleanCast(the_bool_cast)
[docs]def date_time_cast_from_jsonable(jsonable: Jsonable) -> our_types.DateTimeCast: """ Parse an instance of :py:class:`.types.DateTimeCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DateTimeCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_date_time_cast: Optional[our_types.StringValue] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$dateTimeCast": the_date_time_cast = string_value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_date_time_cast is None: raise DeserializationException( "The required property '$dateTimeCast' is missing" ) return our_types.DateTimeCast(the_date_time_cast)
[docs]def time_cast_from_jsonable(jsonable: Jsonable) -> our_types.TimeCast: """ Parse an instance of :py:class:`.types.TimeCast` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.TimeCast` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_time_cast: Optional[our_types.TimeCastOperand] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$timeCast": the_time_cast = time_cast_operand_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_time_cast is None: raise DeserializationException("The required property '$timeCast' is missing") return our_types.TimeCast(the_time_cast)
[docs]def day_of_week_from_jsonable(jsonable: Jsonable) -> our_types.DayOfWeek: """ Parse an instance of :py:class:`.types.DayOfWeek` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DayOfWeek` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_day_of_week: Optional[our_types.DateTimeOperand] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$dayOfWeek": the_day_of_week = date_time_operand_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_day_of_week is None: raise DeserializationException("The required property '$dayOfWeek' is missing") return our_types.DayOfWeek(the_day_of_week)
[docs]def day_of_month_from_jsonable(jsonable: Jsonable) -> our_types.DayOfMonth: """ Parse an instance of :py:class:`.types.DayOfMonth` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DayOfMonth` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_day_of_month: Optional[our_types.DateTimeOperand] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$dayOfMonth": the_day_of_month = date_time_operand_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_day_of_month is None: raise DeserializationException("The required property '$dayOfMonth' is missing") return our_types.DayOfMonth(the_day_of_month)
[docs]def month_from_jsonable(jsonable: Jsonable) -> our_types.Month: """ Parse an instance of :py:class:`.types.Month` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Month` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_month: Optional[our_types.DateTimeOperand] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$month": the_month = date_time_operand_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_month is None: raise DeserializationException("The required property '$month' is missing") return our_types.Month(the_month)
[docs]def year_from_jsonable(jsonable: Jsonable) -> our_types.Year: """ Parse an instance of :py:class:`.types.Year` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Year` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_year: Optional[our_types.DateTimeOperand] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$year": the_year = date_time_operand_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_year is None: raise DeserializationException("The required property '$year' is missing") return our_types.Year(the_year)
[docs]def date_time_attribute_operand_from_jsonable( jsonable: Jsonable, ) -> our_types.DateTimeAttributeOperand: """ Parse an instance of :py:class:`.types.DateTimeAttributeOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.DateTimeAttributeOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_attribute: Optional[our_types.DateTimeAttributeItem] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$attribute": the_attribute = date_time_attribute_item_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_attribute is None: raise DeserializationException("The required property '$attribute' is missing") return our_types.DateTimeAttributeOperand(the_attribute)
[docs]def equal_comparison_from_jsonable(jsonable: Jsonable) -> our_types.EqualComparison: """ Parse an instance of :py:class:`.types.EqualComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EqualComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_eq: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$eq": the_eq = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_eq is None: raise DeserializationException("The required property '$eq' is missing") return our_types.EqualComparison(the_eq)
[docs]def not_equal_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.NotEqualComparison: """ Parse an instance of :py:class:`.types.NotEqualComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.NotEqualComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_ne: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$ne": the_ne = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_ne is None: raise DeserializationException("The required property '$ne' is missing") return our_types.NotEqualComparison(the_ne)
[docs]def greater_than_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.GreaterThanComparison: """ Parse an instance of :py:class:`.types.GreaterThanComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GreaterThanComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_gt: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$gt": the_gt = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_gt is None: raise DeserializationException("The required property '$gt' is missing") return our_types.GreaterThanComparison(the_gt)
[docs]def greater_than_or_equal_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.GreaterThanOrEqualComparison: """ Parse an instance of :py:class:`.types.GreaterThanOrEqualComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.GreaterThanOrEqualComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_ge: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$ge": the_ge = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_ge is None: raise DeserializationException("The required property '$ge' is missing") return our_types.GreaterThanOrEqualComparison(the_ge)
[docs]def less_than_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.LessThanComparison: """ Parse an instance of :py:class:`.types.LessThanComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LessThanComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_lt: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$lt": the_lt = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_lt is None: raise DeserializationException("The required property '$lt' is missing") return our_types.LessThanComparison(the_lt)
[docs]def less_than_or_equal_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.LessThanOrEqualComparison: """ Parse an instance of :py:class:`.types.LessThanOrEqualComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.LessThanOrEqualComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_le: Optional[Tuple[our_types.Value, our_types.Value]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$le": the_le = _tuple2_of__value__value_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_le is None: raise DeserializationException("The required property '$le' is missing") return our_types.LessThanOrEqualComparison(the_le)
[docs]def contains_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.ContainsComparison: """ Parse an instance of :py:class:`.types.ContainsComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.ContainsComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_contains: Optional[Tuple[our_types.StringValue, our_types.StringValue]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$contains": the_contains = _tuple2_of__string_value__string_value_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_contains is None: raise DeserializationException("The required property '$contains' is missing") return our_types.ContainsComparison(the_contains)
[docs]def starts_with_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.StartsWithComparison: """ Parse an instance of :py:class:`.types.StartsWithComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.StartsWithComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_starts_with: Optional[Tuple[our_types.StringValue, our_types.StringValue]] = ( None ) unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$starts-with": the_starts_with = _tuple2_of__string_value__string_value_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_starts_with is None: raise DeserializationException( "The required property '$starts-with' is missing" ) return our_types.StartsWithComparison(the_starts_with)
[docs]def ends_with_comparison_from_jsonable( jsonable: Jsonable, ) -> our_types.EndsWithComparison: """ Parse an instance of :py:class:`.types.EndsWithComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.EndsWithComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_ends_with: Optional[Tuple[our_types.StringValue, our_types.StringValue]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$ends-with": the_ends_with = _tuple2_of__string_value__string_value_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_ends_with is None: raise DeserializationException("The required property '$ends-with' is missing") return our_types.EndsWithComparison(the_ends_with)
[docs]def regex_comparison_from_jsonable(jsonable: Jsonable) -> our_types.RegexComparison: """ Parse an instance of :py:class:`.types.RegexComparison` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.RegexComparison` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_regex: Optional[Tuple[our_types.StringValue, our_types.StringValue]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$regex": the_regex = _tuple2_of__string_value__string_value_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_regex is None: raise DeserializationException("The required property '$regex' is missing") return our_types.RegexComparison(the_regex)
[docs]def match_clause_from_jsonable(jsonable: Jsonable) -> our_types.MatchClause: """ Parse an instance of :py:class:`.types.MatchClause` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.MatchClause` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_match_operands: Optional[List[our_types.MatchExpression]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$match": the_match_operands = _list_of__match_expression_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_match_operands is None: raise DeserializationException("The required property '$match' is missing") return our_types.MatchClause(the_match_operands)
[docs]def and_expression_from_jsonable(jsonable: Jsonable) -> our_types.AndExpression: """ Parse an instance of :py:class:`.types.AndExpression` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.AndExpression` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_and_operands: Optional[List[our_types.LogicalExpression]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$and": the_and_operands = _list_of__logical_expression_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_and_operands is None: raise DeserializationException("The required property '$and' is missing") return our_types.AndExpression(the_and_operands)
[docs]def or_expression_from_jsonable(jsonable: Jsonable) -> our_types.OrExpression: """ Parse an instance of :py:class:`.types.OrExpression` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.OrExpression` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_or_operands: Optional[List[our_types.LogicalExpression]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$or": the_or_operands = _list_of__logical_expression_from_jsonable( jsonable_value ) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_or_operands is None: raise DeserializationException("The required property '$or' is missing") return our_types.OrExpression(the_or_operands)
[docs]def not_expression_from_jsonable(jsonable: Jsonable) -> our_types.NotExpression: """ Parse an instance of :py:class:`.types.NotExpression` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.NotExpression` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_not_operand: Optional[our_types.LogicalExpression] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$not": the_not_operand = logical_expression_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_not_operand is None: raise DeserializationException("The required property '$not' is missing") return our_types.NotExpression(the_not_operand)
[docs]def query_select_from_jsonable(jsonable: Jsonable) -> our_types.QuerySelect: """ Convert the JSON-able structure :paramref:`jsonable` to a literal of :py:class:`.types.QuerySelect`. :param jsonable: JSON-able structure to be parsed :return: parsed literal :raise: :py:class:`.DeserializationException` if unexpected :paramref:`jsonable` """ if not isinstance(jsonable, str): raise DeserializationException("Expected a str, but got: {type(jsonable)}") literal = our_stringification.query_select_from_str(jsonable) if literal is None: raise DeserializationException( f"Not a valid string representation of " f"a literal of QuerySelect: {jsonable}" ) return literal
[docs]def query_filter_from_jsonable(jsonable: Jsonable) -> our_types.QueryFilter: """ Parse an instance of :py:class:`.types.QueryFilter` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.QueryFilter` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_fragment: Optional[str] = None the_condition: Optional[our_types.LogicalExpression] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$fragment": the_fragment = _str_from_jsonable(jsonable_value) elif key == "$condition": the_condition = logical_expression_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_fragment is None: raise DeserializationException("The required property '$fragment' is missing") if the_condition is None: raise DeserializationException("The required property '$condition' is missing") return our_types.QueryFilter(the_fragment, the_condition)
[docs]def query_from_jsonable(jsonable: Jsonable) -> our_types.Query: """ Parse an instance of :py:class:`.types.Query` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Parsed instance of :py:class:`.types.Query` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) the_select: Optional[our_types.QuerySelect] = None the_condition: Optional[our_types.LogicalExpression] = None the_filters: Optional[List[our_types.QueryFilter]] = None unexpected_key: Optional[str] = None try: for key, jsonable_value in mapping.items(): if key == "$select": the_select = query_select_from_jsonable(jsonable_value) elif key == "$condition": the_condition = logical_expression_from_jsonable(jsonable_value) elif key == "$filters": the_filters = _list_of__query_filter_from_jsonable(jsonable_value) else: unexpected_key = key break except DeserializationException as exception: exception.path._prepend(PropertySegment(mapping, key)) raise if unexpected_key is not None: raise DeserializationException(f"Unexpected property: {unexpected_key}") if the_condition is None: raise DeserializationException("The required property '$condition' is missing") return our_types.Query(the_condition, the_select, the_filters)
[docs]def attribute_item_from_jsonable(jsonable: Jsonable) -> our_types.AttributeItem: """ Parse an instance of :py:class:`.types.AttributeItem` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.AttributeItem` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "CLAIM" in mapping: return claim_attribute_from_jsonable(mapping) if "GLOBAL" in mapping: return global_attribute_from_jsonable(mapping) if "REFERENCE" in mapping: return reference_attribute_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of AttributeItem " "for the given JSON object" )
[docs]def string_value_from_jsonable(jsonable: Jsonable) -> our_types.StringValue: """ Parse an instance of :py:class:`.types.StringValue` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.StringValue` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$field" in mapping: return field_operand_from_jsonable(mapping) if "$strVal" in mapping: return string_literal_from_jsonable(mapping) if "$strCast" in mapping: return string_cast_from_jsonable(mapping) if "$attribute" in mapping: return attribute_operand_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of StringValue " "for the given JSON object" )
[docs]def date_time_operand_from_jsonable(jsonable: Jsonable) -> our_types.DateTimeOperand: """ Parse an instance of :py:class:`.types.DateTimeOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.DateTimeOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$dateTimeVal" in mapping: return date_time_literal_from_jsonable(mapping) if "$dateTimeCast" in mapping: return date_time_cast_from_jsonable(mapping) if "$attribute" in mapping: return date_time_attribute_operand_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of DateTimeOperand " "for the given JSON object" )
[docs]def time_cast_operand_from_jsonable(jsonable: Jsonable) -> our_types.TimeCastOperand: """ Parse an instance of :py:class:`.types.TimeCastOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.TimeCastOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$field" in mapping: return field_operand_from_jsonable(mapping) if "$strVal" in mapping: return string_literal_from_jsonable(mapping) if "$strCast" in mapping: return string_cast_from_jsonable(mapping) if "$attribute" in mapping: return attribute_operand_from_jsonable(mapping) if "$dateTimeVal" in mapping: return date_time_literal_from_jsonable(mapping) if "$dateTimeCast" in mapping: return date_time_cast_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of TimeCastOperand " "for the given JSON object" )
[docs]def numerical_operand_from_jsonable(jsonable: Jsonable) -> our_types.NumericalOperand: """ Parse an instance of :py:class:`.types.NumericalOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.NumericalOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$numVal" in mapping: return number_literal_from_jsonable(mapping) if "$numCast" in mapping: return number_cast_from_jsonable(mapping) if "$dayOfWeek" in mapping: return day_of_week_from_jsonable(mapping) if "$dayOfMonth" in mapping: return day_of_month_from_jsonable(mapping) if "$month" in mapping: return month_from_jsonable(mapping) if "$year" in mapping: return year_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of NumericalOperand " "for the given JSON object" )
[docs]def hex_operand_from_jsonable(jsonable: Jsonable) -> our_types.HexOperand: """ Parse an instance of :py:class:`.types.HexOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.HexOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$hexVal" in mapping: return hex_literal_from_jsonable(mapping) if "$hexCast" in mapping: return hex_cast_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of HexOperand " "for the given JSON object" )
[docs]def bool_operand_from_jsonable(jsonable: Jsonable) -> our_types.BoolOperand: """ Parse an instance of :py:class:`.types.BoolOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.BoolOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$boolean" in mapping: return boolean_literal_from_jsonable(mapping) if "$boolCast" in mapping: return boolean_cast_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of BoolOperand " "for the given JSON object" )
[docs]def time_operand_from_jsonable(jsonable: Jsonable) -> our_types.TimeOperand: """ Parse an instance of :py:class:`.types.TimeOperand` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.TimeOperand` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$timeVal" in mapping: return time_literal_from_jsonable(mapping) if "$timeCast" in mapping: return time_cast_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of TimeOperand " "for the given JSON object" )
[docs]def value_from_jsonable(jsonable: Jsonable) -> our_types.Value: """ Parse an instance of :py:class:`.types.Value` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.Value` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$field" in mapping: return field_operand_from_jsonable(mapping) if "$strVal" in mapping: return string_literal_from_jsonable(mapping) if "$strCast" in mapping: return string_cast_from_jsonable(mapping) if "$attribute" in mapping: return attribute_operand_from_jsonable(mapping) if "$numVal" in mapping: return number_literal_from_jsonable(mapping) if "$numCast" in mapping: return number_cast_from_jsonable(mapping) if "$dayOfWeek" in mapping: return day_of_week_from_jsonable(mapping) if "$dayOfMonth" in mapping: return day_of_month_from_jsonable(mapping) if "$month" in mapping: return month_from_jsonable(mapping) if "$year" in mapping: return year_from_jsonable(mapping) if "$hexVal" in mapping: return hex_literal_from_jsonable(mapping) if "$hexCast" in mapping: return hex_cast_from_jsonable(mapping) if "$boolean" in mapping: return boolean_literal_from_jsonable(mapping) if "$boolCast" in mapping: return boolean_cast_from_jsonable(mapping) if "$dateTimeVal" in mapping: return date_time_literal_from_jsonable(mapping) if "$dateTimeCast" in mapping: return date_time_cast_from_jsonable(mapping) if "$timeVal" in mapping: return time_literal_from_jsonable(mapping) if "$timeCast" in mapping: return time_cast_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of Value " "for the given JSON object" )
[docs]def match_expression_from_jsonable(jsonable: Jsonable) -> our_types.MatchExpression: """ Parse an instance of :py:class:`.types.MatchExpression` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.MatchExpression` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$match" in mapping: return match_clause_from_jsonable(mapping) if "$eq" in mapping: return equal_comparison_from_jsonable(mapping) if "$ne" in mapping: return not_equal_comparison_from_jsonable(mapping) if "$gt" in mapping: return greater_than_comparison_from_jsonable(mapping) if "$ge" in mapping: return greater_than_or_equal_comparison_from_jsonable(mapping) if "$lt" in mapping: return less_than_comparison_from_jsonable(mapping) if "$le" in mapping: return less_than_or_equal_comparison_from_jsonable(mapping) if "$contains" in mapping: return contains_comparison_from_jsonable(mapping) if "$starts-with" in mapping: return starts_with_comparison_from_jsonable(mapping) if "$ends-with" in mapping: return ends_with_comparison_from_jsonable(mapping) if "$regex" in mapping: return regex_comparison_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of MatchExpression " "for the given JSON object" )
[docs]def logical_expression_from_jsonable(jsonable: Jsonable) -> our_types.LogicalExpression: """ Parse an instance of :py:class:`.types.LogicalExpression` from the JSON-able structure :paramref:`jsonable`. :param jsonable: structure to be parsed :return: Concrete instance corresponding to :py:class:`.types.LogicalExpression` :raise: :py:class:`DeserializationException` if unexpected :paramref:`jsonable` """ mapping = _as_mapping(jsonable) if "$and" in mapping: return and_expression_from_jsonable(mapping) if "$or" in mapping: return or_expression_from_jsonable(mapping) if "$not" in mapping: return not_expression_from_jsonable(mapping) if "$boolean" in mapping: return boolean_literal_from_jsonable(mapping) if "$match" in mapping: return match_clause_from_jsonable(mapping) if "$eq" in mapping: return equal_comparison_from_jsonable(mapping) if "$ne" in mapping: return not_equal_comparison_from_jsonable(mapping) if "$gt" in mapping: return greater_than_comparison_from_jsonable(mapping) if "$ge" in mapping: return greater_than_or_equal_comparison_from_jsonable(mapping) if "$lt" in mapping: return less_than_comparison_from_jsonable(mapping) if "$le" in mapping: return less_than_or_equal_comparison_from_jsonable(mapping) if "$contains" in mapping: return contains_comparison_from_jsonable(mapping) if "$starts-with" in mapping: return starts_with_comparison_from_jsonable(mapping) if "$ends-with" in mapping: return ends_with_comparison_from_jsonable(mapping) if "$regex" in mapping: return regex_comparison_from_jsonable(mapping) raise DeserializationException( "Could not determine the concrete type of LogicalExpression " "for the given JSON object" )
#: De-serialize a concrete instance of #: :py:class:`.types.HasSemantics`, by its model type _HAS_SEMANTICS_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.HasSemantics]] = { "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "Blob": blob_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "Capability": capability_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "Entity": entity_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "Extension": extension_from_jsonable, "File": file_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "Operation": operation_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "Property": property_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "Qualifier": qualifier_from_jsonable, "Range": range_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "SpecificAssetId": specific_asset_id_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.HasExtensions`, by its model type _HAS_EXTENSIONS_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.HasExtensions] ] = { "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "AssetAdministrationShell": asset_administration_shell_from_jsonable, "AssetAdministrationShellMetadata": asset_administration_shell_metadata_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "Blob": blob_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "Capability": capability_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "ConceptDescription": concept_description_from_jsonable, "Entity": entity_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "File": file_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "Operation": operation_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "Property": property_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "Range": range_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.Referable`, by its model type _REFERABLE_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.Referable]] = { "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "AssetAdministrationShell": asset_administration_shell_from_jsonable, "AssetAdministrationShellMetadata": asset_administration_shell_metadata_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "Blob": blob_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "Capability": capability_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "ConceptDescription": concept_description_from_jsonable, "Entity": entity_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "File": file_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "Operation": operation_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "Property": property_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "Range": range_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.Identifiable`, by its model type _IDENTIFIABLE_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.Identifiable]] = { "AssetAdministrationShell": asset_administration_shell_from_jsonable, "AssetAdministrationShellMetadata": asset_administration_shell_metadata_from_jsonable, "ConceptDescription": concept_description_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.HasKind`, by its model type _HAS_KIND_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.HasKind]] = { "Submodel": submodel_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.HasDataSpecification`, by its model type _HAS_DATA_SPECIFICATION_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.HasDataSpecification] ] = { "AdministrativeInformation": administrative_information_from_jsonable, "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "AssetAdministrationShell": asset_administration_shell_from_jsonable, "AssetAdministrationShellMetadata": asset_administration_shell_metadata_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "Blob": blob_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "Capability": capability_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "ConceptDescription": concept_description_from_jsonable, "Entity": entity_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "File": file_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "Operation": operation_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "Property": property_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "Range": range_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.Qualifiable`, by its model type _QUALIFIABLE_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.Qualifiable]] = { "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "Blob": blob_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "Capability": capability_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "Entity": entity_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "File": file_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "Operation": operation_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "Property": property_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "Range": range_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "Submodel": submodel_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, "SubmodelMetadata": submodel_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.SubmodelElement`, by its model type _SUBMODEL_ELEMENT_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.SubmodelElement] ] = { "RelationshipElement": relationship_element_from_jsonable, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, "BasicEventElement": basic_event_element_from_jsonable, "Blob": blob_from_jsonable, "Capability": capability_from_jsonable, "Entity": entity_from_jsonable, "File": file_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "Operation": operation_from_jsonable, "Property": property_from_jsonable, "Range": range_from_jsonable, "ReferenceElement": reference_element_from_jsonable, "SubmodelElementCollection": submodel_element_collection_from_jsonable, "SubmodelElementList": submodel_element_list_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.RelationshipElement`, by its model type _RELATIONSHIP_ELEMENT_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.RelationshipElement] ] = { "RelationshipElement": _relationship_element_from_jsonable_without_dispatch, "AnnotatedRelationshipElement": annotated_relationship_element_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.DataElement`, by its model type _DATA_ELEMENT_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.DataElement]] = { "Blob": blob_from_jsonable, "File": file_from_jsonable, "MultiLanguageProperty": multi_language_property_from_jsonable, "Property": property_from_jsonable, "Range": range_from_jsonable, "ReferenceElement": reference_element_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.EventElement`, by its model type _EVENT_ELEMENT_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.EventElement]] = { "BasicEventElement": basic_event_element_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.AbstractLangString`, by its model type _ABSTRACT_LANG_STRING_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.AbstractLangString] ] = { "DefinitionTypeUom": definition_type_uom_from_jsonable, "LangStringDefinitionTypeIec61360": lang_string_definition_type_iec_61360_from_jsonable, "LangStringNameType": lang_string_name_type_from_jsonable, "LangStringPreferredNameTypeIec61360": lang_string_preferred_name_type_iec_61360_from_jsonable, "LangStringShortNameTypeIec61360": lang_string_short_name_type_iec_61360_from_jsonable, "LangStringTextType": lang_string_text_type_from_jsonable, "LangStringUom": lang_string_uom_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.DataSpecificationContent`, by its model type _DATA_SPECIFICATION_CONTENT_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.DataSpecificationContent] ] = { "DataSpecificationIec61360": data_specification_iec_61360_from_jsonable, "DataSpecificationUom": data_specification_uom_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.Descriptor`, by its model type _DESCRIPTOR_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.Descriptor]] = { "AssetAdministrationShellDescriptor": asset_administration_shell_descriptor_from_jsonable, "SubmodelDescriptor": submodel_descriptor_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.RecentChange`, by its model type _RECENT_CHANGE_FROM_JSONABLE_DISPATCH: Mapping[str, _Parser[our_types.RecentChange]] = { "AssetAdministrationShellRecentChange": asset_administration_shell_recent_change_from_jsonable, "ConceptDescriptionRecentChange": concept_description_recent_change_from_jsonable, "SubmodelRecentChange": submodel_recent_change_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.SubmodelElementAttributes`, by its model type _SUBMODEL_ELEMENT_ATTRIBUTES_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.SubmodelElementAttributes] ] = { "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, } #: De-serialize a concrete instance of #: :py:class:`.types.SubmodelElementMetadata`, by its model type _SUBMODEL_ELEMENT_METADATA_FROM_JSONABLE_DISPATCH: Mapping[ str, _Parser[our_types.SubmodelElementMetadata] ] = { "AnnotatedRelationshipElementMetadata": annotated_relationship_element_metadata_from_jsonable, "BasicEventElementMetadata": basic_event_element_metadata_from_jsonable, "BlobMetadata": blob_metadata_from_jsonable, "CapabilityMetadata": capability_metadata_from_jsonable, "EntityMetadata": entity_metadata_from_jsonable, "FileMetadata": file_metadata_from_jsonable, "MultiLanguagePropertyMetadata": multi_language_property_metadata_from_jsonable, "OperationMetadata": operation_metadata_from_jsonable, "PropertyMetadata": property_metadata_from_jsonable, "RangeMetadata": range_metadata_from_jsonable, "ReferenceElementMetadata": reference_element_metadata_from_jsonable, "RelationshipElementMetadata": relationship_element_metadata_from_jsonable, "SubmodelElementCollectionMetadata": submodel_element_collection_metadata_from_jsonable, "SubmodelElementListMetadata": submodel_element_list_metadata_from_jsonable, } # endregion # region Serialization
[docs]class SerializationException(Exception): """Signal that the JSON serialization could not be performed.""" #: Human-readable explanation of the exception's cause cause: Final[str]
[docs] def __init__(self, cause: str) -> None: """Initialize with the given :paramref:`cause` and an empty path.""" self.cause = cause self._segments: List[str] = []
@property def path(self) -> str: """ Render the path to the erroneous value as a Python access expression. The path points into the instance which you handed over for the serialization, and *not* into a JSON document -- at the point of the failure, there is no document yet. For example, ``.submodels[0].value`` tells you that the serialization broke on ``that.submodels[0].value``. """ return "".join(self._segments) def _prepend_property(self, name: str) -> None: """Insert the access to the property :paramref:`name` before the path.""" self._segments.insert(0, f".{name}") def _prepend_index(self, index: int) -> None: """Insert the access to the item at :paramref:`index` before the path.""" self._segments.insert(0, f"[{index}]") def _prepend_key(self, key: str) -> None: """ Insert the access to the member :paramref:`key` before the path. Unlike a property of one of our classes, a member of an open JSON-able object is known only at run time and can be any string at all, so it is always rendered as a subscript. """ self._segments.insert(0, f"[{json.dumps(key, ensure_ascii=False)}]")
[docs] def __str__(self) -> str: if len(self._segments) == 0: return self.cause return f"{self.path}: {self.cause}"
def _float_to_jsonable(that: float) -> float: """ Serialize :paramref:`that` floating-point number to a JSON-able value. JSON knows neither an infinity nor a not-a-number, so we refuse to serialize them instead of leaving it to :py:mod:`json` to write them out as ``NaN`` and ``Infinity``, which no conformant parser reads back. :param that: floating-point number to be serialized :return: :paramref:`that`, unchanged :raise: :py:class:`SerializationException` if not finite """ if not math.isfinite(that): raise SerializationException( f"JSON knows neither an infinity nor a not-a-number, so the value " f"can not be serialized: {that}" ) return that def _json_value_to_jsonable(value: our_types.JsonValue) -> MutableJsonable: """ Serialize :paramref:`value` as a JSON-able structure. A JSON-able value is almost JSON-able as it comes, but not quite: its type rules out neither an infinity and a not-a-number, which JSON can not represent at all, nor a non-string key in an object. Each is refused here, at any depth. A ``None`` is written out as a JSON null. The result is a new structure, and never :paramref:`value` itself, so that the serialized document does not alias the instance it came from. :param value: to be serialized :return: :paramref:`value`, as a JSON-able structure :raise: :py:class:`SerializationException` if :paramref:`value` is not JSON-able """ if value is None: return None # NOTE (mristin): # A ``bool`` is an ``int`` in Python, so it has to be checked first -- # otherwise every boolean would come out as a number. if isinstance(value, bool): return value if isinstance(value, int): # NOTE (mristin): # An ``int`` is written out as it stands. JSON knows a single # numeric type, though, so it has to be one which a ``float`` can # hold exactly -- otherwise a reader, which reads every number as # a ``float``, would get a different number back. if our_common.try_to_convert_int_to_float(value) is None: raise SerializationException( f"Expected a JSON-able value, but got the integer {value}, " f"which is not exactly representable as a JSON number" ) return value if isinstance(value, float): if not math.isfinite(value): raise SerializationException( f"Expected a JSON-able value, but got the number {value}, " f"which is neither finite nor representable in JSON" ) return value if isinstance(value, str): return value if isinstance(value, (dict, collections.abc.Mapping)): mapping: Dict[str, Any] = {} for key, item_value in value.items(): if not isinstance(key, str): raise SerializationException( f"Expected only string keys in a JSON-able object, but got " f"a key of type: {type(key)}" ) try: mapping[key] = _json_value_to_jsonable(item_value) except SerializationException as exception: exception._prepend_key(key) raise return mapping array_like = our_common.try_to_cast_to_array_like(value) if array_like is not None: items: List[Any] = [] for i, item_value in enumerate(array_like): try: items.append(_json_value_to_jsonable(item_value)) except SerializationException as exception: exception._prepend_index(i) raise return items raise SerializationException( f"Expected a JSON-able value (a null, a boolean, a number, a string, " f"an array or an object), but got: {type(value)}" ) def _bytes_to_base64_str(value: bytes) -> str: """ Encode :paramref:`value` as a base64 string. :param value: to be encoded :return: encoded :paramref:`value` in base64 """ # We need to decode as ascii as ``base64.b64encode`` returns bytes, # not a string! return base64.b64encode(value).decode("ascii") def _list_of__asset_administration_shell_descriptor_to_jsonable( that: List[our_types.AssetAdministrationShellDescriptor], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.AssetAdministrationShellDescriptor`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_asset_administration_shell_descriptor_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__asset_administration_shell_metadata_to_jsonable( that: List[our_types.AssetAdministrationShellMetadata], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.AssetAdministrationShellMetadata`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_asset_administration_shell_metadata_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__asset_administration_shell_recent_change_to_jsonable( that: List[our_types.AssetAdministrationShellRecentChange], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.AssetAdministrationShellRecentChange`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_asset_administration_shell_recent_change_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__asset_administration_shell_to_jsonable( that: List[our_types.AssetAdministrationShell], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.AssetAdministrationShell`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_asset_administration_shell_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__concept_description_recent_change_to_jsonable( that: List[our_types.ConceptDescriptionRecentChange], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.ConceptDescriptionRecentChange`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_concept_description_recent_change_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__concept_description_to_jsonable( that: List[our_types.ConceptDescription], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.ConceptDescription`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_concept_description_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__data_element_to_jsonable( that: List[our_types.DataElement], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.DataElement`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__definition_type_uom_to_jsonable( that: List[our_types.DefinitionTypeUom], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.DefinitionTypeUom`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_definition_type_uom_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__embedded_data_specification_to_jsonable( that: List[our_types.EmbeddedDataSpecification], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.EmbeddedDataSpecification`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_embedded_data_specification_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__endpoint_to_jsonable( that: List[our_types.Endpoint], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Endpoint`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_endpoint_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__extension_to_jsonable( that: List[our_types.Extension], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Extension`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_extension_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__json_object_to_jsonable( that: List[our_types.JsonObject], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of a JSON-able object. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_json_value_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__key_to_jsonable(that: List[our_types.Key]) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Key`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_key_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_definition_type_iec_61360_to_jsonable( that: List[our_types.LangStringDefinitionTypeIEC61360], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringDefinitionTypeIEC61360`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_lang_string_definition_type_iec_61360_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_name_type_to_jsonable( that: List[our_types.LangStringNameType], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringNameType`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_lang_string_name_type_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_preferred_name_type_iec_61360_to_jsonable( that: List[our_types.LangStringPreferredNameTypeIEC61360], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringPreferredNameTypeIEC61360`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append( _lang_string_preferred_name_type_iec_61360_to_jsonable(item) ) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_short_name_type_iec_61360_to_jsonable( that: List[our_types.LangStringShortNameTypeIEC61360], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringShortNameTypeIEC61360`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_lang_string_short_name_type_iec_61360_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_text_type_to_jsonable( that: List[our_types.LangStringTextType], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringTextType`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_lang_string_text_type_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__lang_string_uom_to_jsonable( that: List[our_types.LangStringUom], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LangStringUom`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_lang_string_uom_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__logical_expression_to_jsonable( that: List[our_types.LogicalExpression], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.LogicalExpression`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__match_expression_to_jsonable( that: List[our_types.MatchExpression], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.MatchExpression`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__message_to_jsonable( that: List[our_types.Message], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Message`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_message_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__operation_variable_to_jsonable( that: List[our_types.OperationVariable], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.OperationVariable`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_operation_variable_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__package_description_to_jsonable( that: List[our_types.PackageDescription], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.PackageDescription`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_package_description_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__qualifier_to_jsonable( that: List[our_types.Qualifier], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Qualifier`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_qualifier_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__query_filter_to_jsonable( that: List[our_types.QueryFilter], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.QueryFilter`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_query_filter_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__referable_to_jsonable( that: List[our_types.Referable], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Referable`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__reference_to_jsonable( that: List[our_types.Reference], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Reference`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_reference_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__security_attribute_object_to_jsonable( that: List[our_types.SecurityAttributeObject], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SecurityAttributeObject`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_security_attribute_object_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__service_specification_profile_enum_to_jsonable( that: List[our_types.ServiceSpecificationProfileEnum], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.ServiceSpecificationProfileEnum`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.value) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__specific_asset_id_to_jsonable( that: List[our_types.SpecificAssetID], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SpecificAssetID`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_specific_asset_id_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_descriptor_to_jsonable( that: List[our_types.SubmodelDescriptor], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SubmodelDescriptor`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_submodel_descriptor_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_element_metadata_to_jsonable( that: List[our_types.SubmodelElementMetadata], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SubmodelElementMetadata`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_element_to_jsonable( that: List[our_types.SubmodelElement], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SubmodelElement`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(item.transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_metadata_to_jsonable( that: List[our_types.SubmodelMetadata], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SubmodelMetadata`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_submodel_metadata_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_recent_change_to_jsonable( that: List[our_types.SubmodelRecentChange], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.SubmodelRecentChange`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_submodel_recent_change_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__submodel_to_jsonable( that: List[our_types.Submodel], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.Submodel`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_submodel_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _list_of__value_reference_pair_to_jsonable( that: List[our_types.ValueReferencePair], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a list of :py:class:`.types.ValueReferencePair`. :param that: list to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] for i, item in enumerate(that): try: jsonable.append(_value_reference_pair_to_jsonable(item)) except SerializationException as exception: exception._prepend_index(i) raise return jsonable def _tuple2_of__string_value__string_value_to_jsonable( that: Tuple[our_types.StringValue, our_types.StringValue], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a tuple of 2 item(s). :param that: tuple to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] try: jsonable.append(that[0].transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(0) raise try: jsonable.append(that[1].transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(1) raise return jsonable def _tuple2_of__value__value_to_jsonable( that: Tuple[our_types.Value, our_types.Value], ) -> List[MutableJsonable]: """ Serialize :paramref:`that` as a tuple of 2 item(s). :param that: tuple to be serialized :return: JSON-able representation of :paramref:`that` """ jsonable: List[MutableJsonable] = [] try: jsonable.append(that[0].transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(0) raise try: jsonable.append(that[1].transform(_SERIALIZER)) except SerializationException as exception: exception._prepend_index(1) raise return jsonable def _extension_to_jsonable( that: our_types.Extension, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise try: jsonable["name"] = that.name except SerializationException as exception: exception._prepend_property("name") raise if that.value_type is not None: try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.refers_to is not None: try: jsonable["refersTo"] = _list_of__reference_to_jsonable(that.refers_to) except SerializationException as exception: exception._prepend_property("refers_to") raise return jsonable def _administrative_information_to_jsonable( that: our_types.AdministrativeInformation, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.version is not None: try: jsonable["version"] = that.version except SerializationException as exception: exception._prepend_property("version") raise if that.revision is not None: try: jsonable["revision"] = that.revision except SerializationException as exception: exception._prepend_property("revision") raise if that.creator is not None: try: jsonable["creator"] = _reference_to_jsonable(that.creator) except SerializationException as exception: exception._prepend_property("creator") raise if that.created_at is not None: try: jsonable["createdAt"] = that.created_at except SerializationException as exception: exception._prepend_property("created_at") raise if that.updated_at is not None: try: jsonable["updatedAt"] = that.updated_at except SerializationException as exception: exception._prepend_property("updated_at") raise if that.template_id is not None: try: jsonable["templateId"] = that.template_id except SerializationException as exception: exception._prepend_property("template_ID") raise return jsonable def _qualifier_to_jsonable( that: our_types.Qualifier, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.kind is not None: try: jsonable["kind"] = that.kind.value except SerializationException as exception: exception._prepend_property("kind") raise try: jsonable["type"] = that.type except SerializationException as exception: exception._prepend_property("type") raise try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.value_id is not None: try: jsonable["valueId"] = _reference_to_jsonable(that.value_id) except SerializationException as exception: exception._prepend_property("value_ID") raise return jsonable def _asset_administration_shell_to_jsonable( that: our_types.AssetAdministrationShell, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.derived_from is not None: try: jsonable["derivedFrom"] = _reference_to_jsonable(that.derived_from) except SerializationException as exception: exception._prepend_property("derived_from") raise try: jsonable["assetInformation"] = _asset_information_to_jsonable( that.asset_information ) except SerializationException as exception: exception._prepend_property("asset_information") raise if that.submodels is not None: try: jsonable["submodels"] = _list_of__reference_to_jsonable(that.submodels) except SerializationException as exception: exception._prepend_property("submodels") raise jsonable["modelType"] = "AssetAdministrationShell" return jsonable def _asset_information_to_jsonable( that: our_types.AssetInformation, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["assetKind"] = that.asset_kind.value except SerializationException as exception: exception._prepend_property("asset_kind") raise if that.global_asset_id is not None: try: jsonable["globalAssetId"] = that.global_asset_id except SerializationException as exception: exception._prepend_property("global_asset_ID") raise if that.specific_asset_ids is not None: try: jsonable["specificAssetIds"] = _list_of__specific_asset_id_to_jsonable( that.specific_asset_ids ) except SerializationException as exception: exception._prepend_property("specific_asset_IDs") raise if that.asset_type is not None: try: jsonable["assetType"] = that.asset_type except SerializationException as exception: exception._prepend_property("asset_type") raise if that.default_thumbnail is not None: try: jsonable["defaultThumbnail"] = _resource_to_jsonable(that.default_thumbnail) except SerializationException as exception: exception._prepend_property("default_thumbnail") raise return jsonable def _resource_to_jsonable( that: our_types.Resource, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["path"] = that.path except SerializationException as exception: exception._prepend_property("path") raise if that.content_type is not None: try: jsonable["contentType"] = that.content_type except SerializationException as exception: exception._prepend_property("content_type") raise return jsonable def _specific_asset_id_to_jsonable( that: our_types.SpecificAssetID, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise try: jsonable["name"] = that.name except SerializationException as exception: exception._prepend_property("name") raise try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.external_subject_id is not None: try: jsonable["externalSubjectId"] = _reference_to_jsonable( that.external_subject_id ) except SerializationException as exception: exception._prepend_property("external_subject_ID") raise return jsonable def _submodel_to_jsonable( that: our_types.Submodel, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.kind is not None: try: jsonable["kind"] = that.kind.value except SerializationException as exception: exception._prepend_property("kind") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.submodel_elements is not None: try: jsonable["submodelElements"] = _list_of__submodel_element_to_jsonable( that.submodel_elements ) except SerializationException as exception: exception._prepend_property("submodel_elements") raise jsonable["modelType"] = "Submodel" return jsonable def _relationship_element_to_jsonable( that: our_types.RelationshipElement, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.first is not None: try: jsonable["first"] = _reference_to_jsonable(that.first) except SerializationException as exception: exception._prepend_property("first") raise if that.second is not None: try: jsonable["second"] = _reference_to_jsonable(that.second) except SerializationException as exception: exception._prepend_property("second") raise jsonable["modelType"] = "RelationshipElement" return jsonable def _submodel_element_list_to_jsonable( that: our_types.SubmodelElementList, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.order_relevant is not None: try: jsonable["orderRelevant"] = that.order_relevant except SerializationException as exception: exception._prepend_property("order_relevant") raise if that.semantic_id_list_element is not None: try: jsonable["semanticIdListElement"] = _reference_to_jsonable( that.semantic_id_list_element ) except SerializationException as exception: exception._prepend_property("semantic_ID_list_element") raise try: jsonable["typeValueListElement"] = that.type_value_list_element.value except SerializationException as exception: exception._prepend_property("type_value_list_element") raise if that.value_type_list_element is not None: try: jsonable["valueTypeListElement"] = that.value_type_list_element.value except SerializationException as exception: exception._prepend_property("value_type_list_element") raise if that.value is not None: try: jsonable["value"] = _list_of__submodel_element_to_jsonable(that.value) except SerializationException as exception: exception._prepend_property("value") raise jsonable["modelType"] = "SubmodelElementList" return jsonable def _submodel_element_collection_to_jsonable( that: our_types.SubmodelElementCollection, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.value is not None: try: jsonable["value"] = _list_of__submodel_element_to_jsonable(that.value) except SerializationException as exception: exception._prepend_property("value") raise jsonable["modelType"] = "SubmodelElementCollection" return jsonable def _property_to_jsonable( that: our_types.Property, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.value_id is not None: try: jsonable["valueId"] = _reference_to_jsonable(that.value_id) except SerializationException as exception: exception._prepend_property("value_ID") raise jsonable["modelType"] = "Property" return jsonable def _multi_language_property_to_jsonable( that: our_types.MultiLanguageProperty, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.value is not None: try: jsonable["value"] = _list_of__lang_string_text_type_to_jsonable(that.value) except SerializationException as exception: exception._prepend_property("value") raise if that.value_id is not None: try: jsonable["valueId"] = _reference_to_jsonable(that.value_id) except SerializationException as exception: exception._prepend_property("value_ID") raise jsonable["modelType"] = "MultiLanguageProperty" return jsonable def _range_to_jsonable(that: our_types.Range) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise if that.min is not None: try: jsonable["min"] = that.min except SerializationException as exception: exception._prepend_property("min") raise if that.max is not None: try: jsonable["max"] = that.max except SerializationException as exception: exception._prepend_property("max") raise jsonable["modelType"] = "Range" return jsonable def _reference_element_to_jsonable( that: our_types.ReferenceElement, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.value is not None: try: jsonable["value"] = _reference_to_jsonable(that.value) except SerializationException as exception: exception._prepend_property("value") raise jsonable["modelType"] = "ReferenceElement" return jsonable def _blob_to_jsonable(that: our_types.Blob) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.value is not None: try: jsonable["value"] = _bytes_to_base64_str(that.value) except SerializationException as exception: exception._prepend_property("value") raise if that.content_type is not None: try: jsonable["contentType"] = that.content_type except SerializationException as exception: exception._prepend_property("content_type") raise jsonable["modelType"] = "Blob" return jsonable def _file_to_jsonable(that: our_types.File) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.content_type is not None: try: jsonable["contentType"] = that.content_type except SerializationException as exception: exception._prepend_property("content_type") raise jsonable["modelType"] = "File" return jsonable def _annotated_relationship_element_to_jsonable( that: our_types.AnnotatedRelationshipElement, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.first is not None: try: jsonable["first"] = _reference_to_jsonable(that.first) except SerializationException as exception: exception._prepend_property("first") raise if that.second is not None: try: jsonable["second"] = _reference_to_jsonable(that.second) except SerializationException as exception: exception._prepend_property("second") raise if that.annotations is not None: try: jsonable["annotations"] = _list_of__data_element_to_jsonable( that.annotations ) except SerializationException as exception: exception._prepend_property("annotations") raise jsonable["modelType"] = "AnnotatedRelationshipElement" return jsonable def _entity_to_jsonable(that: our_types.Entity) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.statements is not None: try: jsonable["statements"] = _list_of__submodel_element_to_jsonable( that.statements ) except SerializationException as exception: exception._prepend_property("statements") raise if that.entity_type is not None: try: jsonable["entityType"] = that.entity_type.value except SerializationException as exception: exception._prepend_property("entity_type") raise if that.global_asset_id is not None: try: jsonable["globalAssetId"] = that.global_asset_id except SerializationException as exception: exception._prepend_property("global_asset_ID") raise if that.specific_asset_ids is not None: try: jsonable["specificAssetIds"] = _list_of__specific_asset_id_to_jsonable( that.specific_asset_ids ) except SerializationException as exception: exception._prepend_property("specific_asset_IDs") raise jsonable["modelType"] = "Entity" return jsonable def _event_payload_to_jsonable( that: our_types.EventPayload, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["source"] = _reference_to_jsonable(that.source) except SerializationException as exception: exception._prepend_property("source") raise if that.source_semantic_id is not None: try: jsonable["sourceSemanticId"] = _reference_to_jsonable( that.source_semantic_id ) except SerializationException as exception: exception._prepend_property("source_semantic_ID") raise try: jsonable["observableReference"] = _reference_to_jsonable( that.observable_reference ) except SerializationException as exception: exception._prepend_property("observable_reference") raise if that.observable_semantic_id is not None: try: jsonable["observableSemanticId"] = _reference_to_jsonable( that.observable_semantic_id ) except SerializationException as exception: exception._prepend_property("observable_semantic_ID") raise if that.topic is not None: try: jsonable["topic"] = that.topic except SerializationException as exception: exception._prepend_property("topic") raise if that.subject_id is not None: try: jsonable["subjectId"] = _reference_to_jsonable(that.subject_id) except SerializationException as exception: exception._prepend_property("subject_ID") raise try: jsonable["timeStamp"] = that.time_stamp except SerializationException as exception: exception._prepend_property("time_stamp") raise if that.payload is not None: try: jsonable["payload"] = _bytes_to_base64_str(that.payload) except SerializationException as exception: exception._prepend_property("payload") raise return jsonable def _basic_event_element_to_jsonable( that: our_types.BasicEventElement, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["observed"] = _reference_to_jsonable(that.observed) except SerializationException as exception: exception._prepend_property("observed") raise try: jsonable["direction"] = that.direction.value except SerializationException as exception: exception._prepend_property("direction") raise try: jsonable["state"] = that.state.value except SerializationException as exception: exception._prepend_property("state") raise if that.message_topic is not None: try: jsonable["messageTopic"] = that.message_topic except SerializationException as exception: exception._prepend_property("message_topic") raise if that.message_broker is not None: try: jsonable["messageBroker"] = _reference_to_jsonable(that.message_broker) except SerializationException as exception: exception._prepend_property("message_broker") raise if that.last_update is not None: try: jsonable["lastUpdate"] = that.last_update except SerializationException as exception: exception._prepend_property("last_update") raise if that.min_interval is not None: try: jsonable["minInterval"] = that.min_interval except SerializationException as exception: exception._prepend_property("min_interval") raise if that.max_interval is not None: try: jsonable["maxInterval"] = that.max_interval except SerializationException as exception: exception._prepend_property("max_interval") raise jsonable["modelType"] = "BasicEventElement" return jsonable def _operation_to_jsonable( that: our_types.Operation, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.input_variables is not None: try: jsonable["inputVariables"] = _list_of__operation_variable_to_jsonable( that.input_variables ) except SerializationException as exception: exception._prepend_property("input_variables") raise if that.output_variables is not None: try: jsonable["outputVariables"] = _list_of__operation_variable_to_jsonable( that.output_variables ) except SerializationException as exception: exception._prepend_property("output_variables") raise if that.inoutput_variables is not None: try: jsonable["inoutputVariables"] = _list_of__operation_variable_to_jsonable( that.inoutput_variables ) except SerializationException as exception: exception._prepend_property("inoutput_variables") raise jsonable["modelType"] = "Operation" return jsonable def _operation_variable_to_jsonable( that: our_types.OperationVariable, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["value"] = that.value.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _capability_to_jsonable( that: our_types.Capability, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "Capability" return jsonable def _concept_description_to_jsonable( that: our_types.ConceptDescription, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.is_case_of is not None: try: jsonable["isCaseOf"] = _list_of__reference_to_jsonable(that.is_case_of) except SerializationException as exception: exception._prepend_property("is_case_of") raise jsonable["modelType"] = "ConceptDescription" return jsonable def _reference_to_jsonable( that: our_types.Reference, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["type"] = that.type.value except SerializationException as exception: exception._prepend_property("type") raise if that.referred_semantic_id is not None: try: jsonable["referredSemanticId"] = _reference_to_jsonable( that.referred_semantic_id ) except SerializationException as exception: exception._prepend_property("referred_semantic_ID") raise try: jsonable["keys"] = _list_of__key_to_jsonable(that.keys) except SerializationException as exception: exception._prepend_property("keys") raise return jsonable def _key_to_jsonable(that: our_types.Key) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["type"] = that.type.value except SerializationException as exception: exception._prepend_property("type") raise try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _lang_string_name_type_to_jsonable( that: our_types.LangStringNameType, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _lang_string_text_type_to_jsonable( that: our_types.LangStringTextType, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _environment_to_jsonable( that: our_types.Environment, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.asset_administration_shells is not None: try: jsonable["assetAdministrationShells"] = ( _list_of__asset_administration_shell_to_jsonable( that.asset_administration_shells ) ) except SerializationException as exception: exception._prepend_property("asset_administration_shells") raise if that.submodels is not None: try: jsonable["submodels"] = _list_of__submodel_to_jsonable(that.submodels) except SerializationException as exception: exception._prepend_property("submodels") raise if that.concept_descriptions is not None: try: jsonable["conceptDescriptions"] = _list_of__concept_description_to_jsonable( that.concept_descriptions ) except SerializationException as exception: exception._prepend_property("concept_descriptions") raise return jsonable def _embedded_data_specification_to_jsonable( that: our_types.EmbeddedDataSpecification, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["dataSpecification"] = _reference_to_jsonable(that.data_specification) except SerializationException as exception: exception._prepend_property("data_specification") raise try: jsonable["dataSpecificationContent"] = ( that.data_specification_content.transform(_SERIALIZER) ) except SerializationException as exception: exception._prepend_property("data_specification_content") raise return jsonable def _level_type_to_jsonable( that: our_types.LevelType, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["min"] = that.min except SerializationException as exception: exception._prepend_property("min") raise try: jsonable["nom"] = that.nom except SerializationException as exception: exception._prepend_property("nom") raise try: jsonable["typ"] = that.typ except SerializationException as exception: exception._prepend_property("typ") raise try: jsonable["max"] = that.max except SerializationException as exception: exception._prepend_property("max") raise return jsonable def _value_reference_pair_to_jsonable( that: our_types.ValueReferencePair, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.value_id is not None: try: jsonable["valueId"] = _reference_to_jsonable(that.value_id) except SerializationException as exception: exception._prepend_property("value_ID") raise return jsonable def _value_list_to_jsonable( that: our_types.ValueList, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["valueReferencePairs"] = _list_of__value_reference_pair_to_jsonable( that.value_reference_pairs ) except SerializationException as exception: exception._prepend_property("value_reference_pairs") raise return jsonable def _lang_string_preferred_name_type_iec_61360_to_jsonable( that: our_types.LangStringPreferredNameTypeIEC61360, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _lang_string_short_name_type_iec_61360_to_jsonable( that: our_types.LangStringShortNameTypeIEC61360, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _lang_string_definition_type_iec_61360_to_jsonable( that: our_types.LangStringDefinitionTypeIEC61360, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _lang_string_uom_to_jsonable( that: our_types.LangStringUom, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _definition_type_uom_to_jsonable( that: our_types.DefinitionTypeUom, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["language"] = that.language except SerializationException as exception: exception._prepend_property("language") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise return jsonable def _data_specification_uom_to_jsonable( that: our_types.DataSpecificationUom, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["preferredName"] = _list_of__lang_string_uom_to_jsonable( that.preferred_name ) except SerializationException as exception: exception._prepend_property("preferred_name") raise try: jsonable["symbol"] = that.symbol except SerializationException as exception: exception._prepend_property("symbol") raise if that.specific_unit_id is not None: try: jsonable["specificUnitId"] = that.specific_unit_id except SerializationException as exception: exception._prepend_property("specific_unit_ID") raise if that.definition is not None: try: jsonable["definition"] = _list_of__definition_type_uom_to_jsonable( that.definition ) except SerializationException as exception: exception._prepend_property("definition") raise if that.preferred_name_quantity is not None: try: jsonable["preferredNameQuantity"] = _list_of__lang_string_uom_to_jsonable( that.preferred_name_quantity ) except SerializationException as exception: exception._prepend_property("preferred_name_quantity") raise if that.quantity_id is not None: try: jsonable["quantityId"] = that.quantity_id except SerializationException as exception: exception._prepend_property("quantity_ID") raise if that.classification_system is not None: try: jsonable["classificationSystem"] = that.classification_system except SerializationException as exception: exception._prepend_property("classification_system") raise if that.classification_system_version is not None: try: jsonable["classificationSystemVersion"] = that.classification_system_version except SerializationException as exception: exception._prepend_property("classification_system_version") raise jsonable["modelType"] = "DataSpecificationUom" return jsonable def _data_specification_iec_61360_to_jsonable( that: our_types.DataSpecificationIEC61360, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["preferredName"] = ( _list_of__lang_string_preferred_name_type_iec_61360_to_jsonable( that.preferred_name ) ) except SerializationException as exception: exception._prepend_property("preferred_name") raise if that.short_name is not None: try: jsonable["shortName"] = ( _list_of__lang_string_short_name_type_iec_61360_to_jsonable( that.short_name ) ) except SerializationException as exception: exception._prepend_property("short_name") raise if that.unit is not None: try: jsonable["unit"] = that.unit except SerializationException as exception: exception._prepend_property("unit") raise if that.unit_id is not None: try: jsonable["unitId"] = _reference_to_jsonable(that.unit_id) except SerializationException as exception: exception._prepend_property("unit_ID") raise if that.source_of_definition is not None: try: jsonable["sourceOfDefinition"] = that.source_of_definition except SerializationException as exception: exception._prepend_property("source_of_definition") raise if that.symbol is not None: try: jsonable["symbol"] = that.symbol except SerializationException as exception: exception._prepend_property("symbol") raise if that.data_type is not None: try: jsonable["dataType"] = that.data_type.value except SerializationException as exception: exception._prepend_property("data_type") raise if that.definition is not None: try: jsonable["definition"] = ( _list_of__lang_string_definition_type_iec_61360_to_jsonable( that.definition ) ) except SerializationException as exception: exception._prepend_property("definition") raise if that.value_format is not None: try: jsonable["valueFormat"] = that.value_format except SerializationException as exception: exception._prepend_property("value_format") raise if that.value_list is not None: try: jsonable["valueList"] = _value_list_to_jsonable(that.value_list) except SerializationException as exception: exception._prepend_property("value_list") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise if that.level_type is not None: try: jsonable["levelType"] = _level_type_to_jsonable(that.level_type) except SerializationException as exception: exception._prepend_property("level_type") raise jsonable["modelType"] = "DataSpecificationIec61360" return jsonable def _asset_administration_shell_descriptor_to_jsonable( that: our_types.AssetAdministrationShellDescriptor, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise if that.asset_kind is not None: try: jsonable["assetKind"] = that.asset_kind.value except SerializationException as exception: exception._prepend_property("asset_kind") raise if that.asset_type is not None: try: jsonable["assetType"] = that.asset_type except SerializationException as exception: exception._prepend_property("asset_type") raise if that.endpoints is not None: try: jsonable["endpoints"] = _list_of__endpoint_to_jsonable(that.endpoints) except SerializationException as exception: exception._prepend_property("endpoints") raise if that.global_asset_id is not None: try: jsonable["globalAssetId"] = that.global_asset_id except SerializationException as exception: exception._prepend_property("global_asset_ID") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.specific_asset_ids is not None: try: jsonable["specificAssetIds"] = _list_of__specific_asset_id_to_jsonable( that.specific_asset_ids ) except SerializationException as exception: exception._prepend_property("specific_asset_IDs") raise if that.submodel_descriptors is not None: try: jsonable["submodelDescriptors"] = _list_of__submodel_descriptor_to_jsonable( that.submodel_descriptors ) except SerializationException as exception: exception._prepend_property("submodel_descriptors") raise return jsonable def _submodel_descriptor_to_jsonable( that: our_types.SubmodelDescriptor, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise try: jsonable["endpoints"] = _list_of__endpoint_to_jsonable(that.endpoints) except SerializationException as exception: exception._prepend_property("endpoints") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise return jsonable def _endpoint_to_jsonable( that: our_types.Endpoint, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["protocolInformation"] = _protocol_information_to_jsonable( that.protocol_information ) except SerializationException as exception: exception._prepend_property("protocol_information") raise try: jsonable["interface"] = that.interface except SerializationException as exception: exception._prepend_property("interface") raise return jsonable def _protocol_information_to_jsonable( that: our_types.ProtocolInformation, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["href"] = that.href except SerializationException as exception: exception._prepend_property("href") raise if that.endpoint_protocol is not None: try: jsonable["endpointProtocol"] = that.endpoint_protocol except SerializationException as exception: exception._prepend_property("endpoint_protocol") raise if that.endpoint_protocol_version is not None: try: jsonable["endpointProtocolVersion"] = list(that.endpoint_protocol_version) except SerializationException as exception: exception._prepend_property("endpoint_protocol_version") raise if that.subprotocol is not None: try: jsonable["subprotocol"] = that.subprotocol except SerializationException as exception: exception._prepend_property("subprotocol") raise if that.subprotocol_body is not None: try: jsonable["subprotocolBody"] = that.subprotocol_body except SerializationException as exception: exception._prepend_property("subprotocol_body") raise if that.subprotocol_body_encoding is not None: try: jsonable["subprotocolBodyEncoding"] = that.subprotocol_body_encoding except SerializationException as exception: exception._prepend_property("subprotocol_body_encoding") raise if that.security_attributes is not None: try: jsonable["securityAttributes"] = ( _list_of__security_attribute_object_to_jsonable( that.security_attributes ) ) except SerializationException as exception: exception._prepend_property("security_attributes") raise return jsonable def _security_attribute_object_to_jsonable( that: our_types.SecurityAttributeObject, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["type"] = that.type.value except SerializationException as exception: exception._prepend_property("type") raise try: jsonable["key"] = that.key except SerializationException as exception: exception._prepend_property("key") raise try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _asset_link_to_jsonable( that: our_types.AssetLink, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["name"] = that.name except SerializationException as exception: exception._prepend_property("name") raise try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _service_description_to_jsonable( that: our_types.ServiceDescription, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["profiles"] = _list_of__service_specification_profile_enum_to_jsonable( that.profiles ) except SerializationException as exception: exception._prepend_property("profiles") raise return jsonable def _asset_administration_shell_recent_change_to_jsonable( that: our_types.AssetAdministrationShellRecentChange, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["createdAt"] = that.created_at except SerializationException as exception: exception._prepend_property("created_at") raise try: jsonable["updatedAt"] = that.updated_at except SerializationException as exception: exception._prepend_property("updated_at") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.global_asset_id is not None: try: jsonable["globalAssetId"] = that.global_asset_id except SerializationException as exception: exception._prepend_property("global_asset_ID") raise if that.specific_asset_ids is not None: try: jsonable["specificAssetIds"] = _list_of__specific_asset_id_to_jsonable( that.specific_asset_ids ) except SerializationException as exception: exception._prepend_property("specific_asset_IDs") raise return jsonable def _concept_description_recent_change_to_jsonable( that: our_types.ConceptDescriptionRecentChange, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["createdAt"] = that.created_at except SerializationException as exception: exception._prepend_property("created_at") raise try: jsonable["updatedAt"] = that.updated_at except SerializationException as exception: exception._prepend_property("updated_at") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise return jsonable def _submodel_recent_change_to_jsonable( that: our_types.SubmodelRecentChange, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["createdAt"] = that.created_at except SerializationException as exception: exception._prepend_property("created_at") raise try: jsonable["updatedAt"] = that.updated_at except SerializationException as exception: exception._prepend_property("updated_at") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise return jsonable def _result_to_jsonable(that: our_types.Result) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.messages is not None: try: jsonable["messages"] = _list_of__message_to_jsonable(that.messages) except SerializationException as exception: exception._prepend_property("messages") raise return jsonable def _message_to_jsonable( that: our_types.Message, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["messageType"] = that.message_type.value except SerializationException as exception: exception._prepend_property("message_type") raise try: jsonable["text"] = that.text except SerializationException as exception: exception._prepend_property("text") raise if that.code is not None: try: jsonable["code"] = that.code except SerializationException as exception: exception._prepend_property("code") raise if that.correlation_id is not None: try: jsonable["correlationId"] = that.correlation_id except SerializationException as exception: exception._prepend_property("correlation_ID") raise if that.timestamp is not None: try: jsonable["timestamp"] = that.timestamp except SerializationException as exception: exception._prepend_property("timestamp") raise return jsonable def _operation_request_to_jsonable( that: our_types.OperationRequest, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.input_arguments is not None: try: jsonable["inputArguments"] = _list_of__operation_variable_to_jsonable( that.input_arguments ) except SerializationException as exception: exception._prepend_property("input_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _list_of__operation_variable_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise if that.client_timeout_duration is not None: try: jsonable["clientTimeoutDuration"] = that.client_timeout_duration except SerializationException as exception: exception._prepend_property("client_timeout_duration") raise return jsonable def _operation_request_async_to_jsonable( that: our_types.OperationRequestAsync, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.input_arguments is not None: try: jsonable["inputArguments"] = _list_of__operation_variable_to_jsonable( that.input_arguments ) except SerializationException as exception: exception._prepend_property("input_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _list_of__operation_variable_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise try: jsonable["clientTimeoutDuration"] = that.client_timeout_duration except SerializationException as exception: exception._prepend_property("client_timeout_duration") raise return jsonable def _operation_request_value_only_to_jsonable( that: our_types.OperationRequestValueOnly, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.input_arguments is not None: try: jsonable["inputArguments"] = _json_value_to_jsonable(that.input_arguments) except SerializationException as exception: exception._prepend_property("input_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _json_value_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise if that.client_timeout_duration is not None: try: jsonable["clientTimeoutDuration"] = that.client_timeout_duration except SerializationException as exception: exception._prepend_property("client_timeout_duration") raise return jsonable def _operation_request_async_value_only_to_jsonable( that: our_types.OperationRequestAsyncValueOnly, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.input_arguments is not None: try: jsonable["inputArguments"] = _json_value_to_jsonable(that.input_arguments) except SerializationException as exception: exception._prepend_property("input_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _json_value_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise try: jsonable["clientTimeoutDuration"] = that.client_timeout_duration except SerializationException as exception: exception._prepend_property("client_timeout_duration") raise return jsonable def _base_operation_result_to_jsonable( that: our_types.BaseOperationResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["executionState"] = that.execution_state.value except SerializationException as exception: exception._prepend_property("execution_state") raise if that.messages is not None: try: jsonable["messages"] = _list_of__message_to_jsonable(that.messages) except SerializationException as exception: exception._prepend_property("messages") raise if that.success is not None: try: jsonable["success"] = that.success except SerializationException as exception: exception._prepend_property("success") raise return jsonable def _operation_result_to_jsonable( that: our_types.OperationResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["executionState"] = that.execution_state.value except SerializationException as exception: exception._prepend_property("execution_state") raise if that.messages is not None: try: jsonable["messages"] = _list_of__message_to_jsonable(that.messages) except SerializationException as exception: exception._prepend_property("messages") raise if that.success is not None: try: jsonable["success"] = that.success except SerializationException as exception: exception._prepend_property("success") raise if that.output_arguments is not None: try: jsonable["outputArguments"] = _list_of__operation_variable_to_jsonable( that.output_arguments ) except SerializationException as exception: exception._prepend_property("output_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _list_of__operation_variable_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise return jsonable def _operation_result_value_only_to_jsonable( that: our_types.OperationResultValueOnly, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["executionState"] = that.execution_state.value except SerializationException as exception: exception._prepend_property("execution_state") raise if that.messages is not None: try: jsonable["messages"] = _list_of__message_to_jsonable(that.messages) except SerializationException as exception: exception._prepend_property("messages") raise if that.success is not None: try: jsonable["success"] = that.success except SerializationException as exception: exception._prepend_property("success") raise if that.output_arguments is not None: try: jsonable["outputArguments"] = _json_value_to_jsonable(that.output_arguments) except SerializationException as exception: exception._prepend_property("output_arguments") raise if that.inoutput_arguments is not None: try: jsonable["inoutputArguments"] = _json_value_to_jsonable( that.inoutput_arguments ) except SerializationException as exception: exception._prepend_property("inoutput_arguments") raise return jsonable def _operation_handle_to_jsonable( that: our_types.OperationHandle, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["handleId"] = that.handle_id except SerializationException as exception: exception._prepend_property("handle_ID") raise return jsonable def _paged_result_to_jsonable( that: our_types.PagedResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.result is not None: try: jsonable["result"] = _list_of__referable_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise return jsonable def _paging_metadata_to_jsonable( that: our_types.PagingMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.cursor is not None: try: jsonable["cursor"] = that.cursor except SerializationException as exception: exception._prepend_property("cursor") raise return jsonable def _package_description_to_jsonable( that: our_types.PackageDescription, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["packageId"] = that.package_id except SerializationException as exception: exception._prepend_property("package_ID") raise if that.aas_ids is not None: try: jsonable["aasIds"] = list(that.aas_ids) except SerializationException as exception: exception._prepend_property("AAS_IDs") raise return jsonable def _property_metadata_to_jsonable( that: our_types.PropertyMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise jsonable["modelType"] = "PropertyMetadata" return jsonable def _range_metadata_to_jsonable( that: our_types.RangeMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["valueType"] = that.value_type.value except SerializationException as exception: exception._prepend_property("value_type") raise jsonable["modelType"] = "RangeMetadata" return jsonable def _blob_metadata_to_jsonable( that: our_types.BlobMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "BlobMetadata" return jsonable def _file_metadata_to_jsonable( that: our_types.FileMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "FileMetadata" return jsonable def _multi_language_property_metadata_to_jsonable( that: our_types.MultiLanguagePropertyMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "MultiLanguagePropertyMetadata" return jsonable def _reference_element_metadata_to_jsonable( that: our_types.ReferenceElementMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "ReferenceElementMetadata" return jsonable def _relationship_element_metadata_to_jsonable( that: our_types.RelationshipElementMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "RelationshipElementMetadata" return jsonable def _annotated_relationship_element_metadata_to_jsonable( that: our_types.AnnotatedRelationshipElementMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "AnnotatedRelationshipElementMetadata" return jsonable def _entity_metadata_to_jsonable( that: our_types.EntityMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "EntityMetadata" return jsonable def _capability_metadata_to_jsonable( that: our_types.CapabilityMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "CapabilityMetadata" return jsonable def _operation_metadata_to_jsonable( that: our_types.OperationMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "OperationMetadata" return jsonable def _submodel_element_collection_metadata_to_jsonable( that: our_types.SubmodelElementCollectionMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "SubmodelElementCollectionMetadata" return jsonable def _basic_event_element_metadata_to_jsonable( that: our_types.BasicEventElementMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise try: jsonable["direction"] = that.direction.value except SerializationException as exception: exception._prepend_property("direction") raise try: jsonable["state"] = that.state.value except SerializationException as exception: exception._prepend_property("state") raise if that.message_topic is not None: try: jsonable["messageTopic"] = that.message_topic except SerializationException as exception: exception._prepend_property("message_topic") raise if that.message_broker is not None: try: jsonable["messageBroker"] = _reference_to_jsonable(that.message_broker) except SerializationException as exception: exception._prepend_property("message_broker") raise if that.last_update is not None: try: jsonable["lastUpdate"] = that.last_update except SerializationException as exception: exception._prepend_property("last_update") raise if that.min_interval is not None: try: jsonable["minInterval"] = that.min_interval except SerializationException as exception: exception._prepend_property("min_interval") raise if that.max_interval is not None: try: jsonable["maxInterval"] = that.max_interval except SerializationException as exception: exception._prepend_property("max_interval") raise jsonable["modelType"] = "BasicEventElementMetadata" return jsonable def _submodel_element_list_metadata_to_jsonable( that: our_types.SubmodelElementListMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.order_relevant is not None: try: jsonable["orderRelevant"] = that.order_relevant except SerializationException as exception: exception._prepend_property("order_relevant") raise if that.semantic_id_list_element is not None: try: jsonable["semanticIdListElement"] = _reference_to_jsonable( that.semantic_id_list_element ) except SerializationException as exception: exception._prepend_property("semantic_ID_list_element") raise try: jsonable["typeValueListElement"] = that.type_value_list_element.value except SerializationException as exception: exception._prepend_property("type_value_list_element") raise if that.value_type_list_element is not None: try: jsonable["valueTypeListElement"] = that.value_type_list_element.value except SerializationException as exception: exception._prepend_property("value_type_list_element") raise jsonable["modelType"] = "SubmodelElementListMetadata" return jsonable def _submodel_metadata_to_jsonable( that: our_types.SubmodelMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.kind is not None: try: jsonable["kind"] = that.kind.value except SerializationException as exception: exception._prepend_property("kind") raise if that.semantic_id is not None: try: jsonable["semanticId"] = _reference_to_jsonable(that.semantic_id) except SerializationException as exception: exception._prepend_property("semantic_ID") raise if that.supplemental_semantic_ids is not None: try: jsonable["supplementalSemanticIds"] = _list_of__reference_to_jsonable( that.supplemental_semantic_ids ) except SerializationException as exception: exception._prepend_property("supplemental_semantic_IDs") raise if that.qualifiers is not None: try: jsonable["qualifiers"] = _list_of__qualifier_to_jsonable(that.qualifiers) except SerializationException as exception: exception._prepend_property("qualifiers") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise jsonable["modelType"] = "SubmodelMetadata" return jsonable def _asset_administration_shell_metadata_to_jsonable( that: our_types.AssetAdministrationShellMetadata, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.extensions is not None: try: jsonable["extensions"] = _list_of__extension_to_jsonable(that.extensions) except SerializationException as exception: exception._prepend_property("extensions") raise if that.category is not None: try: jsonable["category"] = that.category except SerializationException as exception: exception._prepend_property("category") raise if that.id_short is not None: try: jsonable["idShort"] = that.id_short except SerializationException as exception: exception._prepend_property("ID_short") raise if that.display_name is not None: try: jsonable["displayName"] = _list_of__lang_string_name_type_to_jsonable( that.display_name ) except SerializationException as exception: exception._prepend_property("display_name") raise if that.description is not None: try: jsonable["description"] = _list_of__lang_string_text_type_to_jsonable( that.description ) except SerializationException as exception: exception._prepend_property("description") raise if that.administration is not None: try: jsonable["administration"] = _administrative_information_to_jsonable( that.administration ) except SerializationException as exception: exception._prepend_property("administration") raise try: jsonable["id"] = that.id except SerializationException as exception: exception._prepend_property("ID") raise if that.embedded_data_specifications is not None: try: jsonable["embeddedDataSpecifications"] = ( _list_of__embedded_data_specification_to_jsonable( that.embedded_data_specifications ) ) except SerializationException as exception: exception._prepend_property("embedded_data_specifications") raise if that.derived_from is not None: try: jsonable["derivedFrom"] = _reference_to_jsonable(that.derived_from) except SerializationException as exception: exception._prepend_property("derived_from") raise jsonable["modelType"] = "AssetAdministrationShellMetadata" return jsonable def _reference_element_value_to_jsonable( that: our_types.ReferenceElementValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["type"] = that.type.value except SerializationException as exception: exception._prepend_property("type") raise try: jsonable["keys"] = _list_of__key_to_jsonable(that.keys) except SerializationException as exception: exception._prepend_property("keys") raise if that.referred_semantic_id is not None: try: jsonable["referredSemanticId"] = _reference_to_jsonable( that.referred_semantic_id ) except SerializationException as exception: exception._prepend_property("referred_semantic_ID") raise return jsonable def _blob_value_to_jsonable( that: our_types.BlobValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.content_type is not None: try: jsonable["contentType"] = that.content_type except SerializationException as exception: exception._prepend_property("content_type") raise if that.value is not None: try: jsonable["value"] = _bytes_to_base64_str(that.value) except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _file_value_to_jsonable( that: our_types.FileValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.content_type is not None: try: jsonable["contentType"] = that.content_type except SerializationException as exception: exception._prepend_property("content_type") raise if that.value is not None: try: jsonable["value"] = that.value except SerializationException as exception: exception._prepend_property("value") raise return jsonable def _range_value_to_jsonable( that: our_types.RangeValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["min"] = _float_to_jsonable(that.min) except SerializationException as exception: exception._prepend_property("min") raise try: jsonable["max"] = _float_to_jsonable(that.max) except SerializationException as exception: exception._prepend_property("max") raise return jsonable def _relationship_element_value_to_jsonable( that: our_types.RelationshipElementValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.first is not None: try: jsonable["first"] = _reference_to_jsonable(that.first) except SerializationException as exception: exception._prepend_property("first") raise if that.second is not None: try: jsonable["second"] = _reference_to_jsonable(that.second) except SerializationException as exception: exception._prepend_property("second") raise return jsonable def _basic_event_element_value_to_jsonable( that: our_types.BasicEventElementValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["observed"] = _reference_to_jsonable(that.observed) except SerializationException as exception: exception._prepend_property("observed") raise return jsonable def _annotated_relationship_element_value_to_jsonable( that: our_types.AnnotatedRelationshipElementValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.first is not None: try: jsonable["first"] = _reference_to_jsonable(that.first) except SerializationException as exception: exception._prepend_property("first") raise if that.second is not None: try: jsonable["second"] = _reference_to_jsonable(that.second) except SerializationException as exception: exception._prepend_property("second") raise if that.annotations is not None: try: jsonable["annotations"] = _json_value_to_jsonable(that.annotations) except SerializationException as exception: exception._prepend_property("annotations") raise return jsonable def _entity_value_to_jsonable( that: our_types.EntityValue, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.entity_type is not None: try: jsonable["entityType"] = that.entity_type.value except SerializationException as exception: exception._prepend_property("entity_type") raise if that.global_asset_id is not None: try: jsonable["globalAssetId"] = that.global_asset_id except SerializationException as exception: exception._prepend_property("global_asset_ID") raise if that.specific_asset_ids is not None: try: jsonable["specificAssetIds"] = _list_of__json_object_to_jsonable( that.specific_asset_ids ) except SerializationException as exception: exception._prepend_property("specific_asset_IDs") raise if that.statements is not None: try: jsonable["statements"] = _json_value_to_jsonable(that.statements) except SerializationException as exception: exception._prepend_property("statements") raise return jsonable def _get_asset_administration_shells_result_to_jsonable( that: our_types.GetAssetAdministrationShellsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__asset_administration_shell_to_jsonable( that.result ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_asset_administration_shells_metadata_result_to_jsonable( that: our_types.GetAssetAdministrationShellsMetadataResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = ( _list_of__asset_administration_shell_metadata_to_jsonable(that.result) ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_all_asset_administration_shells_recent_changes_result_to_jsonable( that: our_types.GetAllAssetAdministrationShellsRecentChangesResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = ( _list_of__asset_administration_shell_recent_change_to_jsonable( that.result ) ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_asset_administration_shell_descriptors_result_to_jsonable( that: our_types.GetAssetAdministrationShellDescriptorsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = ( _list_of__asset_administration_shell_descriptor_to_jsonable(that.result) ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_concept_descriptions_result_to_jsonable( that: our_types.GetConceptDescriptionsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__concept_description_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_all_concept_descriptions_recent_changes_result_to_jsonable( that: our_types.GetAllConceptDescriptionsRecentChangesResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = ( _list_of__concept_description_recent_change_to_jsonable(that.result) ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_package_descriptions_result_to_jsonable( that: our_types.GetPackageDescriptionsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__package_description_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_path_items_result_to_jsonable( that: our_types.GetPathItemsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = list(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_references_result_to_jsonable( that: our_types.GetReferencesResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__reference_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodel_descriptors_result_to_jsonable( that: our_types.GetSubmodelDescriptorsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_descriptor_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodel_elements_metadata_result_to_jsonable( that: our_types.GetSubmodelElementsMetadataResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_element_metadata_to_jsonable( that.result ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodel_elements_result_to_jsonable( that: our_types.GetSubmodelElementsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_element_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodel_elements_value_result_to_jsonable( that: our_types.GetSubmodelElementsValueResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__json_object_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_all_submodels_recent_changes_result_to_jsonable( that: our_types.GetAllSubmodelsRecentChangesResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_recent_change_to_jsonable( that.result ) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodels_metadata_result_to_jsonable( that: our_types.GetSubmodelsMetadataResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_metadata_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodels_result_to_jsonable( that: our_types.GetSubmodelsResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__submodel_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _get_submodels_value_result_to_jsonable( that: our_types.GetSubmodelsValueResult, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["paging_metadata"] = _paging_metadata_to_jsonable(that.paging_metadata) except SerializationException as exception: exception._prepend_property("paging_metadata") raise if that.result is not None: try: jsonable["result"] = _list_of__json_object_to_jsonable(that.result) except SerializationException as exception: exception._prepend_property("result") raise return jsonable def _claim_attribute_to_jsonable( that: our_types.ClaimAttribute, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["CLAIM"] = that.claim except SerializationException as exception: exception._prepend_property("claim") raise return jsonable def _global_attribute_to_jsonable( that: our_types.GlobalAttribute, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["GLOBAL"] = that.kind.value except SerializationException as exception: exception._prepend_property("kind") raise return jsonable def _reference_attribute_to_jsonable( that: our_types.ReferenceAttribute, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["REFERENCE"] = that.reference except SerializationException as exception: exception._prepend_property("reference") raise return jsonable def _date_time_attribute_item_to_jsonable( that: our_types.DateTimeAttributeItem, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["GLOBAL"] = that.kind.value except SerializationException as exception: exception._prepend_property("kind") raise return jsonable def _field_operand_to_jsonable( that: our_types.FieldOperand, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$field"] = that.field except SerializationException as exception: exception._prepend_property("field") raise return jsonable def _string_literal_to_jsonable( that: our_types.StringLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$strVal"] = that.str_val except SerializationException as exception: exception._prepend_property("str_val") raise return jsonable def _attribute_operand_to_jsonable( that: our_types.AttributeOperand, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$attribute"] = that.attribute.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("attribute") raise return jsonable def _number_literal_to_jsonable( that: our_types.NumberLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$numVal"] = _float_to_jsonable(that.num_val) except SerializationException as exception: exception._prepend_property("num_val") raise return jsonable def _hex_literal_to_jsonable( that: our_types.HexLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$hexVal"] = that.hex_val except SerializationException as exception: exception._prepend_property("hex_val") raise return jsonable def _date_time_literal_to_jsonable( that: our_types.DateTimeLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$dateTimeVal"] = that.date_time_val except SerializationException as exception: exception._prepend_property("date_time_val") raise return jsonable def _time_literal_to_jsonable( that: our_types.TimeLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$timeVal"] = that.time_val except SerializationException as exception: exception._prepend_property("time_val") raise return jsonable def _boolean_literal_to_jsonable( that: our_types.BooleanLiteral, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$boolean"] = that.boolean except SerializationException as exception: exception._prepend_property("boolean") raise return jsonable def _string_cast_to_jsonable( that: our_types.StringCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$strCast"] = that.str_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("str_cast") raise return jsonable def _number_cast_to_jsonable( that: our_types.NumberCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$numCast"] = that.num_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("num_cast") raise return jsonable def _hex_cast_to_jsonable( that: our_types.HexCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$hexCast"] = that.hex_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("hex_cast") raise return jsonable def _boolean_cast_to_jsonable( that: our_types.BooleanCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$boolCast"] = that.bool_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("bool_cast") raise return jsonable def _date_time_cast_to_jsonable( that: our_types.DateTimeCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$dateTimeCast"] = that.date_time_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("date_time_cast") raise return jsonable def _time_cast_to_jsonable( that: our_types.TimeCast, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$timeCast"] = that.time_cast.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("time_cast") raise return jsonable def _day_of_week_to_jsonable( that: our_types.DayOfWeek, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$dayOfWeek"] = that.day_of_week.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("day_of_week") raise return jsonable def _day_of_month_to_jsonable( that: our_types.DayOfMonth, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$dayOfMonth"] = that.day_of_month.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("day_of_month") raise return jsonable def _month_to_jsonable(that: our_types.Month) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$month"] = that.month.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("month") raise return jsonable def _year_to_jsonable(that: our_types.Year) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$year"] = that.year.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("year") raise return jsonable def _date_time_attribute_operand_to_jsonable( that: our_types.DateTimeAttributeOperand, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$attribute"] = _date_time_attribute_item_to_jsonable(that.attribute) except SerializationException as exception: exception._prepend_property("attribute") raise return jsonable def _equal_comparison_to_jsonable( that: our_types.EqualComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$eq"] = _tuple2_of__value__value_to_jsonable(that.eq) except SerializationException as exception: exception._prepend_property("eq") raise return jsonable def _not_equal_comparison_to_jsonable( that: our_types.NotEqualComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$ne"] = _tuple2_of__value__value_to_jsonable(that.ne) except SerializationException as exception: exception._prepend_property("ne") raise return jsonable def _greater_than_comparison_to_jsonable( that: our_types.GreaterThanComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$gt"] = _tuple2_of__value__value_to_jsonable(that.gt) except SerializationException as exception: exception._prepend_property("gt") raise return jsonable def _greater_than_or_equal_comparison_to_jsonable( that: our_types.GreaterThanOrEqualComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$ge"] = _tuple2_of__value__value_to_jsonable(that.ge) except SerializationException as exception: exception._prepend_property("ge") raise return jsonable def _less_than_comparison_to_jsonable( that: our_types.LessThanComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$lt"] = _tuple2_of__value__value_to_jsonable(that.lt) except SerializationException as exception: exception._prepend_property("lt") raise return jsonable def _less_than_or_equal_comparison_to_jsonable( that: our_types.LessThanOrEqualComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$le"] = _tuple2_of__value__value_to_jsonable(that.le) except SerializationException as exception: exception._prepend_property("le") raise return jsonable def _contains_comparison_to_jsonable( that: our_types.ContainsComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$contains"] = _tuple2_of__string_value__string_value_to_jsonable( that.contains ) except SerializationException as exception: exception._prepend_property("contains") raise return jsonable def _starts_with_comparison_to_jsonable( that: our_types.StartsWithComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$starts-with"] = _tuple2_of__string_value__string_value_to_jsonable( that.starts_with ) except SerializationException as exception: exception._prepend_property("starts_with") raise return jsonable def _ends_with_comparison_to_jsonable( that: our_types.EndsWithComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$ends-with"] = _tuple2_of__string_value__string_value_to_jsonable( that.ends_with ) except SerializationException as exception: exception._prepend_property("ends_with") raise return jsonable def _regex_comparison_to_jsonable( that: our_types.RegexComparison, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$regex"] = _tuple2_of__string_value__string_value_to_jsonable( that.regex ) except SerializationException as exception: exception._prepend_property("regex") raise return jsonable def _match_clause_to_jsonable( that: our_types.MatchClause, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$match"] = _list_of__match_expression_to_jsonable(that.match_operands) except SerializationException as exception: exception._prepend_property("match_operands") raise return jsonable def _and_expression_to_jsonable( that: our_types.AndExpression, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$and"] = _list_of__logical_expression_to_jsonable(that.and_operands) except SerializationException as exception: exception._prepend_property("and_operands") raise return jsonable def _or_expression_to_jsonable( that: our_types.OrExpression, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$or"] = _list_of__logical_expression_to_jsonable(that.or_operands) except SerializationException as exception: exception._prepend_property("or_operands") raise return jsonable def _not_expression_to_jsonable( that: our_types.NotExpression, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$not"] = that.not_operand.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("not_operand") raise return jsonable def _query_filter_to_jsonable( that: our_types.QueryFilter, ) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} try: jsonable["$fragment"] = that.fragment except SerializationException as exception: exception._prepend_property("fragment") raise try: jsonable["$condition"] = that.condition.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("condition") raise return jsonable def _query_to_jsonable(that: our_types.Query) -> MutableMapping[str, MutableJsonable]: """Serialize :paramref:`that` to a JSON-able representation.""" jsonable: MutableMapping[str, MutableJsonable] = {} if that.select is not None: try: jsonable["$select"] = that.select.value except SerializationException as exception: exception._prepend_property("select") raise try: jsonable["$condition"] = that.condition.transform(_SERIALIZER) except SerializationException as exception: exception._prepend_property("condition") raise if that.filters is not None: try: jsonable["$filters"] = _list_of__query_filter_to_jsonable(that.filters) except SerializationException as exception: exception._prepend_property("filters") raise return jsonable class _Serializer(our_types.AbstractTransformer[MutableJsonable]): """ Dispatch on the class of an instance to serialize it. The methods *are* the serializers, instead of forwarding to them, so that a dispatch costs a single call. Wherever the class of a value is already known -- which is every class without concrete descendants -- the serializer is called directly and this transformer is not involved at all. """ transform_extension = staticmethod(_extension_to_jsonable) transform_administrative_information = staticmethod( _administrative_information_to_jsonable ) transform_qualifier = staticmethod(_qualifier_to_jsonable) transform_asset_administration_shell = staticmethod( _asset_administration_shell_to_jsonable ) transform_asset_information = staticmethod(_asset_information_to_jsonable) transform_resource = staticmethod(_resource_to_jsonable) transform_specific_asset_id = staticmethod(_specific_asset_id_to_jsonable) transform_submodel = staticmethod(_submodel_to_jsonable) transform_relationship_element = staticmethod(_relationship_element_to_jsonable) transform_submodel_element_list = staticmethod(_submodel_element_list_to_jsonable) transform_submodel_element_collection = staticmethod( _submodel_element_collection_to_jsonable ) transform_property = staticmethod(_property_to_jsonable) transform_multi_language_property = staticmethod( _multi_language_property_to_jsonable ) transform_range = staticmethod(_range_to_jsonable) transform_reference_element = staticmethod(_reference_element_to_jsonable) transform_blob = staticmethod(_blob_to_jsonable) transform_file = staticmethod(_file_to_jsonable) transform_annotated_relationship_element = staticmethod( _annotated_relationship_element_to_jsonable ) transform_entity = staticmethod(_entity_to_jsonable) transform_event_payload = staticmethod(_event_payload_to_jsonable) transform_basic_event_element = staticmethod(_basic_event_element_to_jsonable) transform_operation = staticmethod(_operation_to_jsonable) transform_operation_variable = staticmethod(_operation_variable_to_jsonable) transform_capability = staticmethod(_capability_to_jsonable) transform_concept_description = staticmethod(_concept_description_to_jsonable) transform_reference = staticmethod(_reference_to_jsonable) transform_key = staticmethod(_key_to_jsonable) transform_lang_string_name_type = staticmethod(_lang_string_name_type_to_jsonable) transform_lang_string_text_type = staticmethod(_lang_string_text_type_to_jsonable) transform_environment = staticmethod(_environment_to_jsonable) transform_embedded_data_specification = staticmethod( _embedded_data_specification_to_jsonable ) transform_level_type = staticmethod(_level_type_to_jsonable) transform_value_reference_pair = staticmethod(_value_reference_pair_to_jsonable) transform_value_list = staticmethod(_value_list_to_jsonable) transform_lang_string_preferred_name_type_iec_61360 = staticmethod( _lang_string_preferred_name_type_iec_61360_to_jsonable ) transform_lang_string_short_name_type_iec_61360 = staticmethod( _lang_string_short_name_type_iec_61360_to_jsonable ) transform_lang_string_definition_type_iec_61360 = staticmethod( _lang_string_definition_type_iec_61360_to_jsonable ) transform_lang_string_uom = staticmethod(_lang_string_uom_to_jsonable) transform_definition_type_uom = staticmethod(_definition_type_uom_to_jsonable) transform_data_specification_uom = staticmethod(_data_specification_uom_to_jsonable) transform_data_specification_iec_61360 = staticmethod( _data_specification_iec_61360_to_jsonable ) transform_asset_administration_shell_descriptor = staticmethod( _asset_administration_shell_descriptor_to_jsonable ) transform_submodel_descriptor = staticmethod(_submodel_descriptor_to_jsonable) transform_endpoint = staticmethod(_endpoint_to_jsonable) transform_protocol_information = staticmethod(_protocol_information_to_jsonable) transform_security_attribute_object = staticmethod( _security_attribute_object_to_jsonable ) transform_asset_link = staticmethod(_asset_link_to_jsonable) transform_service_description = staticmethod(_service_description_to_jsonable) transform_asset_administration_shell_recent_change = staticmethod( _asset_administration_shell_recent_change_to_jsonable ) transform_concept_description_recent_change = staticmethod( _concept_description_recent_change_to_jsonable ) transform_submodel_recent_change = staticmethod(_submodel_recent_change_to_jsonable) transform_result = staticmethod(_result_to_jsonable) transform_message = staticmethod(_message_to_jsonable) transform_operation_request = staticmethod(_operation_request_to_jsonable) transform_operation_request_async = staticmethod( _operation_request_async_to_jsonable ) transform_operation_request_value_only = staticmethod( _operation_request_value_only_to_jsonable ) transform_operation_request_async_value_only = staticmethod( _operation_request_async_value_only_to_jsonable ) transform_base_operation_result = staticmethod(_base_operation_result_to_jsonable) transform_operation_result = staticmethod(_operation_result_to_jsonable) transform_operation_result_value_only = staticmethod( _operation_result_value_only_to_jsonable ) transform_operation_handle = staticmethod(_operation_handle_to_jsonable) transform_paged_result = staticmethod(_paged_result_to_jsonable) transform_paging_metadata = staticmethod(_paging_metadata_to_jsonable) transform_package_description = staticmethod(_package_description_to_jsonable) transform_property_metadata = staticmethod(_property_metadata_to_jsonable) transform_range_metadata = staticmethod(_range_metadata_to_jsonable) transform_blob_metadata = staticmethod(_blob_metadata_to_jsonable) transform_file_metadata = staticmethod(_file_metadata_to_jsonable) transform_multi_language_property_metadata = staticmethod( _multi_language_property_metadata_to_jsonable ) transform_reference_element_metadata = staticmethod( _reference_element_metadata_to_jsonable ) transform_relationship_element_metadata = staticmethod( _relationship_element_metadata_to_jsonable ) transform_annotated_relationship_element_metadata = staticmethod( _annotated_relationship_element_metadata_to_jsonable ) transform_entity_metadata = staticmethod(_entity_metadata_to_jsonable) transform_capability_metadata = staticmethod(_capability_metadata_to_jsonable) transform_operation_metadata = staticmethod(_operation_metadata_to_jsonable) transform_submodel_element_collection_metadata = staticmethod( _submodel_element_collection_metadata_to_jsonable ) transform_basic_event_element_metadata = staticmethod( _basic_event_element_metadata_to_jsonable ) transform_submodel_element_list_metadata = staticmethod( _submodel_element_list_metadata_to_jsonable ) transform_submodel_metadata = staticmethod(_submodel_metadata_to_jsonable) transform_asset_administration_shell_metadata = staticmethod( _asset_administration_shell_metadata_to_jsonable ) transform_reference_element_value = staticmethod( _reference_element_value_to_jsonable ) transform_blob_value = staticmethod(_blob_value_to_jsonable) transform_file_value = staticmethod(_file_value_to_jsonable) transform_range_value = staticmethod(_range_value_to_jsonable) transform_relationship_element_value = staticmethod( _relationship_element_value_to_jsonable ) transform_basic_event_element_value = staticmethod( _basic_event_element_value_to_jsonable ) transform_annotated_relationship_element_value = staticmethod( _annotated_relationship_element_value_to_jsonable ) transform_entity_value = staticmethod(_entity_value_to_jsonable) transform_get_asset_administration_shells_result = staticmethod( _get_asset_administration_shells_result_to_jsonable ) transform_get_asset_administration_shells_metadata_result = staticmethod( _get_asset_administration_shells_metadata_result_to_jsonable ) transform_get_all_asset_administration_shells_recent_changes_result = staticmethod( _get_all_asset_administration_shells_recent_changes_result_to_jsonable ) transform_get_asset_administration_shell_descriptors_result = staticmethod( _get_asset_administration_shell_descriptors_result_to_jsonable ) transform_get_concept_descriptions_result = staticmethod( _get_concept_descriptions_result_to_jsonable ) transform_get_all_concept_descriptions_recent_changes_result = staticmethod( _get_all_concept_descriptions_recent_changes_result_to_jsonable ) transform_get_package_descriptions_result = staticmethod( _get_package_descriptions_result_to_jsonable ) transform_get_path_items_result = staticmethod(_get_path_items_result_to_jsonable) transform_get_references_result = staticmethod(_get_references_result_to_jsonable) transform_get_submodel_descriptors_result = staticmethod( _get_submodel_descriptors_result_to_jsonable ) transform_get_submodel_elements_metadata_result = staticmethod( _get_submodel_elements_metadata_result_to_jsonable ) transform_get_submodel_elements_result = staticmethod( _get_submodel_elements_result_to_jsonable ) transform_get_submodel_elements_value_result = staticmethod( _get_submodel_elements_value_result_to_jsonable ) transform_get_all_submodels_recent_changes_result = staticmethod( _get_all_submodels_recent_changes_result_to_jsonable ) transform_get_submodels_metadata_result = staticmethod( _get_submodels_metadata_result_to_jsonable ) transform_get_submodels_result = staticmethod(_get_submodels_result_to_jsonable) transform_get_submodels_value_result = staticmethod( _get_submodels_value_result_to_jsonable ) transform_claim_attribute = staticmethod(_claim_attribute_to_jsonable) transform_global_attribute = staticmethod(_global_attribute_to_jsonable) transform_reference_attribute = staticmethod(_reference_attribute_to_jsonable) transform_date_time_attribute_item = staticmethod( _date_time_attribute_item_to_jsonable ) transform_field_operand = staticmethod(_field_operand_to_jsonable) transform_string_literal = staticmethod(_string_literal_to_jsonable) transform_attribute_operand = staticmethod(_attribute_operand_to_jsonable) transform_number_literal = staticmethod(_number_literal_to_jsonable) transform_hex_literal = staticmethod(_hex_literal_to_jsonable) transform_date_time_literal = staticmethod(_date_time_literal_to_jsonable) transform_time_literal = staticmethod(_time_literal_to_jsonable) transform_boolean_literal = staticmethod(_boolean_literal_to_jsonable) transform_string_cast = staticmethod(_string_cast_to_jsonable) transform_number_cast = staticmethod(_number_cast_to_jsonable) transform_hex_cast = staticmethod(_hex_cast_to_jsonable) transform_boolean_cast = staticmethod(_boolean_cast_to_jsonable) transform_date_time_cast = staticmethod(_date_time_cast_to_jsonable) transform_time_cast = staticmethod(_time_cast_to_jsonable) transform_day_of_week = staticmethod(_day_of_week_to_jsonable) transform_day_of_month = staticmethod(_day_of_month_to_jsonable) transform_month = staticmethod(_month_to_jsonable) transform_year = staticmethod(_year_to_jsonable) transform_date_time_attribute_operand = staticmethod( _date_time_attribute_operand_to_jsonable ) transform_equal_comparison = staticmethod(_equal_comparison_to_jsonable) transform_not_equal_comparison = staticmethod(_not_equal_comparison_to_jsonable) transform_greater_than_comparison = staticmethod( _greater_than_comparison_to_jsonable ) transform_greater_than_or_equal_comparison = staticmethod( _greater_than_or_equal_comparison_to_jsonable ) transform_less_than_comparison = staticmethod(_less_than_comparison_to_jsonable) transform_less_than_or_equal_comparison = staticmethod( _less_than_or_equal_comparison_to_jsonable ) transform_contains_comparison = staticmethod(_contains_comparison_to_jsonable) transform_starts_with_comparison = staticmethod(_starts_with_comparison_to_jsonable) transform_ends_with_comparison = staticmethod(_ends_with_comparison_to_jsonable) transform_regex_comparison = staticmethod(_regex_comparison_to_jsonable) transform_match_clause = staticmethod(_match_clause_to_jsonable) transform_and_expression = staticmethod(_and_expression_to_jsonable) transform_or_expression = staticmethod(_or_expression_to_jsonable) transform_not_expression = staticmethod(_not_expression_to_jsonable) transform_query_filter = staticmethod(_query_filter_to_jsonable) transform_query = staticmethod(_query_to_jsonable) _SERIALIZER = _Serializer()
[docs]def to_jsonable(that: our_types.Class) -> MutableJsonable: """ Convert :paramref:`that` to a JSON-able structure. :param that: Model instance to be recursively converted to a JSON-able structure :return: JSON-able structure which can be further encoded with, *e.g.*, :py:mod:`json` :raise: :py:class:`SerializationException` if :paramref:`that` contains a number which JSON can not represent """ return that.transform(_SERIALIZER)
# endregion # This code has been automatically generated by aas-core-codegen. # Do NOT edit or append.