Retrieves available entity type identifier for the given entity type.
@example
client.get_entity_type_identifier("compute") # => 'http://schemas.ogf.org/occi/infrastructure#compute'
@param type [String] short entity type @return [String, nil] entity type identifier for the given entity type
# File lib/occi/api/client/base/entity_methods.rb, line 60 def get_entity_type_identifier(type) get_type_identifier(type, Occi::Core::Entity.kind) end
Retrieves all available entity 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 entity types in a OCCI ID format
# File lib/occi/api/client/base/entity_methods.rb, line 48 def get_entity_type_identifiers get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier end
Retrieves all available entity types.
@example
client.get_entity_types # => [ "entity", "resource", "link" ]
@return [Array<String>] list of available entity types in a human-readable format
# File lib/occi/api/client/base/entity_methods.rb, line 35 def get_entity_types get_types(Occi::Core::Entity.kind) end
Retrieves available link type identifier for the given link type.
@example
client.get_link_type_identifier("storagelink") # => 'http://schemas.ogf.org/occi/infrastructure#storagelink'
@param type [String] short link type @return [String, nil] link type identifier for the given link type
# File lib/occi/api/client/base/entity_methods.rb, line 129 def get_link_type_identifier(type) get_type_identifier(type, Occi::Core::Link.kind) end
Retrieves all available link type identifiers.
@example
client.get_link_type_identifiers # => [ "http://schemas.ogf.org/occi/infrastructure#storagelink", # "http://schemas.ogf.org/occi/infrastructure#networkinterface" ]
@return [Array<String>] list of available link types in a OCCI ID format
# File lib/occi/api/client/base/entity_methods.rb, line 117 def get_link_type_identifiers get_kind_type_identifiers_related_to Occi::Core::Link.kind.type_identifier end
Retrieves all available link types.
@example
client.get_link_types # => [ "storagelink", "networkinterface" ]
@return [Array<String>] list of available link types in a human-readable format
# File lib/occi/api/client/base/entity_methods.rb, line 105 def get_link_types get_types(Occi::Core::Link.kind) end
Creates a new resource instance, resource should be specified by its name or identifier.
@example
client.get_resource "compute" # => Occi::Core::Resource client.get_resource "storage" # => Occi::Core::Resource client.get_resource "http://schemas.ogf.org/occi/infrastructure#network" # => Occi::Core::Resource
@param resource_type [String] resource name or resource identifier @return [Occi::Core::Resource] new resource instance
# File lib/occi/api/client/base/entity_methods.rb, line 17 def get_resource(resource_type) Occi::Api::Log.debug("Instantiating #{resource_type.inspect}") type_id = get_resource_type_identifier(resource_type) raise "Unknown resource type! #{resource_type.inspect}" unless type_id new_resource = Occi::Core::Resource.new(type_id) new_resource.model = @model new_resource end
Retrieves available resource type identifier for the given resource type.
@example
client.get_resource_type_identifier("compute") # => 'http://schemas.ogf.org/occi/infrastructure#compute'
@param type [String] short resource type @return [String, nil] resource type identifier for the given resource type
# File lib/occi/api/client/base/entity_methods.rb, line 95 def get_resource_type_identifier(type) get_type_identifier(type, Occi::Core::Resource.kind) end
Retrieves all available resource type identifiers.
@example
client.get_resource_type_identifiers # => [ "http://schemas.ogf.org/occi/infrastructure#compute", # "http://schemas.ogf.org/occi/infrastructure#storage", # "http://schemas.ogf.org/occi/infrastructure#network" ]
@return [Array<String>] list of available resource types in a Occi ID format
# File lib/occi/api/client/base/entity_methods.rb, line 83 def get_resource_type_identifiers get_kind_type_identifiers_related_to Occi::Core::Resource.kind.type_identifier end
Retrieves all available resource types.
@example
client.get_resource_types # => [ "compute", "storage", "network" ]
@return [Array<String>] list of available resource types in a human-readable format
# File lib/occi/api/client/base/entity_methods.rb, line 70 def get_resource_types get_types(Occi::Core::Resource.kind) end
# File lib/occi/api/client/base/entity_methods.rb, line 135 def get_type_identifier(type, related_to) return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/')) collection = @model.get(related_to.type_identifier) e_kinds = collection.kinds.to_a.select { |e| e.term == type } tis = e_kinds.collect { |e| e.type_identifier } tis.uniq! if tis.length > 1 raise Occi::Api::Client::Errors::AmbiguousNameError, "#{related_to.type_identifier.split('#').capitalize} type " "#{type.inspect} is ambiguous, use a type identifier!" end tis.first end
# File lib/occi/api/client/base/entity_methods.rb, line 152 def get_types(related_to) collection = @model.get(related_to.type_identifier) collection ? collection.kinds.to_a.collect { |kind| kind.term } : [] end