module Misty::Auth::Catalog

Attributes

payload[R]

Public Class Methods

new(payload) click to toggle source
# File lib/misty/auth/catalog.rb, line 6
def initialize(payload)
  @payload = payload
end

Public Instance Methods

get_endpoint_url(names, region, interface) click to toggle source
# File lib/misty/auth/catalog.rb, line 10
def get_endpoint_url(names, region, interface)
  entry = get_service(names)
  raise ServiceTypeError, 'Endpoint discovery: No service type match' unless entry
  find_url(entry, region, interface)
end

Private Instance Methods

find_url(service, region, interface) click to toggle source
# File lib/misty/auth/catalog.rb, line 25
def find_url(service, region, interface)
  if service['endpoints']
    service['endpoints'].each do |endpoint|
      if (url = endpoint_url(endpoint, region, interface))
        return url
      end
    end
  end
  raise EndpointError, "No endpoint found: service '#{service['type']}', region '#{region}',
    interface '#{interface}'"
end
get_service(names) click to toggle source
# File lib/misty/auth/catalog.rb, line 18
def get_service(names)
  @payload.each do |entry|
    return entry if names.include?(entry['type'])
  end
  nil
end