lib/selenium/webdriver/bidi/protocol/bluetooth.rb



# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# This file is automatically generated. DO NOT EDIT!
# Regenerate with: bazel run //rb/lib/selenium/webdriver:bidi-generate

module Selenium
  module WebDriver
    class BiDi
      module Protocol
        # @api private
        # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
        class Bluetooth < Domain
          EVENTS = {
            request_device_prompt_updated: 'bluetooth.requestDevicePromptUpdated',
            gatt_connection_attempted: 'bluetooth.gattConnectionAttempted'
          }.freeze

          SIMULATE_ADAPTER_PARAMETERS_STATE = {
            absent: 'absent',
            powered_off: 'powered-off',
            powered_on: 'powered-on'
          }.freeze

          SIMULATE_SERVICE_PARAMETERS_TYPE = {
            add: 'add',
            remove: 'remove'
          }.freeze

          SIMULATE_CHARACTERISTIC_PARAMETERS_TYPE = {
            add: 'add',
            remove: 'remove'
          }.freeze

          SIMULATE_CHARACTERISTIC_RESPONSE_PARAMETERS_TYPE = {
            read: 'read',
            write: 'write',
            subscribe_to_notifications: 'subscribe-to-notifications',
            unsubscribe_from_notifications: 'unsubscribe-from-notifications'
          }.freeze

          SIMULATE_DESCRIPTOR_PARAMETERS_TYPE = {
            add: 'add',
            remove: 'remove'
          }.freeze

          SIMULATE_DESCRIPTOR_RESPONSE_PARAMETERS_TYPE = {
            read: 'read',
            write: 'write'
          }.freeze

          CHARACTERISTIC_EVENT_GENERATED_PARAMETERS_TYPE = {
            read: 'read',
            write_with_response: 'write-with-response',
            write_without_response: 'write-without-response',
            subscribe_to_notifications: 'subscribe-to-notifications',
            unsubscribe_from_notifications: 'unsubscribe-from-notifications'
          }.freeze

          DESCRIPTOR_EVENT_GENERATED_PARAMETERS_TYPE = {
            read: 'read',
            write: 'write'
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          BluetoothManufacturerData = Serialization::Record.define(
            key: {wire_key: 'key', primitive: 'integer'},
            data: {wire_key: 'data', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          CharacteristicProperties = Serialization::Record.define(
            broadcast: {wire_key: 'broadcast', required: false, primitive: 'boolean'},
            read: {wire_key: 'read', required: false, primitive: 'boolean'},
            write_without_response: {wire_key: 'writeWithoutResponse', required: false, primitive: 'boolean'},
            write: {wire_key: 'write', required: false, primitive: 'boolean'},
            notify: {wire_key: 'notify', required: false, primitive: 'boolean'},
            indicate: {wire_key: 'indicate', required: false, primitive: 'boolean'},
            authenticated_signed_writes: {wire_key: 'authenticatedSignedWrites', required: false, primitive: 'boolean'},
            extended_properties: {wire_key: 'extendedProperties', required: false, primitive: 'boolean'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RequestDeviceInfo = Serialization::Record.define(
            id: 'id',
            name: {wire_key: 'name', nullable: true, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          ScanRecord = Serialization::Record.define(
            name: {wire_key: 'name', required: false, primitive: 'string'},
            uuids: {wire_key: 'uuids', required: false, list: true},
            appearance: {wire_key: 'appearance', required: false, primitive: 'number'},
            manufacturer_data: {
              wire_key: 'manufacturerData',
              required: false,
              ref: 'Bluetooth::BluetoothManufacturerData',
              list: true
            }
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          class HandleRequestDevicePromptParameters < Serialization::Union
            discriminator 'accept'
            variants(
              true => 'Bluetooth::HandleRequestDevicePromptParameters::AcceptParameters',
              false => 'Bluetooth::HandleRequestDevicePromptParameters::CancelParameters'
            )

            # @api private
            # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
            AcceptParameters = Serialization::Record.define(
              accept: {fixed: true},
              context: {wire_key: 'context', primitive: 'string'},
              prompt: 'prompt',
              device: 'device'
            )

            # @api private
            # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
            CancelParameters = Serialization::Record.define(
              accept: {fixed: false},
              context: {wire_key: 'context', primitive: 'string'},
              prompt: 'prompt'
            )
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateAdapterParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            le_supported: {wire_key: 'leSupported', required: false, primitive: 'boolean'},
            state: {wire_key: 'state', enum: 'Bluetooth::SIMULATE_ADAPTER_PARAMETERS_STATE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DisableSimulationParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulatePreconnectedPeripheralParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            name: {wire_key: 'name', primitive: 'string'},
            manufacturer_data: {wire_key: 'manufacturerData', ref: 'Bluetooth::BluetoothManufacturerData', list: true},
            known_service_uuids: {wire_key: 'knownServiceUuids', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateAdvertisementParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            scan_entry: {wire_key: 'scanEntry', ref: 'Bluetooth::SimulateAdvertisementScanEntryParameters'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateAdvertisementScanEntryParameters = Serialization::Record.define(
            device_address: {wire_key: 'deviceAddress', primitive: 'string'},
            rssi: {wire_key: 'rssi', primitive: 'number'},
            scan_record: {wire_key: 'scanRecord', ref: 'Bluetooth::ScanRecord'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateGattConnectionResponseParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            code: {wire_key: 'code', primitive: 'integer'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateGattDisconnectionParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateServiceParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            uuid: 'uuid',
            type: {wire_key: 'type', enum: 'Bluetooth::SIMULATE_SERVICE_PARAMETERS_TYPE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateCharacteristicParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            characteristic_properties: {
              wire_key: 'characteristicProperties',
              required: false,
              ref: 'Bluetooth::CharacteristicProperties'
            },
            type: {wire_key: 'type', enum: 'Bluetooth::SIMULATE_CHARACTERISTIC_PARAMETERS_TYPE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateCharacteristicResponseParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            type: {wire_key: 'type', enum: 'Bluetooth::SIMULATE_CHARACTERISTIC_RESPONSE_PARAMETERS_TYPE'},
            code: {wire_key: 'code', primitive: 'integer'},
            data: {wire_key: 'data', required: false, list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateDescriptorParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            descriptor_uuid: 'descriptorUuid',
            type: {wire_key: 'type', enum: 'Bluetooth::SIMULATE_DESCRIPTOR_PARAMETERS_TYPE'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SimulateDescriptorResponseParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            descriptor_uuid: 'descriptorUuid',
            type: {wire_key: 'type', enum: 'Bluetooth::SIMULATE_DESCRIPTOR_RESPONSE_PARAMETERS_TYPE'},
            code: {wire_key: 'code', primitive: 'integer'},
            data: {wire_key: 'data', required: false, list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          RequestDevicePromptUpdatedParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            prompt: 'prompt',
            devices: {wire_key: 'devices', ref: 'Bluetooth::RequestDeviceInfo', list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          GattConnectionAttemptedParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          CharacteristicEventGeneratedParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            type: {wire_key: 'type', enum: 'Bluetooth::CHARACTERISTIC_EVENT_GENERATED_PARAMETERS_TYPE'},
            data: {wire_key: 'data', required: false, list: true}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          DescriptorEventGeneratedParameters = Serialization::Record.define(
            context: {wire_key: 'context', primitive: 'string'},
            address: {wire_key: 'address', primitive: 'string'},
            service_uuid: 'serviceUuid',
            characteristic_uuid: 'characteristicUuid',
            descriptor_uuid: 'descriptorUuid',
            type: {wire_key: 'type', enum: 'Bluetooth::DESCRIPTOR_EVENT_GENERATED_PARAMETERS_TYPE'},
            data: {wire_key: 'data', required: false, list: true}
          )

          EVENT_TYPES = {
            'bluetooth.requestDevicePromptUpdated' => Bluetooth::RequestDevicePromptUpdatedParameters,
            'bluetooth.gattConnectionAttempted' => Bluetooth::GattConnectionAttemptedParameters
          }.freeze

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def handle_request_device_prompt(context:, prompt:, accept:, device: Serialization::UNSET)
            params = HandleRequestDevicePromptParameters.build(
              context: context,
              prompt: prompt,
              accept: accept,
              device: device
            )
            execute(cmd: 'bluetooth.handleRequestDevicePrompt', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_adapter(context:, state:, le_supported: Serialization::UNSET)
            Serialization.validate!('state', state, Bluetooth::SIMULATE_ADAPTER_PARAMETERS_STATE)
            params = SimulateAdapterParameters.new(context: context, le_supported: le_supported, state: state)
            execute(cmd: 'bluetooth.simulateAdapter', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def disable_simulation(context:)
            params = DisableSimulationParameters.new(context: context)
            execute(cmd: 'bluetooth.disableSimulation', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_preconnected_peripheral(context:, address:, name:, manufacturer_data:, known_service_uuids:)
            params = SimulatePreconnectedPeripheralParameters.new(
              context: context,
              address: address,
              name: name,
              manufacturer_data: manufacturer_data,
              known_service_uuids: known_service_uuids
            )
            execute(cmd: 'bluetooth.simulatePreconnectedPeripheral', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_advertisement(context:, scan_entry:)
            params = SimulateAdvertisementParameters.new(context: context, scan_entry: scan_entry)
            execute(cmd: 'bluetooth.simulateAdvertisement', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_gatt_connection_response(context:, address:, code:)
            params = SimulateGattConnectionResponseParameters.new(context: context, address: address, code: code)
            execute(cmd: 'bluetooth.simulateGattConnectionResponse', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_gatt_disconnection(context:, address:)
            params = SimulateGattDisconnectionParameters.new(context: context, address: address)
            execute(cmd: 'bluetooth.simulateGattDisconnection', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_service(context:, address:, uuid:, type:)
            Serialization.validate!('type', type, Bluetooth::SIMULATE_SERVICE_PARAMETERS_TYPE)
            params = SimulateServiceParameters.new(context: context, address: address, uuid: uuid, type: type)
            execute(cmd: 'bluetooth.simulateService', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_characteristic(
            context:,
            address:,
            service_uuid:,
            characteristic_uuid:,
            type:,
            characteristic_properties: Serialization::UNSET
          )
            Serialization.validate!('type', type, Bluetooth::SIMULATE_CHARACTERISTIC_PARAMETERS_TYPE)
            params = SimulateCharacteristicParameters.new(
              context: context,
              address: address,
              service_uuid: service_uuid,
              characteristic_uuid: characteristic_uuid,
              characteristic_properties: characteristic_properties,
              type: type
            )
            execute(cmd: 'bluetooth.simulateCharacteristic', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_characteristic_response(
            context:,
            address:,
            service_uuid:,
            characteristic_uuid:,
            type:,
            code:,
            data: Serialization::UNSET
          )
            Serialization.validate!('type', type, Bluetooth::SIMULATE_CHARACTERISTIC_RESPONSE_PARAMETERS_TYPE)
            params = SimulateCharacteristicResponseParameters.new(
              context: context,
              address: address,
              service_uuid: service_uuid,
              characteristic_uuid: characteristic_uuid,
              type: type,
              code: code,
              data: data
            )
            execute(cmd: 'bluetooth.simulateCharacteristicResponse', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_descriptor(context:, address:, service_uuid:, characteristic_uuid:, descriptor_uuid:, type:)
            Serialization.validate!('type', type, Bluetooth::SIMULATE_DESCRIPTOR_PARAMETERS_TYPE)
            params = SimulateDescriptorParameters.new(
              context: context,
              address: address,
              service_uuid: service_uuid,
              characteristic_uuid: characteristic_uuid,
              descriptor_uuid: descriptor_uuid,
              type: type
            )
            execute(cmd: 'bluetooth.simulateDescriptor', params: params)
          end

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def simulate_descriptor_response(
            context:,
            address:,
            service_uuid:,
            characteristic_uuid:,
            descriptor_uuid:,
            type:,
            code:,
            data: Serialization::UNSET
          )
            Serialization.validate!('type', type, Bluetooth::SIMULATE_DESCRIPTOR_RESPONSE_PARAMETERS_TYPE)
            params = SimulateDescriptorResponseParameters.new(
              context: context,
              address: address,
              service_uuid: service_uuid,
              characteristic_uuid: characteristic_uuid,
              descriptor_uuid: descriptor_uuid,
              type: type,
              code: code,
              data: data
            )
            execute(cmd: 'bluetooth.simulateDescriptorResponse', params: params)
          end
        end # Bluetooth
      end # Protocol
    end # BiDi
  end # WebDriver
end # Selenium