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.
Methods included from Core::Collection::Limitable
Methods included from Core::Collection
#each_batch, #enum, #first, #in_groups_of, #page
Constructor Details
#initialize(user, options = {}) ⇒ MFADeviceCollection
Returns a new instance of MFADeviceCollection.
22 23 24 25 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 22 def initialize user, = {} @user = user super end |
Instance Attribute Details
#user ⇒ User (readonly)
Returns the user that this mfa device collection belongs to.
17 18 19 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 17 def user @user end |
Instance Method Details
#[](serial_number) ⇒ MFADevice
Returns a reference to an MFA device with the given serial number.
62 63 64 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 62 def [] serial_number MFADevice.new(user, serial_number) end |
#clear ⇒ nil
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
.
85 86 87 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 85 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.
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)
98 99 100 |
# File 'lib/aws/iam/mfa_device_collection.rb', line 98 def enumerator = {} super() end |