# frozen_string_literal: true

# Copyright 2021 Google LLC
#
# Licensed 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
#
#     https://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.

# Auto-generated by gapic-generator-ruby. DO NOT EDIT!

require "google/cloud/errors"
require "google/cloud/domains/v1beta1/domains_pb"

module Google
  module Cloud
    module Domains
      module V1beta1
        module Domains
          ##
          # Client for the Domains service.
          #
          # The Cloud Domains API enables management and configuration of domain names.
          #
          class Client
            include Paths

            # @private
            attr_reader :domains_stub

            ##
            # Configure the Domains Client class.
            #
            # See {::Google::Cloud::Domains::V1beta1::Domains::Client::Configuration}
            # for a description of the configuration fields.
            #
            # @example
            #
            #   # Modify the configuration for all Domains clients
            #   ::Google::Cloud::Domains::V1beta1::Domains::Client.configure do |config|
            #     config.timeout = 10.0
            #   end
            #
            # @yield [config] Configure the Client client.
            # @yieldparam config [Client::Configuration]
            #
            # @return [Client::Configuration]
            #
            def self.configure
              @configure ||= begin
                namespace = ["Google", "Cloud", "Domains", "V1beta1"]
                parent_config = while namespace.any?
                                  parent_name = namespace.join "::"
                                  parent_const = const_get parent_name
                                  break parent_const.configure if parent_const.respond_to? :configure
                                  namespace.pop
                                end
                default_config = Client::Configuration.new parent_config

                default_config
              end
              yield @configure if block_given?
              @configure
            end

            ##
            # Configure the Domains Client instance.
            #
            # The configuration is set to the derived mode, meaning that values can be changed,
            # but structural changes (adding new fields, etc.) are not allowed. Structural changes
            # should be made on {Client.configure}.
            #
            # See {::Google::Cloud::Domains::V1beta1::Domains::Client::Configuration}
            # for a description of the configuration fields.
            #
            # @yield [config] Configure the Client client.
            # @yieldparam config [Client::Configuration]
            #
            # @return [Client::Configuration]
            #
            def configure
              yield @config if block_given?
              @config
            end

            ##
            # Create a new Domains client object.
            #
            # @example
            #
            #   # Create a client using the default configuration
            #   client = ::Google::Cloud::Domains::V1beta1::Domains::Client.new
            #
            #   # Create a client using a custom configuration
            #   client = ::Google::Cloud::Domains::V1beta1::Domains::Client.new do |config|
            #     config.timeout = 10.0
            #   end
            #
            # @yield [config] Configure the Domains client.
            # @yieldparam config [Client::Configuration]
            #
            def initialize
              # These require statements are intentionally placed here to initialize
              # the gRPC module only when it's required.
              # See https://github.com/googleapis/toolkit/issues/446
              require "gapic/grpc"
              require "google/cloud/domains/v1beta1/domains_services_pb"

              # Create the configuration object
              @config = Configuration.new Client.configure

              # Yield the configuration if needed
              yield @config if block_given?

              # Create credentials
              credentials = @config.credentials
              # Use self-signed JWT if the endpoint is unchanged from default,
              # but only if the default endpoint does not have a region prefix.
              enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                                       !@config.endpoint.split(".").first.include?("-")
              credentials ||= Credentials.default scope: @config.scope,
                                                  enable_self_signed_jwt: enable_self_signed_jwt
              if credentials.is_a?(::String) || credentials.is_a?(::Hash)
                credentials = Credentials.new credentials, scope: @config.scope
              end
              @quota_project_id = @config.quota_project
              @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

              @operations_client = Operations.new do |config|
                config.credentials = credentials
                config.endpoint = @config.endpoint
              end

              @domains_stub = ::Gapic::ServiceStub.new(
                ::Google::Cloud::Domains::V1beta1::Domains::Stub,
                credentials:  credentials,
                endpoint:     @config.endpoint,
                channel_args: @config.channel_args,
                interceptors: @config.interceptors
              )
            end

            ##
            # Get the associated client for long-running operations.
            #
            # @return [::Google::Cloud::Domains::V1beta1::Domains::Operations]
            #
            attr_reader :operations_client

            # Service calls

            ##
            # Searches for available domain names similar to the provided query.
            #
            # Availability results from this method are approximate; call
            # `RetrieveRegisterParameters` on a domain before registering to confirm
            # availability.
            #
            # @overload search_domains(request, options = nil)
            #   Pass arguments to `search_domains` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::SearchDomainsRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::SearchDomainsRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload search_domains(query: nil, location: nil)
            #   Pass arguments to `search_domains` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param query [::String]
            #     Required. String used to search for available domain names.
            #   @param location [::String]
            #     Required. The location. Must be in the format `projects/*/locations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Google::Cloud::Domains::V1beta1::SearchDomainsResponse]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Google::Cloud::Domains::V1beta1::SearchDomainsResponse]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def search_domains request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::SearchDomainsRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.search_domains.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "location" => request.location
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.search_domains.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.search_domains.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :search_domains, request, options: options do |response, operation|
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Gets parameters needed to register a new domain name, including price and
            # up-to-date availability. Use the returned values to call `RegisterDomain`.
            #
            # @overload retrieve_register_parameters(request, options = nil)
            #   Pass arguments to `retrieve_register_parameters` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::RetrieveRegisterParametersRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::RetrieveRegisterParametersRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload retrieve_register_parameters(domain_name: nil, location: nil)
            #   Pass arguments to `retrieve_register_parameters` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param domain_name [::String]
            #     Required. The domain name. Unicode domain names must be expressed in Punycode format.
            #   @param location [::String]
            #     Required. The location. Must be in the format `projects/*/locations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Google::Cloud::Domains::V1beta1::RetrieveRegisterParametersResponse]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Google::Cloud::Domains::V1beta1::RetrieveRegisterParametersResponse]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def retrieve_register_parameters request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::RetrieveRegisterParametersRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.retrieve_register_parameters.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "location" => request.location
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.retrieve_register_parameters.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.retrieve_register_parameters.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :retrieve_register_parameters, request, options: options do |response, operation|
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Registers a new domain name and creates a corresponding `Registration`
            # resource.
            #
            # Call `RetrieveRegisterParameters` first to check availability of the domain
            # name and determine parameters like price that are needed to build a call to
            # this method.
            #
            # A successful call creates a `Registration` resource in state
            # `REGISTRATION_PENDING`, which resolves to `ACTIVE` within 1-2
            # minutes, indicating that the domain was successfully registered. If the
            # resource ends up in state `REGISTRATION_FAILED`, it indicates that the
            # domain was not registered successfully, and you can safely delete the
            # resource and retry registration.
            #
            # @overload register_domain(request, options = nil)
            #   Pass arguments to `register_domain` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::RegisterDomainRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::RegisterDomainRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload register_domain(parent: nil, registration: nil, domain_notices: nil, contact_notices: nil, yearly_price: nil, validate_only: nil)
            #   Pass arguments to `register_domain` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param parent [::String]
            #     Required. The parent resource of the `Registration`. Must be in the
            #     format `projects/*/locations/*`.
            #   @param registration [::Google::Cloud::Domains::V1beta1::Registration, ::Hash]
            #     Required. The complete `Registration` resource to be created.
            #   @param domain_notices [::Array<::Google::Cloud::Domains::V1beta1::DomainNotice>]
            #     The list of domain notices that you acknowledge. Call
            #     `RetrieveRegisterParameters` to see the notices that need acknowledgement.
            #   @param contact_notices [::Array<::Google::Cloud::Domains::V1beta1::ContactNotice>]
            #     The list of contact notices that the caller acknowledges. The notices
            #     required here depend on the values specified in
            #     `registration.contact_settings`.
            #   @param yearly_price [::Google::Type::Money, ::Hash]
            #     Required. Yearly price to register or renew the domain.
            #     The value that should be put here can be obtained from
            #     RetrieveRegisterParameters or SearchDomains calls.
            #   @param validate_only [::Boolean]
            #     When true, only validation will be performed, without actually registering
            #     the domain. Follows:
            #     https://cloud.google.com/apis/design/design_patterns#request_validation
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def register_domain request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::RegisterDomainRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.register_domain.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "parent" => request.parent
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.register_domain.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.register_domain.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :register_domain, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Lists the `Registration` resources in a project.
            #
            # @overload list_registrations(request, options = nil)
            #   Pass arguments to `list_registrations` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ListRegistrationsRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ListRegistrationsRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload list_registrations(parent: nil, page_size: nil, page_token: nil, filter: nil)
            #   Pass arguments to `list_registrations` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param parent [::String]
            #     Required. The project and location from which to list `Registration`s, specified in
            #     the format `projects/*/locations/*`.
            #   @param page_size [::Integer]
            #     Maximum number of results to return.
            #   @param page_token [::String]
            #     When set to the `next_page_token` from a prior response, provides the next
            #     page of results.
            #   @param filter [::String]
            #     Filter expression to restrict the `Registration`s returned.
            #
            #     The expression must specify the field name, a comparison operator, and the
            #     value that you want to use for filtering. The value must be a string, a
            #     number, a boolean, or an enum value. The comparison operator should be one
            #     of =, !=, >, <, >=, <=, or : for prefix or wildcard matches.
            #
            #     For example, to filter to a specific domain name, use an expression like
            #     `domainName="example.com"`. You can also check for the existence of a
            #     field; for example, to find domains using custom DNS settings, use an
            #     expression like `dnsSettings.customDns:*`.
            #
            #     You can also create compound filters by combining expressions with the
            #     `AND` and `OR` operators. For example, to find domains that are suspended
            #     or have specific issues flagged, use an expression like
            #     `(state=SUSPENDED) OR (issue:*)`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Domains::V1beta1::Registration>]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::PagedEnumerable<::Google::Cloud::Domains::V1beta1::Registration>]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def list_registrations request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ListRegistrationsRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.list_registrations.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "parent" => request.parent
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.list_registrations.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.list_registrations.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :list_registrations, request, options: options do |response, operation|
                response = ::Gapic::PagedEnumerable.new @domains_stub, :list_registrations, request, response, operation, options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Gets the details of a `Registration` resource.
            #
            # @overload get_registration(request, options = nil)
            #   Pass arguments to `get_registration` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::GetRegistrationRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::GetRegistrationRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload get_registration(name: nil)
            #   Pass arguments to `get_registration` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param name [::String]
            #     Required. The name of the `Registration` to get, in the format
            #     `projects/*/locations/*/registrations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Google::Cloud::Domains::V1beta1::Registration]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Google::Cloud::Domains::V1beta1::Registration]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def get_registration request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::GetRegistrationRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.get_registration.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "name" => request.name
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.get_registration.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.get_registration.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :get_registration, request, options: options do |response, operation|
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Updates select fields of a `Registration` resource, notably `labels`. To
            # update other fields, use the appropriate custom update method:
            #
            # * To update management settings, see `ConfigureManagementSettings`
            # * To update DNS configuration, see `ConfigureDnsSettings`
            # * To update contact information, see `ConfigureContactSettings`
            #
            # @overload update_registration(request, options = nil)
            #   Pass arguments to `update_registration` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::UpdateRegistrationRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::UpdateRegistrationRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload update_registration(registration: nil, update_mask: nil)
            #   Pass arguments to `update_registration` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::Google::Cloud::Domains::V1beta1::Registration, ::Hash]
            #     Fields of the `Registration` to update.
            #   @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
            #     Required. The field mask describing which fields to update as a comma-separated list.
            #     For example, if only the labels are being updated, the `update_mask` would
            #     be `"labels"`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def update_registration request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::UpdateRegistrationRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.update_registration.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration.name" => request.registration.name
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.update_registration.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.update_registration.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :update_registration, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Updates a `Registration`'s management settings.
            #
            # @overload configure_management_settings(request, options = nil)
            #   Pass arguments to `configure_management_settings` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ConfigureManagementSettingsRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ConfigureManagementSettingsRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload configure_management_settings(registration: nil, management_settings: nil, update_mask: nil)
            #   Pass arguments to `configure_management_settings` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::String]
            #     Required. The name of the `Registration` whose management settings are being updated,
            #     in the format `projects/*/locations/*/registrations/*`.
            #   @param management_settings [::Google::Cloud::Domains::V1beta1::ManagementSettings, ::Hash]
            #     Fields of the `ManagementSettings` to update.
            #   @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
            #     Required. The field mask describing which fields to update as a comma-separated list.
            #     For example, if only the transfer lock is being updated, the `update_mask`
            #     would be `"transfer_lock_state"`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def configure_management_settings request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ConfigureManagementSettingsRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.configure_management_settings.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration" => request.registration
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.configure_management_settings.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.configure_management_settings.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :configure_management_settings, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Updates a `Registration`'s DNS settings.
            #
            # @overload configure_dns_settings(request, options = nil)
            #   Pass arguments to `configure_dns_settings` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ConfigureDnsSettingsRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ConfigureDnsSettingsRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload configure_dns_settings(registration: nil, dns_settings: nil, update_mask: nil, validate_only: nil)
            #   Pass arguments to `configure_dns_settings` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::String]
            #     Required. The name of the `Registration` whose DNS settings are being updated,
            #     in the format `projects/*/locations/*/registrations/*`.
            #   @param dns_settings [::Google::Cloud::Domains::V1beta1::DnsSettings, ::Hash]
            #     Fields of the `DnsSettings` to update.
            #   @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
            #     Required. The field mask describing which fields to update as a comma-separated list.
            #     For example, if only the name servers are being updated for an existing
            #     Custom DNS configuration, the `update_mask` would be
            #     `"custom_dns.name_servers"`.
            #
            #     When changing the DNS provider from one type to another, pass the new
            #     provider's field name as part of the field mask. For example, when changing
            #     from a Google Domains DNS configuration to a Custom DNS configuration, the
            #     `update_mask` would be `"custom_dns"`. //
            #   @param validate_only [::Boolean]
            #     Validate the request without actually updating the DNS settings.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def configure_dns_settings request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ConfigureDnsSettingsRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.configure_dns_settings.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration" => request.registration
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.configure_dns_settings.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.configure_dns_settings.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :configure_dns_settings, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Updates a `Registration`'s contact settings. Some changes require
            # confirmation by the domain's registrant contact .
            #
            # @overload configure_contact_settings(request, options = nil)
            #   Pass arguments to `configure_contact_settings` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ConfigureContactSettingsRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ConfigureContactSettingsRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload configure_contact_settings(registration: nil, contact_settings: nil, update_mask: nil, contact_notices: nil, validate_only: nil)
            #   Pass arguments to `configure_contact_settings` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::String]
            #     Required. The name of the `Registration` whose contact settings are being updated,
            #     in the format `projects/*/locations/*/registrations/*`.
            #   @param contact_settings [::Google::Cloud::Domains::V1beta1::ContactSettings, ::Hash]
            #     Fields of the `ContactSettings` to update.
            #   @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
            #     Required. The field mask describing which fields to update as a comma-separated list.
            #     For example, if only the registrant contact is being updated, the
            #     `update_mask` would be `"registrant_contact"`.
            #   @param contact_notices [::Array<::Google::Cloud::Domains::V1beta1::ContactNotice>]
            #     The list of contact notices that the caller acknowledges. The notices
            #     required here depend on the values specified in `contact_settings`.
            #   @param validate_only [::Boolean]
            #     Validate the request without actually updating the contact settings.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def configure_contact_settings request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ConfigureContactSettingsRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.configure_contact_settings.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration" => request.registration
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.configure_contact_settings.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.configure_contact_settings.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :configure_contact_settings, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Exports a `Registration` that you no longer want to use with
            # Cloud Domains. You can continue to use the domain in
            # [Google Domains](https://domains.google/) until it expires.
            #
            # If the export is successful:
            #
            # * The resource's `state` becomes `EXPORTED`, meaning that it is no longer
            # managed by Cloud Domains
            # * Because individual users can own domains in Google Domains, the calling
            # user becomes the domain's sole owner. Permissions for the domain are
            # subsequently managed in Google Domains.
            # * Without further action, the domain does not renew automatically.
            # The new owner can set up billing in Google Domains to renew the domain
            # if needed.
            #
            # @overload export_registration(request, options = nil)
            #   Pass arguments to `export_registration` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ExportRegistrationRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ExportRegistrationRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload export_registration(name: nil)
            #   Pass arguments to `export_registration` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param name [::String]
            #     Required. The name of the `Registration` to export,
            #     in the format `projects/*/locations/*/registrations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def export_registration request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ExportRegistrationRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.export_registration.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "name" => request.name
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.export_registration.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.export_registration.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :export_registration, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Deletes a `Registration` resource.
            #
            # This method only works on resources in one of the following states:
            #
            # * `state` is `EXPORTED` with `expire_time` in the past
            # * `state` is `REGISTRATION_FAILED`
            #
            # @overload delete_registration(request, options = nil)
            #   Pass arguments to `delete_registration` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::DeleteRegistrationRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::DeleteRegistrationRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload delete_registration(name: nil)
            #   Pass arguments to `delete_registration` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param name [::String]
            #     Required. The name of the `Registration` to delete,
            #     in the format `projects/*/locations/*/registrations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Gapic::Operation]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Gapic::Operation]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def delete_registration request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::DeleteRegistrationRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.delete_registration.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "name" => request.name
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.delete_registration.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.delete_registration.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :delete_registration, request, options: options do |response, operation|
                response = ::Gapic::Operation.new response, @operations_client, options: options
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Gets the authorization code of the `Registration` for the purpose of
            # transferring the domain to another registrar.
            #
            # You can call this method only after 60 days have elapsed since the initial
            # domain registration.
            #
            # @overload retrieve_authorization_code(request, options = nil)
            #   Pass arguments to `retrieve_authorization_code` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::RetrieveAuthorizationCodeRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::RetrieveAuthorizationCodeRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload retrieve_authorization_code(registration: nil)
            #   Pass arguments to `retrieve_authorization_code` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::String]
            #     Required. The name of the `Registration` whose authorization code is being retrieved,
            #     in the format `projects/*/locations/*/registrations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Google::Cloud::Domains::V1beta1::AuthorizationCode]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Google::Cloud::Domains::V1beta1::AuthorizationCode]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def retrieve_authorization_code request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::RetrieveAuthorizationCodeRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.retrieve_authorization_code.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration" => request.registration
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.retrieve_authorization_code.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.retrieve_authorization_code.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :retrieve_authorization_code, request, options: options do |response, operation|
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Resets the authorization code of the `Registration` to a new random string.
            #
            # You can call this method only after 60 days have elapsed since the initial
            # domain registration.
            #
            # @overload reset_authorization_code(request, options = nil)
            #   Pass arguments to `reset_authorization_code` via a request object, either of type
            #   {::Google::Cloud::Domains::V1beta1::ResetAuthorizationCodeRequest} or an equivalent Hash.
            #
            #   @param request [::Google::Cloud::Domains::V1beta1::ResetAuthorizationCodeRequest, ::Hash]
            #     A request object representing the call parameters. Required. To specify no
            #     parameters, or to keep all the default parameter values, pass an empty Hash.
            #   @param options [::Gapic::CallOptions, ::Hash]
            #     Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
            #
            # @overload reset_authorization_code(registration: nil)
            #   Pass arguments to `reset_authorization_code` via keyword arguments. Note that at
            #   least one keyword argument is required. To specify no parameters, or to keep all
            #   the default parameter values, pass an empty Hash as a request object (see above).
            #
            #   @param registration [::String]
            #     Required. The name of the `Registration` whose authorization code is being reset,
            #     in the format `projects/*/locations/*/registrations/*`.
            #
            # @yield [response, operation] Access the result along with the RPC operation
            # @yieldparam response [::Google::Cloud::Domains::V1beta1::AuthorizationCode]
            # @yieldparam operation [::GRPC::ActiveCall::Operation]
            #
            # @return [::Google::Cloud::Domains::V1beta1::AuthorizationCode]
            #
            # @raise [::Google::Cloud::Error] if the RPC is aborted.
            #
            def reset_authorization_code request, options = nil
              raise ::ArgumentError, "request must be provided" if request.nil?

              request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Domains::V1beta1::ResetAuthorizationCodeRequest

              # Converts hash and nil to an options object
              options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

              # Customize the options with defaults
              metadata = @config.rpcs.reset_authorization_code.metadata.to_h

              # Set x-goog-api-client and x-goog-user-project headers
              metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
                lib_name: @config.lib_name, lib_version: @config.lib_version,
                gapic_version: ::Google::Cloud::Domains::V1beta1::VERSION
              metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

              header_params = {
                "registration" => request.registration
              }
              request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
              metadata[:"x-goog-request-params"] ||= request_params_header

              options.apply_defaults timeout:      @config.rpcs.reset_authorization_code.timeout,
                                     metadata:     metadata,
                                     retry_policy: @config.rpcs.reset_authorization_code.retry_policy

              options.apply_defaults timeout:      @config.timeout,
                                     metadata:     @config.metadata,
                                     retry_policy: @config.retry_policy

              @domains_stub.call_rpc :reset_authorization_code, request, options: options do |response, operation|
                yield response, operation if block_given?
                return response
              end
            rescue ::GRPC::BadStatus => e
              raise ::Google::Cloud::Error.from_error(e)
            end

            ##
            # Configuration class for the Domains API.
            #
            # This class represents the configuration for Domains,
            # providing control over timeouts, retry behavior, logging, transport
            # parameters, and other low-level controls. Certain parameters can also be
            # applied individually to specific RPCs. See
            # {::Google::Cloud::Domains::V1beta1::Domains::Client::Configuration::Rpcs}
            # for a list of RPCs that can be configured independently.
            #
            # Configuration can be applied globally to all clients, or to a single client
            # on construction.
            #
            # @example
            #
            #   # Modify the global config, setting the timeout for
            #   # search_domains to 20 seconds,
            #   # and all remaining timeouts to 10 seconds.
            #   ::Google::Cloud::Domains::V1beta1::Domains::Client.configure do |config|
            #     config.timeout = 10.0
            #     config.rpcs.search_domains.timeout = 20.0
            #   end
            #
            #   # Apply the above configuration only to a new client.
            #   client = ::Google::Cloud::Domains::V1beta1::Domains::Client.new do |config|
            #     config.timeout = 10.0
            #     config.rpcs.search_domains.timeout = 20.0
            #   end
            #
            # @!attribute [rw] endpoint
            #   The hostname or hostname:port of the service endpoint.
            #   Defaults to `"domains.googleapis.com"`.
            #   @return [::String]
            # @!attribute [rw] credentials
            #   Credentials to send with calls. You may provide any of the following types:
            #    *  (`String`) The path to a service account key file in JSON format
            #    *  (`Hash`) A service account key as a Hash
            #    *  (`Google::Auth::Credentials`) A googleauth credentials object
            #       (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
            #    *  (`Signet::OAuth2::Client`) A signet oauth2 client object
            #       (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
            #    *  (`GRPC::Core::Channel`) a gRPC channel with included credentials
            #    *  (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
            #    *  (`nil`) indicating no credentials
            #   @return [::Object]
            # @!attribute [rw] scope
            #   The OAuth scopes
            #   @return [::Array<::String>]
            # @!attribute [rw] lib_name
            #   The library name as recorded in instrumentation and logging
            #   @return [::String]
            # @!attribute [rw] lib_version
            #   The library version as recorded in instrumentation and logging
            #   @return [::String]
            # @!attribute [rw] channel_args
            #   Extra parameters passed to the gRPC channel. Note: this is ignored if a
            #   `GRPC::Core::Channel` object is provided as the credential.
            #   @return [::Hash]
            # @!attribute [rw] interceptors
            #   An array of interceptors that are run before calls are executed.
            #   @return [::Array<::GRPC::ClientInterceptor>]
            # @!attribute [rw] timeout
            #   The call timeout in seconds.
            #   @return [::Numeric]
            # @!attribute [rw] metadata
            #   Additional gRPC headers to be sent with the call.
            #   @return [::Hash{::Symbol=>::String}]
            # @!attribute [rw] retry_policy
            #   The retry policy. The value is a hash with the following keys:
            #    *  `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
            #    *  `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
            #    *  `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
            #    *  `:retry_codes` (*type:* `Array<String>`) - The error codes that should
            #       trigger a retry.
            #   @return [::Hash]
            # @!attribute [rw] quota_project
            #   A separate project against which to charge quota.
            #   @return [::String]
            #
            class Configuration
              extend ::Gapic::Config

              config_attr :endpoint,      "domains.googleapis.com", ::String
              config_attr :credentials,   nil do |value|
                allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
                allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
                allowed.any? { |klass| klass === value }
              end
              config_attr :scope,         nil, ::String, ::Array, nil
              config_attr :lib_name,      nil, ::String, nil
              config_attr :lib_version,   nil, ::String, nil
              config_attr(:channel_args,  { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
              config_attr :interceptors,  nil, ::Array, nil
              config_attr :timeout,       nil, ::Numeric, nil
              config_attr :metadata,      nil, ::Hash, nil
              config_attr :retry_policy,  nil, ::Hash, ::Proc, nil
              config_attr :quota_project, nil, ::String, nil

              # @private
              def initialize parent_config = nil
                @parent_config = parent_config unless parent_config.nil?

                yield self if block_given?
              end

              ##
              # Configurations for individual RPCs
              # @return [Rpcs]
              #
              def rpcs
                @rpcs ||= begin
                  parent_rpcs = nil
                  parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
                  Rpcs.new parent_rpcs
                end
              end

              ##
              # Configuration RPC class for the Domains API.
              #
              # Includes fields providing the configuration for each RPC in this service.
              # Each configuration object is of type `Gapic::Config::Method` and includes
              # the following configuration fields:
              #
              #  *  `timeout` (*type:* `Numeric`) - The call timeout in seconds
              #  *  `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
              #  *  `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
              #     include the following keys:
              #      *  `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
              #      *  `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
              #      *  `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
              #      *  `:retry_codes` (*type:* `Array<String>`) - The error codes that should
              #         trigger a retry.
              #
              class Rpcs
                ##
                # RPC-specific configuration for `search_domains`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :search_domains
                ##
                # RPC-specific configuration for `retrieve_register_parameters`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :retrieve_register_parameters
                ##
                # RPC-specific configuration for `register_domain`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :register_domain
                ##
                # RPC-specific configuration for `list_registrations`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :list_registrations
                ##
                # RPC-specific configuration for `get_registration`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :get_registration
                ##
                # RPC-specific configuration for `update_registration`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :update_registration
                ##
                # RPC-specific configuration for `configure_management_settings`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :configure_management_settings
                ##
                # RPC-specific configuration for `configure_dns_settings`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :configure_dns_settings
                ##
                # RPC-specific configuration for `configure_contact_settings`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :configure_contact_settings
                ##
                # RPC-specific configuration for `export_registration`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :export_registration
                ##
                # RPC-specific configuration for `delete_registration`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :delete_registration
                ##
                # RPC-specific configuration for `retrieve_authorization_code`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :retrieve_authorization_code
                ##
                # RPC-specific configuration for `reset_authorization_code`
                # @return [::Gapic::Config::Method]
                #
                attr_reader :reset_authorization_code

                # @private
                def initialize parent_rpcs = nil
                  search_domains_config = parent_rpcs.search_domains if parent_rpcs.respond_to? :search_domains
                  @search_domains = ::Gapic::Config::Method.new search_domains_config
                  retrieve_register_parameters_config = parent_rpcs.retrieve_register_parameters if parent_rpcs.respond_to? :retrieve_register_parameters
                  @retrieve_register_parameters = ::Gapic::Config::Method.new retrieve_register_parameters_config
                  register_domain_config = parent_rpcs.register_domain if parent_rpcs.respond_to? :register_domain
                  @register_domain = ::Gapic::Config::Method.new register_domain_config
                  list_registrations_config = parent_rpcs.list_registrations if parent_rpcs.respond_to? :list_registrations
                  @list_registrations = ::Gapic::Config::Method.new list_registrations_config
                  get_registration_config = parent_rpcs.get_registration if parent_rpcs.respond_to? :get_registration
                  @get_registration = ::Gapic::Config::Method.new get_registration_config
                  update_registration_config = parent_rpcs.update_registration if parent_rpcs.respond_to? :update_registration
                  @update_registration = ::Gapic::Config::Method.new update_registration_config
                  configure_management_settings_config = parent_rpcs.configure_management_settings if parent_rpcs.respond_to? :configure_management_settings
                  @configure_management_settings = ::Gapic::Config::Method.new configure_management_settings_config
                  configure_dns_settings_config = parent_rpcs.configure_dns_settings if parent_rpcs.respond_to? :configure_dns_settings
                  @configure_dns_settings = ::Gapic::Config::Method.new configure_dns_settings_config
                  configure_contact_settings_config = parent_rpcs.configure_contact_settings if parent_rpcs.respond_to? :configure_contact_settings
                  @configure_contact_settings = ::Gapic::Config::Method.new configure_contact_settings_config
                  export_registration_config = parent_rpcs.export_registration if parent_rpcs.respond_to? :export_registration
                  @export_registration = ::Gapic::Config::Method.new export_registration_config
                  delete_registration_config = parent_rpcs.delete_registration if parent_rpcs.respond_to? :delete_registration
                  @delete_registration = ::Gapic::Config::Method.new delete_registration_config
                  retrieve_authorization_code_config = parent_rpcs.retrieve_authorization_code if parent_rpcs.respond_to? :retrieve_authorization_code
                  @retrieve_authorization_code = ::Gapic::Config::Method.new retrieve_authorization_code_config
                  reset_authorization_code_config = parent_rpcs.reset_authorization_code if parent_rpcs.respond_to? :reset_authorization_code
                  @reset_authorization_code = ::Gapic::Config::Method.new reset_authorization_code_config

                  yield self if block_given?
                end
              end
            end
          end
        end
      end
    end
  end
end
