50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Literal
|
||
|
|
from uuid import UUID
|
||
|
|
|
||
|
|
from pydantic import Field
|
||
|
|
|
||
|
|
from .common import ApiEnvelope, RouteContract, SchemaModel
|
||
|
|
|
||
|
|
HTTP_METHOD = 'POST'
|
||
|
|
ROUTE_PATH = '/api/irrigation/recommend/'
|
||
|
|
|
||
|
|
|
||
|
|
class IrrigationRecommendRequest(SchemaModel):
|
||
|
|
farm_uuid: UUID
|
||
|
|
sensor_uuid: UUID | None = None
|
||
|
|
plant_name: str | None = None
|
||
|
|
growth_stage: str | None = None
|
||
|
|
irrigation_method_name: str | None = None
|
||
|
|
query: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class IrrigationSection(SchemaModel):
|
||
|
|
type: Literal['recommendation', 'list', 'warning', 'info']
|
||
|
|
title: str
|
||
|
|
icon: str | None = None
|
||
|
|
content: str | None = None
|
||
|
|
items: list[str] = Field(default_factory=list)
|
||
|
|
frequency: str | None = None
|
||
|
|
amount: str | None = None
|
||
|
|
timing: str | None = None
|
||
|
|
validityPeriod: str | None = None
|
||
|
|
expandableExplanation: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class IrrigationRecommendResponseData(SchemaModel):
|
||
|
|
sections: list[IrrigationSection] = Field(default_factory=list)
|
||
|
|
|
||
|
|
|
||
|
|
class IrrigationRecommendResponse(ApiEnvelope[IrrigationRecommendResponseData]):
|
||
|
|
pass
|
||
|
|
|
||
|
|
|
||
|
|
CONTRACT = RouteContract(
|
||
|
|
method=HTTP_METHOD,
|
||
|
|
path=ROUTE_PATH,
|
||
|
|
request_model=IrrigationRecommendRequest.__name__,
|
||
|
|
response_model=IrrigationRecommendResponse.__name__,
|
||
|
|
)
|