Class: EsHttpOperation

Inherits:
Object
  • Object
show all
Includes:
Gorillib::Model, HTTParty
Defined in:
lib/wukong-migrate/elasticsearch_operations.rb

Defined Under Namespace

Modules: Helpers Classes: AliasIndex, CreateIndex, DeleteIndex, UpdateIndexMapping, UpdateIndexSettings

Instance Method Summary collapse

Instance Method Details

#call_own_http_methodObject



17
18
19
20
# File 'lib/wukong-migrate/elasticsearch_operations.rb', line 17

def call_own_http_method
  http_options = body ? { body: json_body } : {}
  self.class.send(verb, path, http_options)
end

#configure_with(options) ⇒ Object



7
8
9
10
# File 'lib/wukong-migrate/elasticsearch_operations.rb', line 7

def configure_with options
  uri = [options[:host], options[:port]].join(':')
  self.class.base_uri uri
end

#executeObject



12
13
14
15
# File 'lib/wukong-migrate/elasticsearch_operations.rb', line 12

def execute
  response = call_own_http_method
  response
end

#json_bodyObject



28
29
30
# File 'lib/wukong-migrate/elasticsearch_operations.rb', line 28

def json_body
  MultiJson.encode(body)
end

#raw_curl_stringObject



22
23
24
25
26
# File 'lib/wukong-migrate/elasticsearch_operations.rb', line 22

def raw_curl_string
  "curl -X #{verb.to_s.upcase} '#{self.class.base_uri}#{path}'".tap do |raw|
    raw << " -d '#{json_body}'" if body
  end
end