class A4Tools::UsherClient
Attributes
response[R]
Public Class Methods
mirrors()
click to toggle source
# File lib/clients/usher_client.rb, line 4 def mirrors [ "http://s01.ushers.acres4.net:8080/usher2/json?wrap", "http://s02.ushers.acres4.net:8080/usher2/json?wrap", "http://s03.ushers.acres4.net:8080/usher2/json?wrap" ] end
new(uri=nil)
click to toggle source
Calls superclass method
A4Tools::AcresClient::new
# File lib/clients/usher_client.rb, line 20 def initialize(uri=nil) super(uri || self.class.random_mirror) end
random_mirror()
click to toggle source
# File lib/clients/usher_client.rb, line 12 def random_mirror _m = mirrors _m[rand(_m.length)] end
Public Instance Methods
dump_usher_response(response=nil)
click to toggle source
# File lib/clients/usher_client.rb, line 47 def dump_usher_response(response=nil) response ||= @list s = "Site #{response['siteID']} (#{response['siteName']})\n" response[:hosts].each do |host| s += "\t#{host["product"]}, #{host["url"]}#{host["context"]}\n" end s += "\n" end
list_servers(params={})
click to toggle source
# File lib/clients/usher_client.rb, line 42 def list_servers(params={}) list_servers_raw @list end
list_servers_raw(params={})
click to toggle source
# File lib/clients/usher_client.rb, line 36 def list_servers_raw(params={}) response = send_message(wrapped_message(params[:full] ? "usherAlt" : "usher", "com.acres4.common.info.usher.UsherRequest", usher_request_for_params(params))) @list = response_body response response end
locate_service(service, response=nil)
click to toggle source
# File lib/clients/usher_client.rb, line 57 def locate_service(service, response=nil) list_servers unless @list response ||= @list products = response[:hosts].select do |h| h[:product].match("^#{service}(-(Secure|Server))?$") end products.sort! do |h,o| h[:product] <=> o[:product] end products.first end
usher_request_for_params(params)
click to toggle source
# File lib/clients/usher_client.rb, line 24 def usher_request_for_params(params) request = { app: app_info, device: device_info } request[:device][:serialNumber] = params[:serial] if params.has_key?(:serial) request[:ipOverride] = params[:ip] if params.has_key?(:ip) request end