# coding: utf-8

from typing import Dict, List  # noqa: F401

from fastapi import (  # noqa: F401
    APIRouter,
    Body,
    Cookie,
    Depends,
    Form,
    Header,
    Path,
    Query,
    Response,
    Security,
    status,
)

from ecp4_msi_api_fast.models.extra_models import TokenModel  # noqa: F401
from ecp4_msi_api_fast.models.error_response import ErrorResponse
from ecp4_msi_api_fast.models.i2_c_device import I2CDevice
from ecp4_msi_api_fast.models.i2c_device_control import I2cDeviceControl
from ecp4_msi_api_fast.models.i2c_device_data import I2cDeviceData


router = APIRouter(prefix="http://localhost:9292/v1")


@router.get(
    "/i2c/{address}",
    responses={
        200: {"model": I2cDeviceData, "description": "I2C data retrieved successfully"},
        400: {"model": ErrorResponse, "description": "Bad Request - Invalid input or missing parameters"},
        404: {"model": ErrorResponse, "description": "Bad Request - Entity was not found"},
        500: {"model": ErrorResponse, "description": "Internal Server Error - Unexpected server issue"},
    },
    tags=["i2c"],
    summary="Retrieve data from an I2C device",
    response_model_by_alias=True,
)
async def get_i2c_data(
    address: str
 = Path(..., description="I2C device address (e.g., 0x1A).", regex=r"^0x[0-9A-Fa-f]{2}$")
,
) -> I2cDeviceData:
    """Get data from a specific I2C address."""
    ...


@router.get(
    "/i2c",
    responses={
        200: {"model": List[I2CDevice], "description": "I2C devices retrieved successfully"},
        500: {"model": ErrorResponse, "description": "Internal Server Error - Unexpected server issue"},
    },
    tags=["i2c"],
    summary="List I2C devices",
    response_model_by_alias=True,
)
async def get_i2c_devices(
) -> List[I2CDevice]:
    """Retrieve a list of all valid I2C addresses."""
    ...


@router.post(
    "/i2c/{address}",
    responses={
        200: {"model": I2cDeviceControl, "description": "I2c data updated successfully"},
        400: {"model": ErrorResponse, "description": "Bad Request - Invalid input or missing parameters"},
        404: {"model": ErrorResponse, "description": "Bad Request - Entity was not found"},
        500: {"model": ErrorResponse, "description": "Internal Server Error - Unexpected server issue"},
    },
    tags=["i2c"],
    summary="Update data for a i2c device.",
    response_model_by_alias=True,
)
async def update_i2c_data(
    address: str
 = Path(..., description="I2C device address (e.g., 0x1A).", regex=r"^0x[0-9A-Fa-f]{2}$")
,
    i2c_device_control: I2cDeviceControl
 = Body(..., description="")
,
) -> I2cDeviceControl:
    """Modify the data for a specific i2c device."""
    ...
