lib/selenium/webdriver/bidi/protocol/permissions.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 Permissions < Domain
          PERMISSION_STATE = {
            granted: 'granted',
            denied: 'denied',
            prompt: 'prompt'
          }.freeze

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

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          SetPermissionParameters = Serialization::Record.define(
            descriptor: {wire_key: 'descriptor', ref: 'Permissions::PermissionDescriptor'},
            state: {wire_key: 'state', enum: 'Permissions::PERMISSION_STATE'},
            origin: {wire_key: 'origin', primitive: 'string'},
            embedded_origin: {wire_key: 'embeddedOrigin', required: false, primitive: 'string'},
            user_context: {wire_key: 'userContext', required: false, primitive: 'string'}
          )

          # @api private
          # @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
          def set_permission(
            descriptor:,
            state:,
            origin:,
            embedded_origin: Serialization::UNSET,
            user_context: Serialization::UNSET
          )
            Serialization.validate!('state', state, Permissions::PERMISSION_STATE)
            params = SetPermissionParameters.new(
              descriptor: descriptor,
              state: state,
              origin: origin,
              embedded_origin: embedded_origin,
              user_context: user_context
            )
            execute(cmd: 'permissions.setPermission', params: params)
          end
        end # Permissions
      end # Protocol
    end # BiDi
  end # WebDriver
end # Selenium