Skip to content

Commit 26c5cc3

Browse files
Add Range Schema classes
1 parent 152baa0 commit 26c5cc3

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

conSys/datamodels/swe_components.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
from conSys import GeometryTypes
99
from conSys.datamodels.api_utils import UCUMCode, URI
1010

11+
"""
12+
NOTE: The following classes are used to represent the Record Schemas that are required for use with Datastreams
13+
The names are likely to change to include a "Schema" suffix to differentiate them from the actual data structures.
14+
The current scope of the project likely excludes conversion from received data to actual SWE Common data structures,
15+
in the event this is added it will most likely be in a separate module as those structures have use cases outside of
16+
the API solely
17+
"""
18+
19+
20+
# TODO: Add field validators that are missing
21+
# TODO: valid string fields that are intended to represent time/date values
22+
# TODO: Validate places where string fields are not allowed to be empty
23+
1124

1225
class AnyComponent(BaseModel):
1326
id: str = Field(None)
@@ -75,7 +88,7 @@ class Geometry(AnyComponent):
7588
value = Field(None)
7689

7790

78-
class AnyScalarComponent(AnyComponent):
91+
class AnySimpleComponent(AnyComponent):
7992
label: str = Field(...)
8093
description = Field(None)
8194
type: str = Field(...)
@@ -91,6 +104,13 @@ class AnyScalarComponent(AnyComponent):
91104
value = Field(None)
92105

93106

107+
class AnyScalarComponent(AnySimpleComponent):
108+
"""
109+
A base class for all scalar components. The structure is essentially that of AnySimpleComponent
110+
"""
111+
pass
112+
113+
94114
class Boolean(AnyScalarComponent):
95115
type: str = "Boolean"
96116
value: bool = Field(None)
@@ -142,3 +162,29 @@ class Category(AnyScalarComponent):
142162
class Text(AnyScalarComponent):
143163
type: str = "Text"
144164
value: str = Field(None)
165+
166+
167+
class CountRange(AnySimpleComponent):
168+
type: str = "CountRange"
169+
value: list[int] = Field(None)
170+
uom: Union[UCUMCode, URI] = Field(...)
171+
172+
173+
class QuantityRange(AnySimpleComponent):
174+
type: str = "QuantityRange"
175+
value: list[Union[Real, str]] = Field(None)
176+
uom: Union[UCUMCode, URI] = Field(...)
177+
178+
179+
class TimeRange(AnySimpleComponent):
180+
type: str = "TimeRange"
181+
value: list[str] = Field(None)
182+
reference_time: str = Field(None, serialization_alias='referenceTime')
183+
local_frame: str = Field(None)
184+
uom: Union[UCUMCode, URI] = Field(...)
185+
186+
187+
class CategoryRange(AnySimpleComponent):
188+
type: str = "CategoryRange"
189+
value: list[str] = Field(None)
190+
code_space: str = Field(None, serialization_alias='codeSpace')

0 commit comments

Comments
 (0)