Class: AWS::IAM::MFADeviceCollection
- Inherits:
-
Object
- Object
- AWS::IAM::MFADeviceCollection
- Includes:
- Collection
- Defined in:
- lib/aws/iam/mfa_device_collection.rb
Instance Attribute Summary collapse
-
#user ⇒ User
readonly
Returns the user that this mfa device collection belongs to.
Instance Method Summary collapse
-
#[](serial_number) ⇒ MFADevice
Returns a reference to an MFA device with the given serial number.
-
#clear ⇒ nil
Deletes all of the MFA devices in this collection.
- #disable(serial_number) ⇒ nil
-
#each(options = {}) {|user| ... } ⇒ nil
Yields once for each MFA device.
-
#enable(serial_number, authentication_code_1, authentication_code_2) ⇒ MFADevice
(also: #create)
Enables an MFA device for this user.
-
#enumerator(options = {}) ⇒ Enumerator
Returns an enumerable object for this collection.
-
#initialize(user, options = {}) ⇒ MFADeviceCollection
constructor
A new instance of MFADeviceCollection.
Constructor Details
#initialize(user, options = {}) ⇒ MFADeviceCollection
Returns a new instance of MFADeviceCollection.
25 26 27 28 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 25 def initialize user, = {} @user = user super end |
Instance Attribute Details
#user ⇒ User (readonly)
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.
65 66 67 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 65 def [] serial_number MFADevice.new(user, serial_number) end |
#clear ⇒ nil
Deletes all of the MFA devices in this collection.
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
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
.
88 89 90 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 88 def each = {}, &block super(.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.
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)
101 102 103 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 101 def enumerator = {} super() end |