-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f96b261
commit 8525a27
Showing
1 changed file
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import List, Optional, Union | ||
|
||
from pydantic import AnyUrl, BaseModel, Field, RootModel, constr | ||
|
||
|
||
class Address(BaseModel): | ||
addressCountry: Optional[str] = Field( | ||
None, description='The country. For example, Spain' | ||
) | ||
addressLocality: Optional[str] = Field( | ||
None, | ||
description='The locality in which the street address is, and which is in the region', | ||
) | ||
addressRegion: Optional[str] = Field( | ||
None, | ||
description='The region in which the locality is, and which is in the country', | ||
) | ||
district: Optional[str] = Field( | ||
None, | ||
description='A district is a type of administrative division that, in some countries, is managed by the local government', | ||
) | ||
postOfficeBoxNumber: Optional[str] = Field( | ||
None, | ||
description='The post office box number for PO box addresses. For example, 03578', | ||
) | ||
postalCode: Optional[str] = Field( | ||
None, description='The postal code. For example, 24004' | ||
) | ||
streetAddress: Optional[str] = Field(None, description='The street address') | ||
streetNr: Optional[str] = Field( | ||
None, description='Number identifying a specific property on a public street' | ||
) | ||
|
||
|
||
class Type(Enum): | ||
Point = 'Point' | ||
|
||
|
||
class Location(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[float] = Field(..., min_length=2) | ||
type: Type | ||
|
||
|
||
class Coordinate(RootModel[List[float]]): | ||
root: List[float] | ||
|
||
|
||
class Type1(Enum): | ||
LineString = 'LineString' | ||
|
||
|
||
class Location1(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[Coordinate] = Field(..., min_length=2) | ||
type: Type1 | ||
|
||
|
||
class Type2(Enum): | ||
Polygon = 'Polygon' | ||
|
||
|
||
class Location2(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[List[Coordinate]] | ||
type: Type2 | ||
|
||
|
||
class Type3(Enum): | ||
MultiPoint = 'MultiPoint' | ||
|
||
|
||
class Location3(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[List[float]] | ||
type: Type3 | ||
|
||
|
||
class Type4(Enum): | ||
MultiLineString = 'MultiLineString' | ||
|
||
|
||
class Location4(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[List[Coordinate]] | ||
type: Type4 | ||
|
||
|
||
class Type5(Enum): | ||
MultiPolygon = 'MultiPolygon' | ||
|
||
|
||
class Location5(BaseModel): | ||
bbox: Optional[List[float]] = Field(None, min_length=4) | ||
coordinates: List[List[List[Coordinate]]] | ||
type: Type5 | ||
|
||
|
||
class Type6(Enum): | ||
DataService = 'DataService' | ||
|
||
|
||
class DataService(BaseModel): | ||
accessRights: Optional[str] = Field( | ||
None, | ||
description='This property MAY include information regarding access or restrictions based on privacy, security, or other policies', | ||
) | ||
address: Optional[Address] = Field(None, description='The mailing address') | ||
areaServed: Optional[str] = Field( | ||
None, | ||
description='The geographic area where a service or offered item is provided', | ||
) | ||
description: Optional[List[str]] = Field( | ||
None, | ||
description='This property contains a free-text account of the Data Service. This property can be repeated for parallel language versions of the description', | ||
) | ||
endPointDescription: Optional[List[str]] = Field( | ||
None, | ||
description='This property contains a description of the services available via the end-points, including their operations, parameters etc. The property gives specific details of the actual endpoint instances, while dct:conformsTo is used to indicate the general standard or specification that the endpoints implement', | ||
) | ||
endPointURL: Optional[List[AnyUrl]] = Field( | ||
None, | ||
description='The root location or primary endpoint of the service (an IRI)', | ||
) | ||
id: Optional[ | ||
Union[ | ||
constr( | ||
pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!, :\\\\]+$', | ||
min_length=1, | ||
max_length=256, | ||
), | ||
AnyUrl, | ||
] | ||
] = Field(None, description='Unique identifier of the entity') | ||
license: Optional[str] = Field( | ||
None, | ||
description='This property contains the licence under which the Data service is made available', | ||
) | ||
location: Optional[ | ||
Union[Location, Location1, Location2, Location3, Location4, Location5] | ||
] = Field( | ||
None, | ||
description='Geojson reference to the item. It can be Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon', | ||
) | ||
servesDataset: Optional[List[str]] = Field( | ||
None, | ||
description='This property refers to a collection of data that this data service can distribute', | ||
) | ||
title: Optional[List[str]] = Field( | ||
None, | ||
description='This property contains a name given to the Data Service. This property can be repeated for parallel language versions of the name', | ||
) | ||
type: Optional[Type6] = Field( | ||
None, description='NGSI Entity type. It has to be DataService' | ||
) |