Class: Fog::AWS::IAM::AccessKeys

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/aws/models/iam/access_keys.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

#initialize(attributes = {}) ⇒ AccessKeys

Returns a new instance of AccessKeys.

Raises:

  • (ArgumentError)


12
13
14
15
16
# File 'lib/fog/aws/models/iam/access_keys.rb', line 12

def initialize(attributes = {})
  @username = attributes[:username]
  raise ArgumentError.new("Can't get an access_key's user without a username") unless @username
  super
end

Instance Method Details

#allObject



18
19
20
21
22
23
# File 'lib/fog/aws/models/iam/access_keys.rb', line 18

def all
  data = service.list_access_keys('UserName'=> @username).body['AccessKeys']
  # AWS response doesn't contain the UserName, this injects it
  data.each {|access_key| access_key['UserName'] = @username }
  load(data)
end

#get(identity) ⇒ Object



25
26
27
# File 'lib/fog/aws/models/iam/access_keys.rb', line 25

def get(identity)
  self.all.select {|access_key| access_key.id == identity}.first
end

#new(attributes = {}) ⇒ Object



29
30
31
# File 'lib/fog/aws/models/iam/access_keys.rb', line 29

def new(attributes = {})
  super({ :username => @username }.merge!(attributes))
end