"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.

This domain allows configuring virtual Bluetooth devices to test
the web-bluetooth API.
https://chromedevtools.github.io/devtools-protocol/tot/BluetoothEmulation/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    BluetoothEmulation,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class EnableInput(InputModel):

    state: BluetoothEmulation.CentralState
    leSupported: bool


class Enable(CDPMethod[None]):
    """ Enable the BluetoothEmulation domain. """

    INPUT_VALIDATOR = EnableInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        state: BluetoothEmulation.CentralState,
        le_supported: bool
    ):
        super().__init__(
            state=state,
            leSupported=le_supported
        )


class SetSimulatedCentralStateInput(InputModel):

    state: BluetoothEmulation.CentralState


class SetSimulatedCentralState(CDPMethod[None]):
    """ Set the state of the simulated central. """

    INPUT_VALIDATOR = SetSimulatedCentralStateInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        state: BluetoothEmulation.CentralState
    ):
        super().__init__(
            state=state
        )


class Disable(CDPMethod[None]):
    """ Disable the BluetoothEmulation domain. """

    INPUT_VALIDATOR = None
    OUTPUT_VALIDATOR = None


class SimulatePreconnectedPeripheralInput(InputModel):

    address: str
    name: str
    manufacturerData: list[BluetoothEmulation.ManufacturerData]
    knownServiceUuids: list[str]


class SimulatePreconnectedPeripheral(CDPMethod[None]):
    """ Simulates a peripheral with |address|, |name| and |knownServiceUuids|
    that has already been connected to the system. """

    INPUT_VALIDATOR = SimulatePreconnectedPeripheralInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        address: str,
        name: str,
        manufacturer_data: list[BluetoothEmulation.ManufacturerData],
        known_service_uuids: list[str]
    ):
        super().__init__(
            address=address,
            name=name,
            manufacturerData=manufacturer_data,
            knownServiceUuids=known_service_uuids
        )


class SimulateAdvertisementInput(InputModel):

    entry: BluetoothEmulation.ScanEntry


class SimulateAdvertisement(CDPMethod[None]):
    """ Simulates an advertisement packet described in |entry| being received by
    the central. """

    INPUT_VALIDATOR = SimulateAdvertisementInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        entry: BluetoothEmulation.ScanEntry
    ):
        super().__init__(
            entry=entry
        )


class SimulateGATTOperationResponseInput(InputModel):

    address: str
    type: BluetoothEmulation.GATTOperationType
    code: int


class SimulateGATTOperationResponse(CDPMethod[None]):
    """ Simulates the response code from the peripheral with |address| for a
    GATT operation of |type|. The |code| value follows the HCI Error Codes from
    Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes. """

    INPUT_VALIDATOR = SimulateGATTOperationResponseInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        address: str,
        type_: BluetoothEmulation.GATTOperationType,
        code: int
    ):
        super().__init__(
            address=address,
            type=type_,
            code=code
        )


class SimulateCharacteristicOperationResponseInput(InputModel):

    characteristicId: str
    type: BluetoothEmulation.CharacteristicOperationType
    code: int
    data: str | None = None


class SimulateCharacteristicOperationResponse(CDPMethod[None]):
    """ Simulates the response from the characteristic with |characteristicId| for a
    characteristic operation of |type|. The |code| value follows the Error
    Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
    The |data| is expected to exist when simulating a successful read operation
    response. """

    INPUT_VALIDATOR = SimulateCharacteristicOperationResponseInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        characteristic_id: str,
        type_: BluetoothEmulation.CharacteristicOperationType,
        code: int,
        data: str | None = None
    ):
        super().__init__(
            characteristicId=characteristic_id,
            type=type_,
            code=code,
            data=data
        )


class SimulateDescriptorOperationResponseInput(InputModel):

    descriptorId: str
    type: BluetoothEmulation.DescriptorOperationType
    code: int
    data: str | None = None


class SimulateDescriptorOperationResponse(CDPMethod[None]):
    """ Simulates the response from the descriptor with |descriptorId| for a
    descriptor operation of |type|. The |code| value follows the Error
    Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.
    The |data| is expected to exist when simulating a successful read operation
    response. """

    INPUT_VALIDATOR = SimulateDescriptorOperationResponseInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        descriptor_id: str,
        type_: BluetoothEmulation.DescriptorOperationType,
        code: int,
        data: str | None = None
    ):
        super().__init__(
            descriptorId=descriptor_id,
            type=type_,
            code=code,
            data=data
        )


class AddServiceInput(InputModel):

    address: str
    serviceUuid: str


class AddServiceOutput(OutputModel):

    serviceId: str


class AddService(CDPMethod[AddServiceOutput]):
    """ Adds a service with |serviceUuid| to the peripheral with |address|. """

    INPUT_VALIDATOR = AddServiceInput
    OUTPUT_VALIDATOR = AddServiceOutput

    def __init__(
        self,
        *,
        address: str,
        service_uuid: str
    ):
        super().__init__(
            address=address,
            serviceUuid=service_uuid
        )


class RemoveServiceInput(InputModel):

    serviceId: str


class RemoveService(CDPMethod[None]):
    """ Removes the service respresented by |serviceId| from the simulated central. """

    INPUT_VALIDATOR = RemoveServiceInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        service_id: str
    ):
        super().__init__(
            serviceId=service_id
        )


class AddCharacteristicInput(InputModel):

    serviceId: str
    characteristicUuid: str
    properties: BluetoothEmulation.CharacteristicProperties


class AddCharacteristicOutput(OutputModel):

    characteristicId: str


class AddCharacteristic(CDPMethod[AddCharacteristicOutput]):
    """ Adds a characteristic with |characteristicUuid| and |properties| to the
    service represented by |serviceId|. """

    INPUT_VALIDATOR = AddCharacteristicInput
    OUTPUT_VALIDATOR = AddCharacteristicOutput

    def __init__(
        self,
        *,
        service_id: str,
        characteristic_uuid: str,
        properties: BluetoothEmulation.CharacteristicProperties
    ):
        super().__init__(
            serviceId=service_id,
            characteristicUuid=characteristic_uuid,
            properties=properties
        )


class RemoveCharacteristicInput(InputModel):

    characteristicId: str


class RemoveCharacteristic(CDPMethod[None]):
    """ Removes the characteristic respresented by |characteristicId| from the
    simulated central. """

    INPUT_VALIDATOR = RemoveCharacteristicInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        characteristic_id: str
    ):
        super().__init__(
            characteristicId=characteristic_id
        )


class AddDescriptorInput(InputModel):

    characteristicId: str
    descriptorUuid: str


class AddDescriptorOutput(OutputModel):

    descriptorId: str


class AddDescriptor(CDPMethod[AddDescriptorOutput]):
    """ Adds a descriptor with |descriptorUuid| to the characteristic respresented
    by |characteristicId|. """

    INPUT_VALIDATOR = AddDescriptorInput
    OUTPUT_VALIDATOR = AddDescriptorOutput

    def __init__(
        self,
        *,
        characteristic_id: str,
        descriptor_uuid: str
    ):
        super().__init__(
            characteristicId=characteristic_id,
            descriptorUuid=descriptor_uuid
        )


class RemoveDescriptorInput(InputModel):

    descriptorId: str


class RemoveDescriptor(CDPMethod[None]):
    """ Removes the descriptor with |descriptorId| from the simulated central. """

    INPUT_VALIDATOR = RemoveDescriptorInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        descriptor_id: str
    ):
        super().__init__(
            descriptorId=descriptor_id
        )


class SimulateGATTDisconnectionInput(InputModel):

    address: str


class SimulateGATTDisconnection(CDPMethod[None]):
    """ Simulates a GATT disconnection from the peripheral with |address|. """

    INPUT_VALIDATOR = SimulateGATTDisconnectionInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        address: str
    ):
        super().__init__(
            address=address
        )
