Class: RedhatAccess::Strata::Client

Inherits:
Object
  • Object
show all
Includes:
Katello::Util::HttpProxy
Defined in:
lib/redhat_access/strata/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/redhat_access/strata/client.rb', line 7

def initialize(token)
  username = ""
  password = ""
  unless token.nil?
    token = Base64.decode64(token)
    username,password = token.split(":")
  end
  config = RedHatSupportLib::Network::Config.new
  config.base_uri = 'https://api.' + REDHAT_ACCESS_CONFIG[:strata_host]
  config.username= username
  config.password = password
  config.proxy = get_portal_http_proxy
  attachments_config = {:max_http_size => REDHAT_ACCESS_CONFIG[:attachment_max_http_size],
                        :ftp_host => REDHAT_ACCESS_CONFIG[:attachment_ftp_host],
                        :ftp_remote_dir => REDHAT_ACCESS_CONFIG[:attachment_ftp_dir]}
  @api = RedHatSupportLib::Api::API.new(config,attachments_config)
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



6
7
8
# File 'lib/redhat_access/strata/client.rb', line 6

def api
  @api
end

Instance Method Details

#get_portal_http_proxyObject



25
26
27
28
29
# File 'lib/redhat_access/strata/client.rb', line 25

def get_portal_http_proxy
  # switching to Katello::Util::HttpProxy's proxy_uri, which has a workaround for rest-client's poor handling
  # of special characters in proxy passwords (see https://github.com/Katello/katello/commit/bea53437509f68ceeff0eabfde88f69810876307)
  proxy_uri
end