36 lines
865 B
Python
36 lines
865 B
Python
from __future__ import annotations
|
|
|
|
from typing import Literal
|
|
from uuid import UUID
|
|
|
|
from pydantic import Field
|
|
|
|
from .common import ApiEnvelope, JsonObject, RouteContract, SchemaModel
|
|
|
|
HTTP_METHOD = 'POST'
|
|
ROUTE_PATH = '/api/irrigation/water-stress/'
|
|
|
|
|
|
class IrrigationWaterStressRequest(SchemaModel):
|
|
farm_uuid: UUID
|
|
sensor_uuid: UUID | None = None
|
|
|
|
|
|
class IrrigationWaterStressResponseData(SchemaModel):
|
|
farm_uuid: str
|
|
waterStressIndex: int | float
|
|
level: Literal['low', 'medium', 'high'] | str
|
|
sourceMetric: JsonObject = Field(default_factory=dict)
|
|
|
|
|
|
class IrrigationWaterStressResponse(ApiEnvelope[IrrigationWaterStressResponseData]):
|
|
pass
|
|
|
|
|
|
CONTRACT = RouteContract(
|
|
method=HTTP_METHOD,
|
|
path=ROUTE_PATH,
|
|
request_model=IrrigationWaterStressRequest.__name__,
|
|
response_model=IrrigationWaterStressResponse.__name__,
|
|
)
|