Class: Crowbar::Client::Request::Rest

Inherits:
RestClient::Resource
  • Object
show all
Defined in:
lib/crowbar/client/request/rest.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Rest

Returns a new instance of Rest.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/crowbar/client/request/rest.rb', line 23

def initialize(options = {})
  url = options.fetch(:url, "")
  user = options.fetch(:user, Config.username)
  password = options.fetch(:password, Config.password)
  auth_type = options.fetch(:auth_type, :digest)
  verify_ssl = options.fetch(:verify_ssl, Config.verify_ssl)

  Config.debug && RestClient.log = "stdout"

  super(
    [
      Config.server,
      "/",
      url
    ].join(""),
    user: URI::DEFAULT_PARSER.escape(user, URI::PATTERN::RESERVED),
    password: URI::DEFAULT_PARSER.escape(password, URI::PATTERN::RESERVED),
    auth_type: auth_type,
    verify_ssl: verify_ssl,
    timeout: Config.timeout
  )
end