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:



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

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:



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

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:



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

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:



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

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