"""
Shared data models
"""
from aenum import Enum
from pydantic import ConfigDict, BaseModel, Field, field_validator
from filip.utils.validators import (validate_fiware_service_path,
validate_fiware_service)
[docs]class NgsiVersion(str, Enum):
"""
Version of NGSI-Specification that should be used within the target system.
Note:
Currently, the library only supports functionality for NGSI-v2
"""
v2 = "v2"
ld = "ld"
[docs]class DataType(str, Enum):
"""
When possible reuse schema.org data types
(Text, Number, DateTime, StructuredValue, etc.).
Remember that null is not allowed in NGSI-LD and
therefore should be avoided as a value.
https://schema.org/DataType
"""
_init_ = "value __doc__"
BOOLEAN = "Boolean", "True or False."
DATE = "Date", "A date value in ISO 8601 date format."
DATETIME = (
"DateTime",
"A combination of date and time of day in the form "
"[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] "
"(see Chapter 5.4 of ISO 8601).",
)
NUMBER = (
"Number",
"Use values from 0123456789 (Unicode 'DIGIT ZERO' "
"(U+0030) to 'DIGIT NINE' (U+0039)) rather than "
"superficially similar Unicode symbols. Use '.' "
"(Unicode 'FULL STOP' (U+002E)) rather than ',' to "
"indicate a decimal point. Avoid using these symbols "
"as a readability separator.",
)
INTEGER = "Integer", "Integer number"
FLOAT = "Float", "Floating number. Please check 'DataType.Number'"
TEXT = "Text", "https://schema.org/Text"
TIME = (
"Time",
"A point in time recurring on multiple days in the form "
"hh:mm:ss[Z|(+|-)hh:mm] (see XML schema for details).",
)
RELATIONSHIP = "Relationship", "Reference to another context entity"
STRUCTUREDVALUE = "StructuredValue", ("Structured datatype must be an "
"array or object"
"serializable")
ARRAY = "Array", "Array of the types above"
OBJECT = "Object", "JSON-Object of the types above, i.e. a dictionary"
COMMAND = "command", "A command for IoT Devices"
COMMAND_RESULT = (
"commandResult",
"An entity containing a command, "
"contains an autogenerated attribute"
"of this type",
)
COMMAND_STATUS = (
"commandStatus",
"An entity containing a command, "
"contains an autogenerated attribute "
"of this type",
)
GEOJSON = "geo:json", "GeoJson object"
[docs]class LogLevel(str, Enum):
CRITICAL = "CRITICAL"
ERROR = "ERROR"
WARNING = "WARNING"
INFO = "INFO"
DEBUG = "DEBUG"
NOTSET = "NOTSET"
@classmethod
def _missing_name_(cls, name):
"""
Class method to realize case-insensitive args
Args:
name: missing argument
Returns:
valid member of enum
"""
for member in cls:
if member.value.casefold() == name.casefold():
return member