Coverage for filip/models/ngsi_ld/base.py: 100%
9 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-02-19 11:48 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-02-19 11:48 +0000
1from typing import Union, Optional
2from pydantic import BaseModel, Field, ConfigDict
5class GeoQuery(BaseModel):
6 """
7 GeoQuery used for Subscriptions, as described in NGSI-LD Spec section 5.2.13
8 """
10 geometry: str = Field(
11 description="A valid GeoJSON [8] geometry, type excepting GeometryCollection"
12 )
13 coordinates: Union[list, str] = Field(
14 description="A JSON Array coherent with the geometry type as per "
15 "IETF RFC 7946 [8]"
16 )
17 georel: str = Field(
18 description="A valid geo-relationship as defined by clause 4.10 (near, "
19 "within, etc.)"
20 )
21 geoproperty: Optional[str] = Field(
22 default=None, description="Attribute Name as a short-hand string"
23 )
24 model_config = ConfigDict(populate_by_name=True)
27def validate_ngsi_ld_query(q: str) -> str:
28 """
29 Valid query string as described in NGSI-LD Spec section 5.2.12
30 Args:
31 q: query string
32 Returns:
34 """
35 return q