Module: Occi::Api::Dsl

Includes:
HelperMethods, MainMethods, MixinMethods, TypeMethods
Defined in:
lib/occi/api/dsl/main_methods.rb,
lib/occi/api/dsl/type_methods.rb,
lib/occi/api/dsl/mixin_methods.rb,
lib/occi/api/dsl/helper_methods.rb,
lib/occi/api/dsl.rb,
lib/occi-api.rb

Defined Under Namespace

Modules: HelperMethods, MainMethods, MixinMethods, TypeMethods

Instance Method Summary collapse

Methods included from HelperMethods

#path_for_instance, #path_for_kind_type_identifier, #sanitize_instance_link

Methods included from MixinMethods

#mixin, #mixin_list, #mixins, #os_templates, #resource_templates

Methods included from TypeMethods

#action_type_identifier, #action_type_identifiers, #action_types, #category_type_identifier, #category_type_identifiers, #category_types, #entity_type_identifier, #entity_type_identifiers, #entity_types, #kind_type_identifier, #kind_type_identifiers, #kind_type_identifiers_related_to, #kind_types, #link_type_identifier, #link_type_identifiers, #link_types, #mixin_type_identifier, #mixin_type_identifiers, #mixin_types, #resource_type_identifier, #resource_type_identifiers, #resource_types

Methods included from MainMethods

#create, #delete, #describe, #list, #model, #refresh, #resource, #trigger

Instance Method Details

#checkObject (private)

Raises:

  • (RuntimeError)

41
42
43
44
# File 'lib/occi/api/dsl.rb', line 41

def check
  raise RuntimeError, "You have to issue 'connect' first!" unless @client
  raise RuntimeError, "Client is disconnected!" unless @client.connected
end

#connect(protocol = :http, options = {}) ⇒ Object

Raises:

  • (ArgumentError)

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/occi/api/dsl.rb', line 6

def connect(protocol = :http, options = {})
  raise ArgumentError, 'Protocol is a required argument!' unless protocol

  if block_given?
    options = options.marshal_dump if options.is_a?(OpenStruct)
    options = Hashie::Mash.new(options)
    yield(options)
  end

  case protocol.to_sym
  when :http 
    @client = Occi::Api::Client::ClientHttp.new(options)
  else
    raise ArgumentError, "Protocol #{protocol.to_s} is not supported!"
  end

  @client.connect unless @client.connected

  true
end