module Occi::Api::Client::Base::CategoryMethods

Public Instance Methods

get_category_type_identifier(type) click to toggle source

Retrieves available category type identifier for the given category type.

@example

client.get_category_type_identifier("compute")
 # => 'http://schemas.ogf.org/occi/infrastructure#compute'

@param type [String] short category type @return [String, nil] category type identifier for the given category type

# File lib/occi/api/client/base/category_methods.rb, line 37
def get_category_type_identifier(type)
  return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))

  cats = @model.categories.to_a.select { |k| k.term == type }
  tis = cats.collect { |c| c.type_identifier }
  tis.uniq!

  if tis.length > 1
    raise Occi::Api::Client::Errors::AmbiguousNameError,
          "Category type #{type.inspect} is ambiguous, use a type identifier!"
  end

  tis.first
end
get_category_type_identifiers() click to toggle source

Retrieves all available category type identifiers.

@example

client.get_category_type_identifiers
# => [ "http://schemas.ogf.org/occi/core#entity",
#      "http://schemas.ogf.org/occi/core#resource",
#      "http://schemas.ogf.org/occi/core#link" ]

@return [Array<String>] list of available category type identifiers

# File lib/occi/api/client/base/category_methods.rb, line 25
def get_category_type_identifiers
  @model.categories.to_a.collect { |category| category.type_identifier }
end
get_category_types() click to toggle source

Retrieves all available category types.

@example

client.get_category_types # => [ "entity", "resource", "link" ]

@return [Array<String>] list of available category types in a human-readable format

# File lib/occi/api/client/base/category_methods.rb, line 12
def get_category_types
  @model.categories.to_a.collect { |category| category.term }
end