Class: DogapiDemo::EventService
- Defined in:
- lib/dogapi-demo/event.rb
Overview
DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.
Constant Summary collapse
- API_VERSION =
"1.0.0"
- MAX_BODY_LENGTH =
4000
- MAX_TITLE_LENGTH =
100
Instance Method Summary collapse
-
#start(api_key, event, scope, source_type = nil) ⇒ Object
DEPRECATED: Going forward, use the V1 services.
-
#submit(api_key, event, scope = nil, source_type = nil) ⇒ Object
DEPRECATED: Going forward, use the V1 services.
Methods inherited from Service
#connect, #initialize, #request
Constructor Details
This class inherits a constructor from DogapiDemo::Service
Instance Method Details
#start(api_key, event, scope, source_type = nil) ⇒ Object
DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/dogapi-demo/event.rb', line 101 def start(api_key, event, scope, source_type=nil) warn "[DEPRECATION] DogapiDemo::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) ⇒ Object
DEPRECATED: Going forward, use the V1 services. This legacy service will be removed in an upcoming release.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/dogapi-demo/event.rb', line 71 def submit(api_key, event, scope=nil, source_type=nil) warn "[DEPRECATION] DogapiDemo::EventService.submit() has been deprecated in favor of the newer V1 services" scope = scope || DogapiDemo::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 |