class StudioApi::Connection

Represents information needed for connection to studio. In common case it is just needed once initialize and then pass it to classes.

Constants

SSL_ATTRIBUTES

SSL attributes which can be set into ssl attributes. For more details see openssl library

Attributes

password[R]

Represents API key for studio API

proxy[R]

Represents proxy object needed for connection to studio API. nil represents that no proxy needed

ssl[R]

Represents settings for SSL verification in case of uri is https. It is Hash with keys from SSL_ATTRIBUTES

timeout[R]

Represents timeout for connection in seconds.

uri[R]

Represents URI pointing to studio site including path to API @example

connection.uri == URI.parse "http://susestudio.com/api/v1/user/"
user[R]

Represents login name for studio API

Public Class Methods

new(user, password, uri, options={}) click to toggle source

Creates new object @example

StudioApi::Connection.new "user","pwd","https://susestudio.com//api/v1/user/",
                          :timeout => 120, :proxy => "http://user:pwd@proxy",
                          :ssl => { :verify_mode => OpenSSL::SSL::VERIFY_PEER,
                                    :ca_path => "/etc/studio.cert"}

@param [String] user login to studio API @param (String) password API key for studio @param (String,URI) uri pointing to studio site including path to api @param (Hash) options hash of additional options. Represents other attributes. @option options [URI,String] :proxy (nil) see proxy attribute @option options [String, Fixnum] :timeout (45) see timeout attribute. Specified in seconds @option options [Hash] :ssl ( {:verify_mode = OpenSSL::SSL::VERIFY_NONE}) see ssl attribute

# File lib/studio_api/connection.rb, line 61
def initialize(user, password, uri, options={})
  @user = user
  @password = password
  self.uri = uri
  self.proxy = options[:proxy] #nil as default is OK
  @timeout = (options[:timeout] || 45).to_i
  @ssl = options[:ssl] || { :verify_mode => OpenSSL::SSL::VERIFY_NONE } # don't verify as default
end

Public Instance Methods

api_version() click to toggle source
# File lib/studio_api/connection.rb, line 70
def api_version
  @version ||= version_detect
end

Protected Instance Methods

proxy=(value) click to toggle source

Overwritte proxy object. @param (String,URI,nil) value new proxy to site. If String is passed then it is parsed by URI.parse, which can throw exception. If nil is passed then it means disable proxy.

# File lib/studio_api/connection.rb, line 87
def proxy=(value)
  if value.is_a? String
    @proxy = URI.parse value
  else
    @proxy = value
  end
end
uri=(value) click to toggle source

Overwritte uri object. @param (String,URI) value new uri to site. If String is passed then it is parsed by URI.parse, which can throw exception

# File lib/studio_api/connection.rb, line 77
def uri=(value)
  if value.is_a? String
    @uri = URI.parse value
  else
    @uri = value
  end
end