Sha256: 8d0d72d84732978f94c866919e8c6395ceaa455bc00ff241ff4a45d1742aa9ed

Contents?: true

Size: 851 Bytes

Versions: 15

Compression:

Stored size: 851 Bytes

Contents

module Service
  class RegistryApi
    DEFAULTS = { :url => 'http://localhost:5000' }
    attr_reader :config

    def initialize(params = {})
      config = DEFAULTS.merge(params)
      uri = URI(config.delete(:url))
      uri.user = config.delete(:user) unless config[:user].blank?
      uri.password = config.delete(:password) unless config[:password].blank?
      @config = config.merge(:url => uri.to_s)
    end

    def search(aquery)
      response = RestClient.get(config[:url] + '/v1/search',
                                :params => { :q => aquery }, :accept => :json)
      JSON.parse(response.body)
    end

    def list_repository_tags(arepository)
      response = RestClient.get(config[:url] + "/v1/repositories/#{arepository}/tags",
                                :accept => :json)
      JSON.parse(response.body)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
foreman_docker-3.0.0 app/models/service/registry_api.rb
foreman_docker-2.1.1 app/models/service/registry_api.rb
foreman_docker-2.1.0 app/models/service/registry_api.rb
foreman_docker-2.0.1 app/models/service/registry_api.rb
foreman_docker-2.0.0 app/models/service/registry_api.rb
foreman_docker-1.4.1 app/models/service/registry_api.rb
foreman_docker-1.4.0 app/models/service/registry_api.rb
foreman_docker-1.3.1 app/models/service/registry_api.rb
foreman_docker-1.3.0 app/models/service/registry_api.rb
foreman_docker-1.2.4 app/models/service/registry_api.rb
foreman_docker-1.2.3 app/models/service/registry_api.rb
foreman_docker-1.2.2 app/models/service/registry_api.rb
foreman_docker-1.2.1 app/models/service/registry_api.rb
foreman_docker-1.2.0 app/models/service/registry_api.rb
foreman_docker-1.1.0 app/models/service/registry_api.rb