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

Constructor Details

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

Returns a new instance of MFADeviceCollection.

Parameters:

  • user (User)

    The user that owns this device collection.



25
26
27
28
# File 'lib/aws/iam/mfa_device_collection.rb', line 25

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

Instance Attribute Details

#userUser (readonly)

Returns the user that this mfa device collection belongs to.

Returns:

  • (User)

    Returns the user that this mfa device collection belongs to.



20
21
22
# File 'lib/aws/iam/mfa_device_collection.rb', line 20

def user
  @user
end

Instance Method Details

#[](serial_number) ⇒ MFADevice

Returns a reference to an MFA device with the given serial number.

Parameters:

  • serial_number (String)

    The serial number of an MFA device.

Returns:

  • (MFADevice)

    Returns a reference to an MFA device with the given serial number.



65
66
67
# File 'lib/aws/iam/mfa_device_collection.rb', line 65

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

#clearnil

Deletes all of the MFA devices in this collection.

Returns:

  • (nil)


71
72
73
74
75
76
# File 'lib/aws/iam/mfa_device_collection.rb', line 71

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

#disable(serial_number) ⇒ nil

Parameters:

  • serial_number (String)

    The serial number of the MFA device you want to disable.

Returns:

  • (nil)


57
58
59
60
# File 'lib/aws/iam/mfa_device_collection.rb', line 57

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.

Parameters:

  • options (Hash) (defaults to: {})

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:

Returns:

  • (nil)


88
89
90
# File 'lib/aws/iam/mfa_device_collection.rb', line 88

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.

Parameters:

  • serial_number (String)

    The serial number that uniquely identifies the MFA device

  • authentication_code_1 (String)

    An authentication code emitted by the device.

  • authentication_code_2 (String)

    A subsequent authentication code emitted by the device.

Returns:

  • (MFADevice)

    Returns the newly enabled MFA device.



42
43
44
45
46
47
48
49
50
# File 'lib/aws/iam/mfa_device_collection.rb', line 42

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)

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :limit (Integer)

    The maximum number of devices to yield.

  • :batch_size (Integer)

    The maximum number of devices receive each service reqeust.

Returns:

  • (Enumerator)


101
102
103
# File 'lib/aws/iam/mfa_device_collection.rb', line 101

def enumerator options = {}
  super(options)
end