Class: AWS::IAM::MFADeviceCollection

Inherits:
Object
  • Object
show all
Includes:
Collection
Defined in:
lib/aws/iam/mfa_device_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::Collection::Limitable

#each_batch

Methods included from Core::Collection

#each_batch, #enum, #first, #in_groups_of, #page

Constructor Details

#initialize(user, options = {}) ⇒ MFADeviceCollection



22
23
24
25
# File 'lib/aws/iam/mfa_device_collection.rb', line 22

def initialize user, options = {}
  @user = user
  super
end

Instance Attribute Details

#userUser (readonly)



17
18
19
# File 'lib/aws/iam/mfa_device_collection.rb', line 17

def user
  @user
end

Instance Method Details

#[](serial_number) ⇒ MFADevice



62
63
64
# File 'lib/aws/iam/mfa_device_collection.rb', line 62

def [] serial_number
  MFADevice.new(user, serial_number)
end

#clearnil

Deletes all of the MFA devices in this collection.



68
69
70
71
72
73
# File 'lib/aws/iam/mfa_device_collection.rb', line 68

def clear
  each do |device| 
    device.delete
  end
  nil
end

#disable(serial_number) ⇒ nil



54
55
56
57
# File 'lib/aws/iam/mfa_device_collection.rb', line 54

def disable serial_number
  self[serial_number].disable
  nil
end

#each(options = {}) {|user| ... } ⇒ nil

Yields once for each MFA device.

You can limit the number of devices yielded using :limit.

Options Hash (options):

  • :limit (Integer)

    The maximum number of devices to yield.

  • :batch_size (Integer)

    The maximum number of devices receive each service reqeust.

Yield Parameters:



85
86
87
# File 'lib/aws/iam/mfa_device_collection.rb', line 85

def each options = {}, &block
  super(options.merge(:user_name => user.name), &block)
end

#enable(serial_number, authentication_code_1, authentication_code_2) ⇒ MFADevice Also known as: create

Enables an MFA device for this user.



39
40
41
42
43
44
45
46
47
# File 'lib/aws/iam/mfa_device_collection.rb', line 39

def enable serial_number, authentication_code_1, authentication_code_2
  client.enable_mfa_device({
    :user_name => user.name,
    :serial_number => serial_number,
    :authentication_code_1 => authentication_code_1.to_s,
    :authentication_code_2 => authentication_code_2.to_s,
  })
  self[serial_number]
end

#enumerator(options = {}) ⇒ Enumerator

Returns an enumerable object for this collection. This can be useful if you want to call an enumerable method that does not accept options (e.g. collect, first, etc).

mfa_devices.enumerator(:limit => 10).collect(&:serial_number)

Options Hash (options):

  • :limit (Integer)

    The maximum number of devices to yield.

  • :batch_size (Integer)

    The maximum number of devices receive each service reqeust.



98
99
100
# File 'lib/aws/iam/mfa_device_collection.rb', line 98

def enumerator options = {}
  super(options)
end