Module: Wavefront::Mixin::Tag

Included in:
Alert, Dashboard, DerivedMetric, Event, Source
Defined in:
lib/wavefront-sdk/api_mixins/tag.rb

Overview

Tagging support.

Mix this module into class which supports tags, ensuring there is a valid_id? method to perform ID validation.

Instance Method Summary collapse

Instance Method Details

#tag_add(id, tag) ⇒ Wavefront::Response

PUT /api/v2/object/id/tag/tagValue Add a tag to a specific object.

Parameters:

  • id (String)

    ID of the object

  • tag (String)

    tag to set.

Returns:



57
58
59
60
61
# File 'lib/wavefront-sdk/api_mixins/tag.rb', line 57

def tag_add(id, tag)
  valid_id?(id)
  wf_string?(tag)
  api.put([id, 'tag', tag].uri_concat)
end

#tag_delete(id, tag) ⇒ Wavefront::Response

DELETE /api/v2/object/id/tag/tagValue Remove a tag from a specific object.

Parameters:

  • id (String)

    ID of the object

  • tag (String)

    tag to delete

Returns:



44
45
46
47
48
# File 'lib/wavefront-sdk/api_mixins/tag.rb', line 44

def tag_delete(id, tag)
  valid_id?(id)
  wf_string?(tag)
  api.delete([id, 'tag', tag].uri_concat)
end

#tag_set(id, tags) ⇒ Wavefront::Response

POST /api/v2/object/id/tag Set all tags associated with a specific object.

Parameters:

  • id (String)

    ID of the object

  • tags (Array)

    list of tags to set.

Returns:



30
31
32
33
34
35
# File 'lib/wavefront-sdk/api_mixins/tag.rb', line 30

def tag_set(id, tags)
  valid_id?(id)
  tags = Array(tags)
  tags.each { |t| wf_string?(t) }
  api.post([id, 'tag'].uri_concat, tags.to_json, 'application/json')
end

#tags(id) ⇒ Wavefront::Response

GET /api/v2/object/id/tag Get all tags associated with a specific object.

Parameters:

  • id (String)

    ID of the object

Returns:



18
19
20
21
# File 'lib/wavefront-sdk/api_mixins/tag.rb', line 18

def tags(id)
  valid_id?(id)
  api.get([id, 'tag'].uri_concat)
end