class Dogapi::EventService

DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.

Constants

API_VERSION
MAX_BODY_LENGTH
MAX_TITLE_LENGTH

Public Instance Methods

start(api_key, event, scope, source_type=nil) { |response| ... } click to toggle source

DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.

# File lib/dogapi/event.rb, line 101
def start(api_key, event, scope, source_type=nil)
  warn "[DEPRECATION] Dogapi::EventService.start() has been deprecated in favor of the newer V1 services"
  response = submit api_key, event, scope, source_type
  success = nil

  begin
    yield response
  rescue
    success = false
    raise
  else
    success = true
  ensure
    return finish api_key, response['id'], success
  end
end
submit(api_key, event, scope=nil, source_type=nil) click to toggle source

DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.

# File lib/dogapi/event.rb, line 71
def submit(api_key, event, scope=nil, source_type=nil)
  warn "[DEPRECATION] Dogapi::EventService.submit() has been deprecated in favor of the newer V1 services"
  scope = scope || Dogapi::Scope.new()
  params = {
    :api_key => api_key,
    :api_version  =>  API_VERSION,

    :host =>    scope.host,
    :device =>  scope.device,

    :metric =>  event.metric,
    :date_detected => event.date_detected,
    :date_happened => event.date_happened,
    :alert_type => event.alert_type,
    :event_type => event.event_type,
    :event_object => event.event_object,
    :msg_title => event.msg_title[0..MAX_TITLE_LENGTH - 1],
    :msg_text => event.msg_text[0..MAX_BODY_LENGTH - 1],
    :json_payload => event.json_payload,
  }

  if source_type
    params[:source_type] = source_type
  end

  request Net::HTTP::Post, '/event/submit', params
end

Private Instance Methods

finish(api_key, event_id, successful=nil) click to toggle source
# File lib/dogapi/event.rb, line 120
def finish(api_key, event_id, successful=nil)
  params = {
    :api_key => api_key,
    :event_id => event_id
  }

  request Net::HTTP::Post, '/event/ended', params
end