Class: Occi::Api::Client::ClientBase
- Inherits:
-
Object
- Object
- Occi::Api::Client::ClientBase
- Includes:
- Base::ActionMethods, Base::CategoryMethods, Base::EntityMethods, Base::Helpers, Base::KindMethods, Base::MixinMethods, Base::ProtectedHelpers, Base::ProtectedStubs, Base::Stubs
- Defined in:
- lib/occi/api/client/client_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auth_options ⇒ Object
readonly
a few attributes which should be visible outside the client.
-
#connected ⇒ Object
readonly
Returns the value of attribute connected.
-
#endpoint ⇒ Object
readonly
a few attributes which should be visible outside the client.
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#media_type ⇒ Object
readonly
a few attributes which should be visible outside the client.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#connect(force = false) ⇒ Boolean
Issues necessary connecting operations on connection-oriented clients.
-
#initialize(options = {}) ⇒ ClientBase
constructor
A new instance of ClientBase.
Methods included from Base::ProtectedHelpers
#get_endpoint_uri, #get_logger, #get_model, #get_os_tpl_mixins_ary, #get_resource_tpl_mixins_ary
Methods included from Base::ProtectedStubs
#configure_connection, #get_auth, #get_media_type, #preauthenticate
Methods included from Base::Helpers
#path_for_instance, #path_for_kind_type_identifier, #sanitize_instance_link
Methods included from Base::MixinMethods
#describe_mixin, #describe_mixin_w_type, #describe_mixin_wo_type, #get_mixin, #get_mixin_type_identifier, #get_mixin_type_identifiers, #get_mixin_types, #get_mixins, #get_os_templates, #get_resource_templates, #list_mixin, #list_mixins
Methods included from Base::EntityMethods
#get_entity_type_identifier, #get_entity_type_identifiers, #get_entity_types, #get_link, #get_link_type_identifier, #get_link_type_identifiers, #get_link_types, #get_resource, #get_resource_type_identifier, #get_resource_type_identifiers, #get_resource_types, #get_type_identifier, #get_types
Methods included from Base::KindMethods
#get_kind_type_identifier, #get_kind_type_identifiers, #get_kind_type_identifiers_related_to, #get_kind_types
Methods included from Base::CategoryMethods
#get_category_type_identifier, #get_category_type_identifiers, #get_category_types
Methods included from Base::ActionMethods
#get_action_type_identifier, #get_action_type_identifiers, #get_action_types
Methods included from Base::Stubs
#create, #delete, #describe, #list, #refresh, #trigger, #update
Constructor Details
#initialize(options = {}) ⇒ ClientBase
Returns a new instance of ClientBase.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/occi/api/client/client_base.rb', line 13 def initialize( = {}) # define defaults and convert options to Hashie::Mash if necessary defaults = Hashie::Mash.new({ :endpoint => "http://localhost:3000/", :auth => {:type => "none"}, :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil}, :auto_connect => true, :media_type => nil }) = .marshal_dump if .is_a?(OpenStruct) = Hashie::Mash.new() @options = defaults.merge() # set Occi::Api::Log @logger = get_logger(@options[:log]) # check the validity and canonize the endpoint URI @endpoint = get_endpoint_uri(@options[:endpoint]) # set global connection options, such as timeout configure_connection(@options) # pass auth options @auth_options = get_auth(@options[:auth]) # verify authN before attempting actual # message exchange with the server; this # is necessary because of OCCI-OS and its # redirect to OS Keystone preauthenticate # set accepted media types @media_type = get_media_type(@options[:media_type]) @connected = false end |
Instance Attribute Details
#auth_options ⇒ Object (readonly)
a few attributes which should be visible outside the client
9 10 11 |
# File 'lib/occi/api/client/client_base.rb', line 9 def @auth_options end |
#connected ⇒ Object (readonly)
Returns the value of attribute connected.
10 11 12 |
# File 'lib/occi/api/client/client_base.rb', line 10 def connected @connected end |
#endpoint ⇒ Object (readonly)
a few attributes which should be visible outside the client
9 10 11 |
# File 'lib/occi/api/client/client_base.rb', line 9 def endpoint @endpoint end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
10 11 12 |
# File 'lib/occi/api/client/client_base.rb', line 10 def last_response @last_response end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/occi/api/client/client_base.rb', line 10 def logger @logger end |
#media_type ⇒ Object (readonly)
a few attributes which should be visible outside the client
9 10 11 |
# File 'lib/occi/api/client/client_base.rb', line 9 def media_type @media_type end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'lib/occi/api/client/client_base.rb', line 10 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/occi/api/client/client_base.rb', line 11 def @options end |
Instance Method Details
#connect(force = false) ⇒ Boolean
Issues necessary connecting operations on connection-oriented clients. Stateless clients (such as ClientHttp) should use the auto_connect option during instantiation.
61 62 63 64 |
# File 'lib/occi/api/client/client_base.rb', line 61 def connect(force = false) raise "Client already connected!" if @connected && !force @connected = true end |