elasticsearch-api/api-spec-testing/test_file/action.rb
# Execute the action. The method returns the client, in case the action created a new client
#   with header settings.
#
# @example Execute the action.
#   action.execute(client, test)
#
# @param [ Elasticsearch::Client ] client The client to use to execute the action.
# @param [ Test ] test The test containing this action. Necessary for caching variables.
#
# @return [ Elasticsearch::Client ] The client. It will be a new one, not the one passed in,
#   if the action is to set headers.
#
# @since 6.2.0
Execute the action. The method returns the client, in case the action created a new client
with header settings.
Execute the action . The method returns the client in case the action created a new client with header settings .
def execute(client, test = nil)
        @definition.each.inject(client) do |client, (method_chain, args)|
          chain = method_chain.split('.')
          if chain.size > 1
            client = chain[0...-1].inject(client) do |_client, _method|
              _client.send(_method)
            end
          end
          _method = chain[-1]
          case _method
          when 'headers'
            headers = prepare_arguments(args, test)
            if headers[:Authorization] == 'Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA=='
              headers.delete(:Authorization)
            end
            host = client.transport.instance_variable_get('@hosts')
            transport_options = client.transport.instance_variable_get('@options')&.dig(:transport_options) || {}
            if ENV['QUIET'] == 'true'
              Elasticsearch::Client.new(
                host: host,
                transport_options: transport_options.merge(headers: headers)
              )
            else
              Elasticsearch::Client.new(
                host: host,
                tracer: Logger.new($stdout),
                transport_options: transport_options.merge(headers: headers)
              )
            end
          when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex'
            client
          when 'put_trained_model_alias'
            args.merge!('reassign' => true) unless args['reassign'] === false
            @response = client.send(_method, prepare_arguments(args, test))
            client
          else
            @response = client.send(_method, prepare_arguments(args, test))
            client
          end
        end
      end
def execute ( client , test = nil ) @definition . each . inject ( client ) do | client , ( method_chain , args ) | chain = method_chain . split ( '.' ) if chain . size > 1 client = chain [ 0 ... - 1 ] . inject ( client ) do | _client , _method | _client . send ( _method ) end end _method = chain [ - 1 ] case _method when 'headers' headers = prepare_arguments ( args , test ) if headers [ :Authorization ] == 'Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==' headers . delete ( :Authorization ) end host = client . transport . instance_variable_get ( '@hosts' ) transport_options = client . transport . instance_variable_get ( '@options' ) &. dig ( :transport_options ) || { } if ENV [ 'QUIET' ] == 'true' Elasticsearch :: Client . new ( host : host , transport_options : transport_options . merge ( headers : headers ) ) else Elasticsearch :: Client . new ( host : host , tracer : Logger . new ( $stdout ) , transport_options : transport_options . merge ( headers : headers ) ) end when 'catch' , 'warnings' , 'allowed_warnings' , 'allowed_warnings_regex' client when 'put_trained_model_alias' args . merge! ( 'reassign' => true ) unless args [ 'reassign' ] === false @response = client . send ( _method , prepare_arguments ( args , test ) ) client else @response = client . send ( _method , prepare_arguments ( args , test ) ) client end end end
Execute the action.
Execute the action .
# If we have a method nested in a namespace, client becomes the # client/namespace. Eg for `indices.resolve_index`, `client = # client.indices` and then we call `resolve_index` on `client`. # TODO: Remove Authorization headers while x_pack_rest_user is fixed # todo: create a method on Elasticsearch::Client that can clone the client with new options
The client. It will be a new one, not the one passed in, if the action is to set headers.
The client . It will be a new one not the one passed in if the action is to set headers .
 Elasticsearch::Client 
client
test
test The test containing this action. Necessary for caching variables.
test The test containing this action . Necessary for caching variables .
example
Execute the action. action.execute(client, test)
Execute the action . action . execute ( client test )
since
None