module Occi::Api::Client::Base::KindMethods

Public Instance Methods

get_kind_type_identifier(type) click to toggle source

Retrieves available kind type identifier for the given kind type.

@example

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

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

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

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

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

  tis.first
end
get_kind_type_identifiers() click to toggle source

Retrieves all available kind type identifiers.

@example

client.get_kind_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 kind type identifiers

# File lib/occi/api/client/base/kind_methods.rb, line 41
def get_kind_type_identifiers
  @model.kinds.to_a.collect { |kind| kind.type_identifier }
end
get_kind_types() click to toggle source

Retrieves all available kind types.

@example

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

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

# File lib/occi/api/client/base/kind_methods.rb, line 28
def get_kind_types
  @model.kinds.to_a.collect { |kind| kind.term }
end