Class: Wavefront::Source
- Includes:
- Mixin::Tag
- Defined in:
- lib/wavefront-sdk/source.rb
Overview
View and manage source metadata.
Instance Attribute Summary
Attributes inherited from CoreApi
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.
-
#description_delete(id) ⇒ Object
DELETE /api/v2/source/id/description Remove description from a specific source.
-
#description_set(id, description) ⇒ Object
POST /api/v2/source/id/description Set description associated with a specific source.
-
#list(limit = nil, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/source Get all sources for a customer.
-
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/source/id Update metadata (description or tags) for a specific source.
- #update_keys ⇒ Object
- #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_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/source Create metadata (description or tags) for a specific source.
Refer to the Swagger API docs for valid keys.
40 41 42 43 44 |
# File 'lib/wavefront-sdk/source.rb', line 40 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.
52 53 54 55 |
# File 'lib/wavefront-sdk/source.rb', line 52 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.
80 81 82 83 84 85 86 |
# File 'lib/wavefront-sdk/source.rb', line 80 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 |
#description_delete(id) ⇒ Object
DELETE /api/v2/source/id/description Remove description from a specific source
69 70 71 72 |
# File 'lib/wavefront-sdk/source.rb', line 69 def description_delete(id) wf_source_id?(id) api.delete([id, 'description'].uri_concat) end |
#description_set(id, description) ⇒ Object
POST /api/v2/source/id/description Set description associated with a specific source
60 61 62 63 64 |
# File 'lib/wavefront-sdk/source.rb', line 60 def description_set(id, description) wf_source_id?(id) api.post([id, 'description'].uri_concat, description, 'application/json') end |
#list(limit = nil, cursor = nil) ⇒ Wavefront::Response
GET /api/v2/source Get all sources for a customer
24 25 26 27 28 29 30 |
# File 'lib/wavefront-sdk/source.rb', line 24 def list(limit = nil, cursor = nil) qs = {} qs[:limit] = limit if limit qs[:cursor] = cursor if cursor api.get('', qs) end |
#update(id, body, modify = true) ⇒ Wavefront::Response
PUT /api/v2/source/id Update metadata (description or tags) for a specific source.
99 100 101 102 103 104 105 106 107 |
# File 'lib/wavefront-sdk/source.rb', line 99 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
13 14 15 |
# File 'lib/wavefront-sdk/source.rb', line 13 def update_keys %i[sourceName tags description] end |
#valid_id?(id) ⇒ Boolean
109 110 111 |
# File 'lib/wavefront-sdk/source.rb', line 109 def valid_id?(id) wf_source_id?(id) end |