Module: InfluxDB::HTTP

Included in:
Client
Defined in:
lib/influxdb/client/http.rb

Overview

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

Instance Method Summary collapse

Instance Method Details

#get(url, options = {}) ⇒ Object

:nodoc:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/influxdb/client/http.rb', line 10

def get(url, options = {})
  connect_with_retry do |http|
    response = do_request http, Net::HTTP::Get.new(url)
    case response
    when Net::HTTPSuccess
      handle_successful_response(response, options)
    when Net::HTTPUnauthorized
      raise InfluxDB::AuthenticationError, response.body
    else
      resolve_error(response.body)
    end
  end
end

#post(url, data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/influxdb/client/http.rb', line 24

def post(url, data)
  headers = { "Content-Type" => "application/octet-stream" }
  connect_with_retry do |http|
    response = do_request http, Net::HTTP::Post.new(url, headers), data

    case response
    when Net::HTTPNoContent
      return response
    when Net::HTTPUnauthorized
      raise InfluxDB::AuthenticationError, response.body
    else
      resolve_error(response.body)
    end
  end
end