class Dogapi::Service
DEPRECATED: Going forward, use the newer APIService.
Public Class Methods
new(api_key, api_host=Dogapi.find_datadog_host)
click to toggle source
DEPRECATED: Going forward, use the newer APIService.
# File lib/dogapi/common.rb, line 24 def initialize(api_key, api_host=Dogapi.find_datadog_host) @api_key = api_key @host = api_host end
Public Instance Methods
connect() { |conn| ... }
click to toggle source
DEPRECATED: Going forward, use the newer APIService.
# File lib/dogapi/common.rb, line 30 def connect warn "[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services" uri = URI.parse(@host) session = Net::HTTP.new(uri.host, uri.port) if 'https' == uri.scheme session.use_ssl = true end session.start do |conn| yield(conn) end end
request(method, url, params)
click to toggle source
DEPRECATED: Going forward, use the newer APIService.
# File lib/dogapi/common.rb, line 43 def request(method, url, params) warn "[DEPRECATION] Dogapi::Service has been deprecated in favor of the newer V1 services" if !params.has_key? :api_key params[:api_key] = @api_key end resp_obj = nil connect do |conn| req = method.new(url) req.set_form_data params resp = conn.request(req) begin resp_obj = MultiJson.load(resp.body) rescue raise 'Invalid JSON Response: ' + resp.body end if resp_obj.has_key? 'error' request_string = params.pretty_inspect error_string = resp_obj['error'] raise "Failed request\n#{request_string}#{error_string}" end end resp_obj end