Skip to content

Commit

Permalink
Draft version of pydantic file v2
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoabellagarcia committed Aug 17, 2024
1 parent 49fc2c2 commit d22b787
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions MeasurementTimePeriod/code/code_for_using_pydantic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from __future__ import annotations

from enum import Enum
from typing import Optional, Union

from pydantic import AnyUrl, BaseModel, Field, constr


class Type(Enum):
MeasurementTimePeriod = 'MeasurementTimePeriod'


class MeasurementTimePeriod(BaseModel):
EndTime: Optional[str] = Field(
None,
description='The date and time at the end of the time period over which a Measurement is taken. Date time should be UTC, compliant with ISO 8601 format (e.g. 2023-04-20T11:54:59Z)',
)
id: Optional[
Union[
constr(
pattern=r'^[\\w\\-\\.\\{\\}\\$\\+\\*\\[\\]`|~^@!, :\\\\]+$',
min_length=1,
max_length=256,
),
AnyUrl,
]
] = Field(None, description='Unique identifier of the entity')
type: Optional[Type] = Field(
None, description='It must be equal to MeasurementTimePeriod.'
)

0 comments on commit d22b787

Please sign in to comment.