2012-06-04 15:24:02 +02:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/aws/models/iam/access_key'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class IAM
|
|
|
|
|
|
|
|
class AccessKeys < Fog::Collection
|
2012-12-22 23:30:34 +00:00
|
|
|
|
2012-06-04 15:24:02 +02:00
|
|
|
model Fog::AWS::IAM::AccessKey
|
2012-12-22 23:30:34 +00:00
|
|
|
|
2012-06-05 15:02:03 +02:00
|
|
|
def initialize(attributes = {})
|
|
|
|
@username = attributes[:username]
|
|
|
|
raise ArgumentError.new("Can't get an access_key's user without a username") unless @username
|
2012-06-04 15:24:02 +02:00
|
|
|
super
|
|
|
|
end
|
2012-12-22 23:30:34 +00:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = service.list_access_keys('UserName'=> @username).body['AccessKeys']
|
2012-06-04 15:24:02 +02:00
|
|
|
# AWS response doesn't contain the UserName, this injects it
|
2012-06-05 15:02:03 +02:00
|
|
|
data.each {|access_key| access_key['UserName'] = @username }
|
2012-06-04 15:24:02 +02:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(identity)
|
|
|
|
self.all.select {|access_key| access_key.id == identity}.first
|
|
|
|
end
|
2012-12-22 23:30:34 +00:00
|
|
|
|
2012-06-04 15:24:02 +02:00
|
|
|
def new(attributes = {})
|
2012-06-05 15:02:03 +02:00
|
|
|
super({ :username => @username }.merge!(attributes))
|
2012-06-04 15:24:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-12-22 23:30:34 +00:00
|
|
|
end
|