mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
f9c5773bb6
Previously, the model was being incorrectly loaded from request data. As a result, the username and apiKey properties were always nil. This fixes parsing and improves the tests to catch this type of bug in the future.
33 lines
768 B
Ruby
33 lines
768 B
Ruby
require 'fog/core/collection'
|
|
require 'fog/rackspace/models/identity/credential'
|
|
|
|
module Fog
|
|
module Rackspace
|
|
class Identity
|
|
class Credentials < Fog::Collection
|
|
|
|
model Fog::Rackspace::Identity::Credential
|
|
|
|
attr_accessor :user
|
|
|
|
def all
|
|
requires :user
|
|
load(retrieve_credentials)
|
|
end
|
|
|
|
def get(id)
|
|
requires :user
|
|
data = retrieve_credentials.find { |credential| credential['apiKey'] == id }
|
|
data && new(data)
|
|
end
|
|
|
|
private
|
|
|
|
def retrieve_credentials
|
|
raw_credentials = service.list_credentials(user.identity).body['credentials']
|
|
raw_credentials.map { |c| c['RAX-KSKEY:apiKeyCredentials'] }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|