Sha256: 1ba3b9fd2dc78a4ece6bf07b9228a46c0fc0dd6b52bf39467af2c43a9e5894d3

Contents?: true

Size: 1000 Bytes

Versions: 12

Compression:

Stored size: 1000 Bytes

Contents

require 'uri'

module Proxy
  module ContainerGateway
    class ForemanApi
      def registry_request(auth_header, params, suffix)
        uri = URI.join(Proxy::SETTINGS.foreman_url, Proxy::ContainerGateway::Plugin.settings.katello_registry_path, suffix)
        uri.query = process_params(params)

        req = Net::HTTP::Get.new(uri)
        req.add_field('Authorization', auth_header)
        req.add_field('Accept', 'application/json')
        req.content_type = 'application/json'
        http = Net::HTTP.new(uri.hostname, uri.port)
        http.use_ssl = true

        http.request(req)
      end

      def process_params(params_in)
        params = params_in.slice('scope', 'account').compact
        URI.encode_www_form(params)
      end

      def fetch_token(auth_header, params)
        registry_request(auth_header, params, 'token')
      end

      def fetch_user_repositories(auth_header, params)
        registry_request(auth_header, params, '_catalog')
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
smart_proxy_container_gateway-3.2.0 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-3.1.1 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-3.1.0 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-2.0.0 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.2.0 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.1.0 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.9 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.8 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.7 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.6 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.5 lib/smart_proxy_container_gateway/foreman_api.rb
smart_proxy_container_gateway-1.0.4 lib/smart_proxy_container_gateway/foreman_api.rb