diff --git a/src/edr_pydantic_classes/collections.py b/src/edr_pydantic_classes/collections.py new file mode 100644 index 0000000..d78d1e3 --- /dev/null +++ b/src/edr_pydantic_classes/collections.py @@ -0,0 +1,43 @@ +from __future__ import annotations + +from typing import List +from typing import Optional + +from .data_queries import DataQueries +from .extent import Extent +from .link import Link +from .my_base_model import EDRBaseModel +from .parameter import ParameterNames + + +# TODO instances or collections as base? +class Collection(EDRBaseModel): + links: List[Link] + id: str + extent: Extent + parameter_names: ParameterNames + title: Optional[str] = None + description: Optional[str] = None + keywords: Optional[List[str]] = None + data_queries: Optional[DataQueries] = None + # TODO required according to A.13, string array or crs object? + crs: Optional[List[str]] = None + # TODO in req as f? + output_formats: Optional[List[str]] = None + # TODO may have distanceunits, if radius is in link, it shall have distanceunits + distanceunits: Optional[List[str]] = None + + +class CollectionsModel(EDRBaseModel): + links: List[Link] + collections: List[Collection] + + +class InstancesModel(EDRBaseModel): + links: List[Link] + instances: List[Instance] + + +# For now, the instance metadata corresponds to the first collection metadata. So they have equal classes +class Instance(Collection): + pass diff --git a/src/edr_pydantic_classes/instances.py b/src/edr_pydantic_classes/instances.py deleted file mode 100644 index 85682b7..0000000 --- a/src/edr_pydantic_classes/instances.py +++ /dev/null @@ -1,107 +0,0 @@ -# generated by datamodel-codegen: -# filename: https://schemas.opengis.net/ogcapi/edr/1.0/openapi/schemas/instances.yaml -# timestamp: 2022-06-29T09:43:11+00:00 -from __future__ import annotations - -from datetime import datetime -from enum import Enum -from typing import Dict -from typing import List -from typing import Optional -from typing import Union - -from .generic_models import CubeVariables -from .generic_models import Link -from .generic_models import Variables -from .my_base_model import MyBaseModel -from .parameter import Parameter - - -class CRSOptions(str, Enum): - wgs84 = "WGS84" - - -class Spatial(MyBaseModel): - bbox: List[List[float]] - crs: CRSOptions - name: Optional[str] = None - - -class Temporal(MyBaseModel): - interval: List[List[datetime]] - values: List[str] - trs: str - name: Optional[str] = None - - -class Vertical(MyBaseModel): - interval: List[List[float]] - vrs: str - name: Optional[str] = None - - -class Extent(MyBaseModel): - spatial: Optional[Spatial] = None - temporal: Optional[Temporal] = None - vertical: Optional[Vertical] = None - - -class DataQueryLink(MyBaseModel): - model_config = { - "json_schema_extra": { - "examples": [ - { - "href": "https://data.example.com/collections/monitoringsites/locations", - "rel": "alternate", - "hreflang": "en", - } - ], - } - } - href: str - hreflang: Optional[str] = None - rel: str - variables: Union[Variables, CubeVariables] - - -class DataQuery(MyBaseModel): - link: DataQueryLink - - -class DataQueries(MyBaseModel): - position: Optional[DataQuery] = None - radius: Optional[DataQuery] = None - area: Optional[DataQuery] = None - cube: Optional[DataQuery] = None - trajectory: Optional[DataQuery] = None - corridor: Optional[DataQuery] = None - locations: Optional[DataQuery] = None - items: Optional[DataQuery] = None - - -class Instance(MyBaseModel): - links: List[Link] - id: str - title: Optional[str] = None - description: Optional[str] = None - keywords: Optional[List[str]] = None - extent: Extent - data_queries: Optional[DataQueries] = None - crs: Optional[List[str]] = None - output_formats: Optional[List[str]] = None - parameter_names: Optional[Dict[str, Parameter]] = None - - -class InstancesModel(MyBaseModel): - links: List[Link] - instances: List[Instance] - - -# For now, the collection metadata corresponds to the first instance metadata. So they have equal classes -class Collection(Instance): - pass - - -class CollectionsModel(MyBaseModel): - links: List[Link] - collections: List[Collection]