class Wavefront::Source

View and manage source metadata.

Public Instance Methods

create(body) click to toggle source

POST /api/v2/source Create metadata (description or tags) for a specific source.

Refer to the Swagger API docs for valid keys.

@param body [Hash] description of source @return [Wavefront::Response]

# 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) click to toggle source

DELETE /api/v2/source/id Delete metadata (description and tags) for a specific source.

@param id [String] ID of the source @return [Wavefront::Response]

# File lib/wavefront-sdk/source.rb, line 52
def delete(id)
  wf_source_id?(id)
  api.delete(id)
end
describe(id, version = nil) click to toggle source

GET /api/v2/source/id Get a specific source for a customer.

@param id [String] ID of the source @return [Wavefront::Response]

# 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) click to toggle source

DELETE /api/v2/source/id/description Remove description from a specific source

# 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) click to toggle source

POST /api/v2/source/id/description Set description associated with a specific source

# 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) click to toggle source

GET /api/v2/source Get all sources for a customer

@param limit [Integer] the number of sources to return @param cursor [String] source at which the list begins @return [Wavefront::Response]

# 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) click to toggle source

PUT /api/v2/source/id Update metadata (description or tags) for a specific source.

@param id [String] a Wavefront alert ID @param body [Hash] key-value hash of the parameters you wish

to change

@param modify [true, false] if true, use {#describe()} to get

a hash describing the existing object, and modify that with
the new body. If false, pass the new body straight through.

@return [Wavefront::Response]

# 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() click to toggle source
# File lib/wavefront-sdk/source.rb, line 13
def update_keys
  %i[sourceName tags description]
end
valid_id?(id) click to toggle source
# File lib/wavefront-sdk/source.rb, line 109
def valid_id?(id)
  wf_source_id?(id)
end