def get_endpoint(service_name, region=nil, service_net=false)
service_region = region_key(region)
network_type = network_type_key(service_net)
endpoints = get_endpoints(service_name, service_net)
raise "Unable to locate endpoint for service #{service_name}" if endpoints.empty?
if endpoints.size > 1 && region.nil?
raise "There are multiple endpoints available for #{service_name}. Please specify one of the following regions: #{display_service_regions(service_name)}."
end
endpoint = endpoints.find {|e| matching_region?(e, service_region) }
return endpoint[network_type] if endpoint && endpoint[network_type]
if endpoints.size == 1 && matching_region?(endpoints[0], "GLOBAL")
return endpoints[0][network_type]
end
raise "Unknown region :#{region} for service #{service_name}. Please use one of the following regions: #{display_service_regions(service_name)}"
end