Class: Wavefront::Dashboard
- Includes:
- Mixin::Acl, Mixin::Tag
- Defined in:
- lib/wavefront-sdk/dashboard.rb
Overview
View and manage dashboards.
Instance Attribute Summary
Attributes inherited from CoreApi
Instance Method Summary collapse
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/dashboard Create a specific dashboard.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/dashboard/id Delete a specific dashboard.
-
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/dashboard/id GET /api/v2/dashboard/id/history/version Get a specific dashboard / Get a specific historical version of a specific dashboard.
-
#favorite(id) ⇒ Wavefront::Response
(also: #favourite)
POST /api/v2/dashboard/id/favorite Mark a dashboard as favorite.
-
#history(id) ⇒ Wavefront::Response
GET /api/v2/dashboard/id/history Get the version history of a dashboard.
-
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/dashboard Get all dashboards for a customer.
-
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/dashboard/id/undelete Move a dashboard from ‘trash’ back into active service.
-
#unfavorite(id) ⇒ Wavefront::Response
(also: #unfavourite)
POST /api/v2/dashboard/id/unfavorite Unmark a dashboard as favorite.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/dashboard/id Update a specific dashboard.
- #update_keys ⇒ Object
- #valid_id?(id) ⇒ Boolean
Methods included from Mixin::Tag
#tag_add, #tag_delete, #tag_set, #tags
Methods included from Mixin::Acl
#acl_add, #acl_delete, #acl_set, #acls
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_account_id?, #wf_alert_id?, #wf_alert_severity?, #wf_apitoken_id?, #wf_aws_external_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_ingestionpolicy_id?, #wf_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_metricspolicy_id?, #wf_monitoredapplication_id?, #wf_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_role_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_spansamplingpolicy_id?, #wf_string?, #wf_tag?, #wf_trace?, #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/dashboard Create a specific dashboard. Refer to the Swagger API docs for valid keys.
37 38 39 40 41 |
# File 'lib/wavefront-sdk/dashboard.rb', line 37 def create(body) raise ArgumentError unless body.is_a?(Hash) api.post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/dashboard/id Delete a specific dashboard. Deleting an active dashboard moves it to ‘trash’, from where it can be restored with an #undelete operation. Deleting a dashboard in ‘trash’ removes it for ever.
52 53 54 55 |
# File 'lib/wavefront-sdk/dashboard.rb', line 52 def delete(id) wf_dashboard_id?(id) api.delete(id) end |
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/dashboard/id GET /api/v2/dashboard/id/history/version Get a specific dashboard / Get a specific historical version of a specific dashboard.
66 67 68 69 70 71 72 |
# File 'lib/wavefront-sdk/dashboard.rb', line 66 def describe(id, version = nil) wf_dashboard_id?(id) wf_version?(version) if version fragments = [id] fragments += ['history', version] if version api.get(fragments.uri_concat) end |
#favorite(id) ⇒ Wavefront::Response Also known as: favourite
POST /api/v2/dashboard/id/favorite Mark a dashboard as favorite
101 102 103 104 |
# File 'lib/wavefront-sdk/dashboard.rb', line 101 def favorite(id) wf_dashboard_id?(id) api.post([id, 'favorite'].uri_concat) end |
#history(id) ⇒ Wavefront::Response
GET /api/v2/dashboard/id/history Get the version history of a dashboard.
113 114 115 116 |
# File 'lib/wavefront-sdk/dashboard.rb', line 113 def history(id) wf_dashboard_id?(id) api.get([id, 'history'].uri_concat) end |
#list(offset = 0, limit = 100) ⇒ Wavefront::Response
GET /api/v2/dashboard Get all dashboards for a customer.
26 27 28 |
# File 'lib/wavefront-sdk/dashboard.rb', line 26 def list(offset = 0, limit = 100) api.get('', offset: offset, limit: limit) end |
#undelete(id) ⇒ Wavefront::Response
POST /api/v2/dashboard/id/undelete Move a dashboard from ‘trash’ back into active service.
124 125 126 127 |
# File 'lib/wavefront-sdk/dashboard.rb', line 124 def undelete(id) wf_dashboard_id?(id) api.post([id, 'undelete'].uri_concat) end |
#unfavorite(id) ⇒ Wavefront::Response Also known as: unfavourite
POST /api/v2/dashboard/id/unfavorite Unmark a dashboard as favorite
135 136 137 138 |
# File 'lib/wavefront-sdk/dashboard.rb', line 135 def unfavorite(id) wf_dashboard_id?(id) api.post([id, 'unfavorite'].uri_concat) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/dashboard/id Update a specific dashboard.
85 86 87 88 89 90 91 92 93 |
# File 'lib/wavefront-sdk/dashboard.rb', line 85 def update(id, body, modify = true) wf_dashboard_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 |
#update_keys ⇒ Object
15 16 17 |
# File 'lib/wavefront-sdk/dashboard.rb', line 15 def update_keys %i[id name url description sections] end |
#valid_id?(id) ⇒ Boolean
141 142 143 |
# File 'lib/wavefront-sdk/dashboard.rb', line 141 def valid_id?(id) wf_dashboard_id?(id) end |