def self.get_user_info(libra_server, rhlogin, password, net_http, debug, print_result, not_found_message=nil)
puts "Contacting https://#{libra_server}"
data = {'rhlogin' => rhlogin}
if debug
data['debug'] = "true"
end
print_post_data(data, debug)
json_data = generate_json(data)
url = URI.parse("https://#{libra_server}/broker/userinfo")
response = http_post(net_http, url, json_data, password)
unless response.code == '200'
if response.code == '404'
if not_found_message
puts not_found_message
else
puts "A user with rhlogin '#{rhlogin}' does not have a registered domain. Be sure to run rhc-create-domain before using the other rhc tools."
end
exit 99
elsif response.code == '401'
puts "Invalid user credentials"
exit 97
else
print_response_err(response, debug)
end
exit 254
end
begin
json_resp = JSON.parse(response.body)
rescue JSON::ParserError
exit 254
end
update_server_api_v(json_resp)
if print_result
print_response_success(json_resp, debug)
end
begin
user_info = JSON.parse(json_resp['data'].to_s)
rescue JSON::ParserError
exit 254
end
user_info
end