class PulpProxy::PulpcoreClient

Public Class Methods

capabilities() click to toggle source
# 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) click to toggle source
# 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
http() click to toggle source
# 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
logger() click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 24
def self.logger
  Proxy::LoggerFactory.logger
end