Class: Wavefront::Source
Overview
View and manage source metadata.
Instance Attribute Summary
Attributes inherited from Base
#api_base, #conn, #debug, #logger, #net, #noop, #opts, #verbose
Instance Method Summary collapse
-
#create(body) ⇒ Wavefront::Response
POST /api/v2/source Create metadata (description or tags) for a specific source.
-
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/source/id Delete metadata (description and tags) for a specific source.
-
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/source/id Get a specific source for a customer.
-
#list(limit = nil, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/source Get all sources for a customer.
-
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/source/id/tag/tagValue Add a tag to a specific source.
-
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/source/id/tag/tagValue Remove a tag from a specific source.
-
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/source/id/tag Set all tags associated with a specific source.
-
#tags(id) ⇒ Wavefront::Response
GET /api/v2/source/id/tag Get all tags associated with a specific source.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/source/id Update metadata (description or tags) for a specific source.
- #update_keys ⇒ Object
Methods inherited from Base
#api_delete, #api_get, #api_post, #api_put, #hash_for_update, #initialize, #log, #mk_conn, #respond, #time_to_ms
Methods included from Mixins
Methods included from Validators
#wf_alert_id?, #wf_alert_severity?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_ms_ts?, #wf_name?, #wf_point?, #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_value?, #wf_version?, #wf_webhook_id?
Constructor Details
This class inherits a constructor from Wavefront::Base
Instance Method Details
#create(body) ⇒ Wavefront::Response
POST /api/v2/source Create metadata (description or tags) for a specific source.
Refer to the Swagger API docs for valid keys.
35 36 37 38 |
# File 'lib/wavefront-sdk/source.rb', line 35 def create(body) raise ArgumentError unless body.is_a?(Hash) api_post('', body, 'application/json') end |
#delete(id) ⇒ Wavefront::Response
DELETE /api/v2/source/id Delete metadata (description and tags) for a specific source.
46 47 48 49 |
# File 'lib/wavefront-sdk/source.rb', line 46 def delete(id) wf_source_id?(id) api_delete(id) end |
#describe(id, version = nil) ⇒ Wavefront::Response
GET /api/v2/source/id Get a specific source for a customer.
57 58 59 60 61 62 63 |
# File 'lib/wavefront-sdk/source.rb', line 57 def describe(id, version = nil) wf_source_id?(id) wf_version?(version) if version fragments = [id] fragments += ['history', version] if version api_get(fragments.uri_concat) end |
#list(limit = nil, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/source Get all sources for a customer
19 20 21 22 23 24 25 |
# File 'lib/wavefront-sdk/source.rb', line 19 def list(limit = nil, cursor = nil) qs = {} qs[:limit] = limit if limit qs[:cursor] = cursor if cursor api_get('', qs) end |
#tag_add(id, tag) ⇒ Wavefront::Response
PUT /api/v2/source/id/tag/tagValue Add a tag to a specific source
131 132 133 134 135 |
# File 'lib/wavefront-sdk/source.rb', line 131 def tag_add(id, tag) wf_source_id?(id) wf_string?(tag) api_put([id, 'tag', tag].uri_concat) end |
#tag_delete(id, tag) ⇒ Wavefront::Response
DELETE /api/v2/source/id/tag/tagValue Remove a tag from a specific source.
118 119 120 121 122 |
# File 'lib/wavefront-sdk/source.rb', line 118 def tag_delete(id, tag) wf_source_id?(id) wf_string?(tag) api_delete([id, 'tag', tag].uri_concat) end |
#tag_set(id, tags) ⇒ Wavefront::Response
POST /api/v2/source/id/tag Set all tags associated with a specific source.
104 105 106 107 108 109 |
# File 'lib/wavefront-sdk/source.rb', line 104 def tag_set(id, ) wf_source_id?(id) = Array() .each { |t| wf_string?(t) } api_post([id, 'tag'].uri_concat, .to_json, 'application/json') end |
#tags(id) ⇒ Wavefront::Response
GET /api/v2/source/id/tag Get all tags associated with a specific source.
92 93 94 95 |
# File 'lib/wavefront-sdk/source.rb', line 92 def (id) wf_source_id?(id) api_get([id, 'tag'].uri_concat) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/source/id Update metadata (description or tags) for a specific source.
76 77 78 79 80 81 82 83 84 |
# File 'lib/wavefront-sdk/source.rb', line 76 def update(id, body, modify = true) wf_source_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
8 9 10 |
# File 'lib/wavefront-sdk/source.rb', line 8 def update_keys i(sourceName description) end |