These are methods that belong to the API object but are callable from the client for convenience.
# File lib/rhc/rest/client.rb, line 17 def add_domain(id) debug "Adding domain #{id}" @domains = nil api.rest_method "ADD_DOMAIN", :id => id end
# File lib/rhc/rest/client.rb, line 43 def add_key(name, key, content) debug "Adding key #{key} for #{user.login}" user.add_key name, key, content end
# File lib/rhc/rest/client.rb, line 28 def cartridges debug "Getting all cartridges" @cartridges ||= api.rest_method("LIST_CARTRIDGES", nil, :lazy_auth => true) end
# File lib/rhc/rest/client.rb, line 48 def delete_key(name) debug "Deleting key '#{name}'" key = find_key(name) key.destroy end
# File lib/rhc/rest/client.rb, line 23 def domains debug "Getting all domains" @domains ||= api.rest_method "LIST_DOMAINS" end
# File lib/rhc/rest/client.rb, line 62 def find_application(domain, application, options={}) response = request({ :url => link_show_application_by_domain_name(domain, application), :method => "GET", :payload => options }) end
# File lib/rhc/rest/client.rb, line 70 def find_application_gear_groups(domain, application, options={}) response = request({ :url => link_show_application_by_domain_name(domain, application, "gear_groups"), :method => "GET", :payload => options }) end
Find Cartridge by name or regex
# File lib/rhc/rest/client.rb, line 88 def find_cartridges(name) debug "Finding cartridge #{name}" if name.is_a?(Hash) regex = name[:regex] type = name[:type] name = name[:name] end filtered = Array.new cartridges.each do |cart| if regex filtered.push(cart) if cart.name.match(regex) and (type.nil? or cart.type == type) else filtered.push(cart) if (name.nil? or cart.name == name) and (type.nil? or cart.type == type) end end return filtered end
Find Domain by namesapce
# File lib/rhc/rest/client.rb, line 55 def find_domain(id) debug "Finding domain #{id}" domains.each { |domain| return domain if domain.id == id } raise DomainNotFoundException.new("Domain #{id} not found") end
find Key by name
# File lib/rhc/rest/client.rb, line 108 def find_key(name) debug "Finding key #{name}" user.find_key(name) or raise RHC::KeyNotFoundException.new("Key #{name} does not exist") end
# File lib/rhc/rest/client.rb, line 78 def link_show_application_by_domain_name(domain, application, *args) [ api.links['LIST_DOMAINS']['href'], domain, "applications", application, ].concat(args).map{ |s| URI.escape(s) }.join("/") end
# File lib/rhc/rest/client.rb, line 177 def logout #TODO logout debug "Logout/Close client" end
Returns nil if creating sessions is not supported, raises on error, otherwise returns an Authorization object.
# File lib/rhc/rest/client.rb, line 142 def new_session(options={}) if supports_sessions? api.rest_method('ADD_AUTHORIZATION', { :scope => 'session', :note => "RHC/#{RHC::VERSION::STRING} (from #{Socket.gethostname rescue 'unknown'} on #{RUBY_PLATFORM})", :reuse => true }, options) end end
# File lib/rhc/rest/client.rb, line 38 def sshkeys debug "Finding all keys for #{user.login}" user.keys end
# File lib/rhc/rest/client.rb, line 129 def supports_sessions? api.supports? 'ADD_AUTHORIZATION' end
# File lib/rhc/rest/client.rb, line 33 def user debug "Getting user info" @user ||= api.rest_method "GET_USER" end