Module: Elastic::EnterpriseSearch::Request
- Included in:
- Client
- Defined in:
- lib/elastic/enterprise-search/request.rb
Overview
Module included in Elastic::Enterprise::Client for http requests.
Instance Method Summary collapse
- #basic_auth_header ⇒ Object
- #delete(path, params = {}, headers = {}) ⇒ Object
- #get(path, params = {}, headers = {}) ⇒ Object
- #post(path, params = {}, body = {}, headers = {}) ⇒ Object
- #put(path, params = {}, body = {}, headers = {}) ⇒ Object
-
#request(method, path, params = {}, body = {}, headers = {}) ⇒ Object
Construct and send a request to the API.
- #setup_authentication_header ⇒ Object
Instance Method Details
#basic_auth_header ⇒ Object
75 76 77 78 |
# File 'lib/elastic/enterprise-search/request.rb', line 75 def basic_auth_header credentials = Base64.strict_encode64("#{http_auth[:user]}:#{http_auth[:password]}") "Basic #{credentials}" end |
#delete(path, params = {}, headers = {}) ⇒ Object
45 46 47 |
# File 'lib/elastic/enterprise-search/request.rb', line 45 def delete(path, params = {}, headers = {}) request(:delete, path, params, headers) end |
#get(path, params = {}, headers = {}) ⇒ Object
33 34 35 |
# File 'lib/elastic/enterprise-search/request.rb', line 33 def get(path, params = {}, headers = {}) request(:get, path, params, headers) end |
#post(path, params = {}, body = {}, headers = {}) ⇒ Object
37 38 39 |
# File 'lib/elastic/enterprise-search/request.rb', line 37 def post(path, params = {}, body = {}, headers = {}) request(:post, path, params, body, headers) end |
#put(path, params = {}, body = {}, headers = {}) ⇒ Object
41 42 43 |
# File 'lib/elastic/enterprise-search/request.rb', line 41 def put(path, params = {}, body = {}, headers = {}) request(:put, path, params, body, headers) end |
#request(method, path, params = {}, body = {}, headers = {}) ⇒ Object
Construct and send a request to the API.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/elastic/enterprise-search/request.rb', line 50 def request(method, path, params = {}, body = {}, headers = {}) = { authorization: (params) } headers = if !headers.is_a?(Hash) else headers.merge() end Elastic::API::Response.new( @transport.perform_request(method.to_s.upcase, path, params, body, headers) ) end |
#setup_authentication_header ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/elastic/enterprise-search/request.rb', line 62 def setup_authentication_header if instance_of? Elastic::EnterpriseSearch::Client basic_auth_header else case http_auth when Hash basic_auth_header when String "Bearer #{http_auth}" end end end |