Module: Occi::Api::Client::Base::ProtectedStubs

Included in:
ClientBase
Defined in:
lib/occi/api/client/base/protected_stubs.rb

Instance Method Summary collapse

Instance Method Details

#configure_connection(options) ⇒ Object

Sets global connection options before the first call to a remote server is made. For example, this allows the configuration of a global connection timeout, including pre-authentication and authentication calls.

Examples:

configure_connection { :timeout => 180 }

Parameters:

  • options (Hash)

    global options

Raises:


15
16
17
# File 'lib/occi/api/client/base/protected_stubs.rb', line 15

def configure_connection(options)
  raise Occi::Api::Client::Errors::NotImplementedError, "#{__method__} is just a stub!"
end

#get_auth(auth_options, fallback = false) ⇒ Hash

Sets auth method and appropriate httparty attributes. Supported auth methods are: ["basic", "digest", "x509", "none"]

Examples:

get_auth { :type => "none" }
get_auth { :type => "basic", :username => "123", :password => "321" }
get_auth { :type => "digest", :username => "123", :password => "321" }
get_auth { :type => "x509", :user_cert => "~/cert.pem",
              :user_cert_password => "321", :ca_path => nil }

Parameters:

  • auth_options (Hash)

    authentication options

  • fallback (Boolean) (defaults to: false)

    allow fallback-only options

Returns:

  • (Hash)

    transformed hash with authN information

Raises:


32
33
34
# File 'lib/occi/api/client/base/protected_stubs.rb', line 32

def get_auth(auth_options, fallback = false)
  raise Occi::Api::Client::Errors::NotImplementedError, "#{__method__} is just a stub!"
end

#get_media_type(force_type = nil) ⇒ String

Sets media type. Will choose either application/occi+json or text/plain based on the formats supported by the server.

Examples:

get_media_type # => 'application/occi+json'

Parameters:

  • force_type (String) (defaults to: nil)

    type to be forcibly chosen

Returns:

  • (String)

    chosen media type

Raises:


51
52
53
# File 'lib/occi/api/client/base/protected_stubs.rb', line 51

def get_media_type(force_type = nil)
  raise Occi::Api::Client::Errors::NotImplementedError, "#{__method__} is just a stub!"
end

#preauthenticateObject

Attempts to establish a preliminary connection with the server to verify provided credentials and perform fallback authN if necessary. Has to be invoked after @auth_options have been set.


39
40
41
# File 'lib/occi/api/client/base/protected_stubs.rb', line 39

def preauthenticate
  raise Occi::Api::Client::Errors::NotImplementedError, "#{__method__} is just a stub!"
end