def public_endpoint(service_name, region = nil)
      return IDENTITY_URL if service_name == "identity"

      endpoints = service_endpoints(service_name)
      if endpoints.size > 1 && region
        region = region.to_s.upcase
        endpoints = endpoints.select { |e| e["region"] == region } || {}
      elsif endpoints.size > 1 && region.nil?
        raise ArgumentError, "The requested service exists in multiple regions, please specify a region code"
      end

      if endpoints.size == 0
        raise ArgumentError, "No matching services found"
      else
        endpoints.first["publicURL"]
      end
    end
def public_endpoint(service_name, region = nil)
      return IDENTITY_URL if service_name == "identity"

      endpoints = service_endpoints(service_name)
      if endpoints.size > 1 && region
        region = region.to_s.upcase
        endpoints = endpoints.select { |e| e["region"] == region } || {}
      elsif endpoints.size > 1 && region.nil?
        raise ArgumentError, "The requested service exists in multiple regions, please specify a region code"
      end

      if endpoints.size == 0
        raise ArgumentError, "No matching services found"
      else
        endpoints.first["publicURL"]
      end
    end
Return the public API URL for a particular rackspace service.

 Use Account#service_names to see a list of valid service_name's for this.

 Check the project README for an updated list of the available regions.

     account = Raca::Account.new("username", "secret")
     puts account.public_endpoint("cloudServers", :syd)

 Some service APIs are not regioned. In those cases, the region code can be
 left off:

     account = Raca::Account.new("username", "secret")
     puts account.public_endpoint("cloudDNS")