module Occi::Api::Client::Base::ActionMethods

Public Instance Methods

get_action_type_identifier(type, for_kind_w_term = nil) click to toggle source

Retrieves available action type identifier for the given action type.

@example

client.get_action_type_identifier("start")
 # => 'http://schemas.ogf.org/occi/infrastructure/compute/action#start'
client.get_action_type_identifier("start", "compute")
 # => 'http://schemas.ogf.org/occi/infrastructure/compute/action#start'
client.get_action_type_identifier("start", "storage")
 # => nil

@param type [String] short action type @param for_kind_w_term [String] kind the action belongs to (e.g. “compute”, “network”, …) @return [String, nil] action type identifier for the given action type

# File lib/occi/api/client/base/action_methods.rb, line 42
def get_action_type_identifier(type, for_kind_w_term = nil)
  return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))

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

  tis.keep_if { |ti| ti.include? "/#{for_kind_w_term}/" } unless for_kind_w_term.blank?

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

  tis.first
end
get_action_type_identifiers() click to toggle source

Retrieves all available action type identifiers.

@example

client.get_action_type_identifiers
# => [ "http://schemas.ogf.org/occi/infrastructure/compute/action#start",
#      "http://schemas.ogf.org/occi/infrastructure/compute/action#stop",
#      "http://schemas.ogf.org/occi/infrastructure/compute/action#suspend" ]

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

# File lib/occi/api/client/base/action_methods.rb, line 25
def get_action_type_identifiers
  @model.actions.to_a.collect { |action| action.type_identifier }
end
get_action_types() click to toggle source

Retrieves all available action types.

@example

client.get_action_types # => [ "stop", "start", "up", "down" ]

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

# File lib/occi/api/client/base/action_methods.rb, line 12
def get_action_types
  @model.actions.to_a.collect { |action| action.term }
end