1
|
module Service
|
2
|
class RegistryApi
|
3
|
DEFAULTS = { :url => 'http://localhost:5000' }
|
4
|
attr_reader :config
|
5
|
|
6
|
def initialize(params = {})
|
7
|
config = DEFAULTS.merge(params)
|
8
|
uri = URI(config.delete(:url))
|
9
|
uri.user = config.delete(:user) unless config[:user].blank?
|
10
|
uri.password = config.delete(:password) unless config[:password].blank?
|
11
|
@config = config.merge(:url => uri.to_s)
|
12
|
end
|
13
|
|
14
|
def search(aquery)
|
15
|
response = RestClient.get(config[:url] + '/v1/search',
|
16
|
:params => { :q => aquery }, :accept => :json)
|
17
|
JSON.parse(response.body)
|
18
|
end
|
19
|
|
20
|
def list_repository_tags(arepository)
|
21
|
response = RestClient.get(config[:url] + "/v1/repositories/#{arepository}/tags",
|
22
|
:accept => :json)
|
23
|
JSON.parse(response.body)
|
24
|
end
|
25
|
end
|
26
|
end
|