Module: Collins::Api::Tag

Includes:
Util
Included in:
Collins::Api
Defined in:
lib/collins/api/tag.rb

Constant Summary

Constants included from Util::Logging

Util::Logging::DEFAULT_LOG_FORMAT

Instance Method Summary collapse

Methods included from Util

#deep_copy_hash, #get_asset_or_tag, included, #require_non_empty, #require_that, #stringify_hash, #symbolize_hash

Methods included from Util::Logging

#get_logger

Instance Method Details

#get_all_tagsArray<OpenStruct>

Get all collins tags

Sample output

Examples:

[
  {:name => "", :label => "", :description => ""},
]

Returns:

  • (Array<OpenStruct>)

    Array of tags containing name, label and description keys

Raises:



20
21
22
23
24
25
26
# File 'lib/collins/api/tag.rb', line 20

def get_all_tags
  http_get("/api/tags") do |response|
    parse_response response, :expects => 200, :default => [], :raise => strict? do |json|
      json["data"]["tags"].map{|t| OpenStruct.new(symbolize_hash(t))}
    end
  end
end

#get_tag_values(tag, strict = false) ⇒ Array<String>

Note:

You will get a 404 if the tag does not exist. Depending on strict mode, this will result in an empty array or an exception

Get all values associated with the specified tag

Parameters:

  • tag (String)

    The tag you would like values for

  • strict (Boolean) (defaults to: false)

    Here for backwards API compatibility

Returns:

  • (Array<String>)

    values associated with this tag

Raises:



35
36
37
38
39
40
41
# File 'lib/collins/api/tag.rb', line 35

def get_tag_values tag, strict = false
  http_get("/api/tag/#{tag}") do |response|
    parse_response response, :expects => 200, :default => [], :raise => strict?(strict) do |json|
      json["data"]["values"]
    end
  end
end