python
This commit is contained in:
59
custom_components/yandex_smart_home/schema/response.py
Normal file
59
custom_components/yandex_smart_home/schema/response.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""Schema for an API response for Yandex Smart Home."""
|
||||
|
||||
from __future__ import annotations
|
||||
from enum import StrEnum
|
||||
from typing import Optional, Any, Dict, Literal
|
||||
from .base import APIModel
|
||||
|
||||
|
||||
class ResponseCode(StrEnum):
|
||||
"""Response code."""
|
||||
|
||||
DOOR_OPEN = "DOOR_OPEN"
|
||||
LID_OPEN = "LID_OPEN"
|
||||
REMOTE_CONTROL_DISABLED = "REMOTE_CONTROL_DISABLED"
|
||||
NOT_ENOUGH_WATER = "NOT_ENOUGH_WATER"
|
||||
LOW_CHARGE_LEVEL = "LOW_CHARGE_LEVEL"
|
||||
CONTAINER_FULL = "CONTAINER_FULL"
|
||||
CONTAINER_EMPTY = "CONTAINER_EMPTY"
|
||||
DRIP_TRAY_FULL = "DRIP_TRAY_FULL"
|
||||
DEVICE_STUCK = "DEVICE_STUCK"
|
||||
DEVICE_OFF = "DEVICE_OFF"
|
||||
FIRMWARE_OUT_OF_DATE = "FIRMWARE_OUT_OF_DATE"
|
||||
NOT_ENOUGH_DETERGENT = "NOT_ENOUGH_DETERGENT"
|
||||
HUMAN_INVOLVEMENT_NEEDED = "HUMAN_INVOLVEMENT_NEEDED"
|
||||
DEVICE_UNREACHABLE = "DEVICE_UNREACHABLE"
|
||||
DEVICE_BUSY = "DEVICE_BUSY"
|
||||
INTERNAL_ERROR = "INTERNAL_ERROR"
|
||||
INVALID_ACTION = "INVALID_ACTION"
|
||||
INVALID_VALUE = "INVALID_VALUE"
|
||||
NOT_SUPPORTED_IN_CURRENT_MODE = "NOT_SUPPORTED_IN_CURRENT_MODE"
|
||||
ACCOUNT_LINKING_ERROR = "ACCOUNT_LINKING_ERROR"
|
||||
DEVICE_NOT_FOUND = "DEVICE_NOT_FOUND"
|
||||
|
||||
|
||||
class ResponsePayload(APIModel):
|
||||
"""Base class for an API response payload."""
|
||||
|
||||
|
||||
class Error(ResponsePayload):
|
||||
"""Error payload."""
|
||||
error_code: ResponseCode
|
||||
error_message: Optional[str] = None
|
||||
|
||||
|
||||
class SuccessActionResult(APIModel):
|
||||
"""Represents a successful action result."""
|
||||
status: Literal["DONE"] = "DONE"
|
||||
|
||||
|
||||
class FailedActionResult(APIModel):
|
||||
"""Represents a failed action result."""
|
||||
status: Literal["ERROR"] = "ERROR"
|
||||
error_code: ResponseCode
|
||||
|
||||
|
||||
class Response(APIModel):
|
||||
"""Base API response."""
|
||||
request_id: Optional[str] = None
|
||||
payload: Optional[Dict[str, Any]] = None
|
||||
Reference in New Issue
Block a user