Class: PulpProxy::PulpcoreClient

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_pulp_plugin/pulpcore_client.rb

Class Method Summary collapse

Class Method Details

.capabilitiesObject



16
17
18
19
20
21
22
# File 'lib/smart_proxy_pulp_plugin/pulpcore_client.rb', line 16

def self.capabilities
  body = JSON.parse(get("/pulp/api/v3/status/").body)
  body['versions'].map{|item| item['component'] }
rescue => e
  logger.error("Could not fetch capabilities: #{e.message}")
  []
end

.get(path) ⇒ Object



9
10
11
12
13
14
# File 'lib/smart_proxy_pulp_plugin/pulpcore_client.rb', line 9

def self.get(path)
  uri = URI.parse(::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s)
  req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
  req.add_field('Accept', 'application/json')
  self.http.request(req)
end

.httpObject



28
29
30
31
32
33
# File 'lib/smart_proxy_pulp_plugin/pulpcore_client.rb', line 28

def self.http
  uri = URI.parse(::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'
  http
end

.loggerObject



24
25
26
# File 'lib/smart_proxy_pulp_plugin/pulpcore_client.rb', line 24

def self.logger
  Proxy::LoggerFactory.logger
end