Class: Wavefront::DerivedMetric
- Includes:
- Mixin::Tag
- Defined in:
- lib/wavefront-sdk/derivedmetric.rb
Overview
View and manage derived metrics
Instance Attribute Summary
Attributes inherited from CoreApi
#api, #creds, #logger, #opts, #update_keys
Instance Method Summary collapse
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/derivedmetric Create a specific derived metric definition.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/derivedmetric/id Delete a specific derived metric definition.
-
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/derivedmetric/id Get a specific derived metric definition / Get a specific historical version of a specific derived metric definition.
-
#history(id) ⇒ Wavefront::Response
GET /api/v2/derivedmetric/id/history Get the version history of a derived metric definition.
-
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/derivedmetric Get all derived metric definitions for a customer.
-
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/derivedmetric/id/undelete Move a derived metric definition from ‘trash’ back into active service.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/derivedmetric/id Update a specific derived metric definition.
- #valid_id?(id) ⇒ Boolean
Methods included from Mixin::Tag
#tag_add, #tag_delete, #tag_set, #tags
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_apitoken_id?, #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
#create(body) ⇒ Wavefront::Response
POST /api/v2/derivedmetric Create a specific derived metric definition. Refer to the Swagger API docs for valid keys.
29 30 31 32 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 29 def create(body) raise ArgumentError unless body.is_a?(Hash) api.post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/derivedmetric/id Delete a specific derived metric definition. Deleting an active derived metric moves it to ‘trash’, from where it can be restored with an #undelete operation. Deleting a derived metric in ‘trash’ removes it for ever.
43 44 45 46 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 43 def delete(id) wf_derivedmetric_id?(id) api.delete(id) end |
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/derivedmetric/id Get a specific derived metric definition / Get a specific historical version of a specific derived metric definition.
56 57 58 59 60 61 62 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 56 def describe(id, version = nil) wf_derivedmetric_id?(id) wf_version?(version) if version fragments = [id] fragments += ['history', version] if version api.get(fragments.uri_concat) end |
#history(id) ⇒ Wavefront::Response
GET /api/v2/derivedmetric/id/history Get the version history of a derived metric definition.
91 92 93 94 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 91 def history(id) wf_derivedmetric_id?(id) api.get([id, 'history'].uri_concat) end |
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/derivedmetric Get all derived metric definitions for a customer.
18 19 20 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 18 def list(offset = 0, limit = 100) api.get('', offset: offset, limit: limit) end |
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/derivedmetric/id/undelete Move a derived metric definition from ‘trash’ back into active service.
103 104 105 106 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 103 def undelete(id) wf_derivedmetric_id?(id) api.post([id, 'undelete'].uri_concat) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/derivedmetric/id Update a specific derived metric definition.
75 76 77 78 79 80 81 82 83 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 75 def update(id, body, modify = true) wf_derivedmetric_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).response, body), 'application/json') end |
#valid_id?(id) ⇒ Boolean
108 109 110 |
# File 'lib/wavefront-sdk/derivedmetric.rb', line 108 def valid_id?(id) wf_derivedmetric_id?(id) end |