from typing import Any


class GetFaceRecognitionStatusCmd:
    id = "getFaceRecogStatus"
    camera : str|None
    stream_url : str|None

    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.stream_url = request.get("stream_url", None)
        
    isvalid = property(lambda self: self.camera is not None and self.stream_url is not None)

class GetFaceRecognitionStatusResponse:
    id = "faceRecogStatus"
    camera : str
    stream_url : str
    facerecog_status : str
    status : str
    message : str
    
    def __init__(self, camera:str, stream_url:str, facerecog_status:str, status:str, message:str):
        self.camera = camera
        self.stream_url = stream_url
        self.facerecog_status = facerecog_status
        self.status = status
        self.message = message
    
    toDict = property(lambda self: {
        "id": self.id,
        "camera": self.camera,
        "stream_url": self.stream_url,
        "facerecog_status": self.facerecog_status,
        "status": self.status,
        "message": self.message
    })

class StartFaceRecogCmd:
    id = "startFaceRecog"
    camera : str|None
    stream_url : str|None
    detector : str|None

    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.stream_url = request.get("stream_url", None)
        self.detector = request.get("detector", None)
    
    isvalid = property(lambda self: self.camera is not None and self.stream_url is not None and self.detector is not None)

class StartFaceRecogResponse:
    id = "faceRecogStarted"
    camera: str
    stream_url: str
    status: str
    message: str
    detector: str
    
    def __init__(self, camera:str, stream_url:str, status:str, message:str, detector:str):
        self.camera = camera
        self.stream_url = stream_url
        self.status = status
        self.message = message
        self.detector = detector
        
    toDict = property(lambda self: {
        "id": self.id,
        "camera": self.camera,
        "stream_url": self.stream_url,
        "status": self.status,
        "message": self.message,
        "detector": self.detector
    })

class Resolution:
    width: int
    height: int
    
    def __init__(self, width:int, height:int):
        self.width = width
        self.height = height

class FaceData:
    x: int
    y: int
    w: int
    h: int
    
    def __init__(self, x:int, y:int, w:int, h:int):
        self.x = x
        self.y = y
        self.w = w
        self.h = h

class FaceRecognitionData:
    id = "facerecogData"
    stream_url : str
    camera : str
    resolution: Resolution
    data: list[FaceData]
    
    def __init__(self, stream_url:str, camera:str, resolution:Resolution, data:list[FaceData]):
        self.stream_url = stream_url
        self.camera = camera
        self.resolution = resolution
        self.data = data
        
    toDict = property(lambda self: {
        "id": self.id,
        "stream_url": self.stream_url,
        "camera": self.camera,
        "resolution": {"width": self.resolution.width, "height": self.resolution.height},
        "data": [fd.__dict__ for fd in self.data]
    })

class StopFaceRecogCmd:
    id = "stopFaceRecog"
    camera : str|None
    stream_url : str|None

    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.stream_url = request.get("stream_url", None)
    
    isvalid = property(lambda self: self.camera is not None and self.stream_url is not None)

class StopFaceRecogResponse:
    id = "faceRecogStopped"
    camera: str
    stream_url: str
    status: str
    message: str
    
    def __init__(self, camera:str, stream_url:str, status:str, message:str):
        self.camera = camera
        self.stream_url = stream_url
        self.status = status
        self.message = message
        
    toDict = property(lambda self: {
        "id": self.id,
        "camera": self.camera,
        "stream_url": self.stream_url,
        "status": self.status,
        "message": self.message
    })
    
class GetCameraStatusCmd :
    id = 'getCameraStatus'
    camera: str|None
    network: str|None
    
    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.network = request.get("network", None)
        
    isvalid = property(lambda self: self.camera is not None and self.network is not None)

class CameraStatusResponse:
    id = 'cameraStatus'
    camera: str
    network: str
    on_air: bool
    preview: bool
    status: str
    message: str
    
    def __init__(self, camera:str, network:str, on_air:bool, preview:bool, status:str, message:str):
        self.camera = camera
        self.network = network
        self.on_air = on_air
        self.preview = preview
        self.status = status
        self.message = message
        
    toDict = property(lambda self: {
        "id": self.id,
        "camera": self.camera,
        "network": self.network,
        "on_air": self.on_air,
        "preview": self.preview,
        "status": self.status,
        "message": self.message
    })

class SetCameraOnAirCmd:
    id = 'setCameraOnAir'
    camera: str|None
    network: str|None
    on_air: bool|None

    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.network = request.get("network", None)
        self.on_air = request.get("on_air", None)

    isvalid = property(lambda self: self.camera is not None and self.network is not None and self.on_air is not None)
    
class SetCameraPreviewCmd:
    id = 'setCameraPreview'
    camera: str|None
    network: str|None
    preview: bool|None

    def __init__(self, request: dict[str, Any]):
        self.camera = request.get("camera", None)
        self.network = request.get("network", None)
        self.preview = request.get("preview", None)
        
    isvalid = property(lambda self: self.camera is not None and self.network is not None and self.preview is not None)
