Skip to content

Commit

Permalink
Add get methods. Add minions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch00k committed Sep 4, 2014
1 parent 3bfe38e commit 569807b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/kubr/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,37 @@ def send_request(method, path, body=nil)
args = [method]
args << body.to_json if body
process_response @cl[path].send(*args)
rescue RestClient::UnprocessableEntity, RestClient::InternalServerError => e
process_response e.response
end

def process_response(response)
JSON.parse(response).recursively_symbolize_keys!
end

def list_minions
response = send_request :get, 'minions'
response[:items]
end

def get_minion(id)
send_request :get, "minions/#{id}"
end

def delete_minion(id)
send_request :delete, "minions/#{id}"
end

['pod', 'service', 'replicationController'].each do |entity|
define_method "list_#{entity.underscore.pluralize}" do
response = send_request :get, entity.pluralize
response[:items]
end

define_method "get_#{entity.underscore}" do |id|
send_request :get, "#{entity.pluralize}/#{id}"
end

define_method "create_#{entity.underscore}" do |config|
send_request :post, entity.pluralize, config
end
Expand Down

0 comments on commit 569807b

Please sign in to comment.