lib/elasticsearch/api/actions/index.rb in elasticsearch-api-7.6.0 vs lib/elasticsearch/api/actions/index.rb in elasticsearch-api-7.7.0.pre

- old
+ new

@@ -24,24 +24,26 @@ # (options: internal,external,external_gte) # @option arguments [Number] :if_seq_no only perform the index operation if the last operation that has changed the document has the specified sequence number # @option arguments [Number] :if_primary_term only perform the index operation if the last operation that has changed the document has the specified primary term # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with - + # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body The document (*Required*) # # *Deprecation notice*: # Specifying types in urls has been deprecated # Deprecated since version 7.0.0 # # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-index_.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html # def index(arguments = {}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] + headers = arguments.delete(:headers) || {} + arguments = arguments.clone _id = arguments.delete(:id) _index = arguments.delete(:index) @@ -59,10 +61,10 @@ "#{Utils.__listify(_index)}/_doc" end params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] - perform_request(method, path, params, body).body + perform_request(method, path, params, body, headers).body end # Register this action with its valid params when the module is loaded. # # @since 6.2.0