Class: Wavefront::Event
Overview
View and manage events. Events are identified by their millisecond epoch timestamp.
Instance Attribute Summary
Attributes inherited from CoreApi
Instance Method Summary collapse
-
#close(id) ⇒ Object
POST /api/v2/event/id/close Close a specific event.
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/event Create a specific event.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/event/id Delete a specific event.
-
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/event/id Get a specific event / Get a specific historical version of a specific event.
-
#list(from = nil, to = Time.now, limit = 100, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/event List all the events for a customer within a time range.
-
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/event/id/tag/tagValue Add a tag to a specific event.
-
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/event/id/tag/tagValue Remove a tag from a specific event.
-
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/event/id/tag Set all tags associated with a specific event.
-
#tags(id) ⇒ Wavefront::Response
GET /api/v2/event/id/tag Get all tags associated with a specific event.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/event/id Update a specific event.
- #update_keys ⇒ Object
Methods inherited from CoreApi
#api_base, #api_path, #hash_for_update, #initialize, #setup_api, #time_to_ms
Methods included from Mixins
#log, #parse_relative_time, #parse_time, #relative_time, #time_multiplier, #valid_relative_time?
Methods included from Validators
#uuid?, #wf_alert_id?, #wf_alert_severity?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_derivedmetric_id?, #wf_distribution?, #wf_distribution_count?, #wf_distribution_interval?, #wf_distribution_values?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_source_id?, #wf_string?, #wf_tag?, #wf_ts?, #wf_user_id?, #wf_usergroup_id?, #wf_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::CoreApi
Instance Method Details
#close(id) ⇒ Object
POST /api/v2/event/id/close Close a specific event.
113 114 115 116 |
# File 'lib/wavefront-sdk/event.rb', line 113 def close(id) wf_event_id?(id) api.post([id, 'close'].uri_concat) end |
#create(body) ⇒ Wavefront::Response
POST /api/v2/event Create a specific event.
We used to validate keys and provide helpers for time fields. Now ensuring a valid hash is entirely left up to the user. Refer to the Swagger docs for more information.
54 55 56 57 |
# File 'lib/wavefront-sdk/event.rb', line 54 def create(body) raise ArgumentError unless body.is_a?(Hash) api.post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/event/id Delete a specific event.
65 66 67 68 |
# File 'lib/wavefront-sdk/event.rb', line 65 def delete(id) wf_event_id?(id) api.delete(id) end |
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/event/id Get a specific event / Get a specific historical version of a specific event.
78 79 80 81 82 83 84 |
# File 'lib/wavefront-sdk/event.rb', line 78 def describe(id, version = nil) wf_event_id?(id) wf_version?(version) if version fragments = [id] fragments += ['history', version] if version api.get(fragments.uri_concat) end |
#list(from = nil, to = Time.now, limit = 100, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/event List all the events for a customer within a time range.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/wavefront-sdk/event.rb', line 26 def list(from = nil, to = Time.now, limit = 100, cursor = nil) raise ArgumentError unless from && to wf_event_id?(cursor) if cursor from = parse_time(from, true) to = parse_time(to, true) wf_ms_ts?(from) wf_ms_ts?(to) body = { earliestStartTimeEpochMillis: from, latestStartTimeEpochMillis: to, cursor: cursor, limit: limit } api.get('', body.cleanse) end |
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/event/id/tag/tagValue Add a tag to a specific event.
165 166 167 168 169 |
# File 'lib/wavefront-sdk/event.rb', line 165 def tag_add(id, tag) wf_event_id?(id) wf_string?(tag) api.put([id, 'tag', tag].uri_concat) end |
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/event/id/tag/tagValue Remove a tag from a specific event.
152 153 154 155 156 |
# File 'lib/wavefront-sdk/event.rb', line 152 def tag_delete(id, tag) wf_event_id?(id) wf_string?(tag) api.delete([id, 'tag', tag].uri_concat) end |
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/event/id/tag Set all tags associated with a specific event.
138 139 140 141 142 143 |
# File 'lib/wavefront-sdk/event.rb', line 138 def tag_set(id, ) wf_event_id?(id) = Array() .each { |t| wf_string?(t) } api.post([id, 'tag'].uri_concat, , 'application/json') end |
#tags(id) ⇒ Wavefront::Response
GET /api/v2/event/id/tag Get all tags associated with a specific event
125 126 127 128 |
# File 'lib/wavefront-sdk/event.rb', line 125 def (id) wf_event_id?(id) api.get([id, 'tag'].uri_concat) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/event/id Update a specific event
This method helps you update one or more properties of an event.
99 100 101 102 103 104 105 106 |
# File 'lib/wavefront-sdk/event.rb', line 99 def update(id, body, modify = true) wf_event_id?(id) raise ArgumentError unless body.is_a?(Hash) return api.put(id, body, 'application/json') unless modify api.put(id, hash_for_update(describe(id), body), 'application/json') end |
#update_keys ⇒ Object
9 10 11 |
# File 'lib/wavefront-sdk/event.rb', line 9 def update_keys %i[startTime endTime name annotations] end |