@attr_reader [User] user Returns the user that owns this collection.
@return [User] Returns the user that this mfa device collection
belongs to.
@param [User] user The user that owns this device collection.
# File lib/aws/iam/mfa_device_collection.rb, line 22 def initialize user, options = {} @user = user super end
@param [String] serial_number The serial number of an MFA device. @return [MFADevice] Returns a reference to an MFA device with the
given serial number.
# File lib/aws/iam/mfa_device_collection.rb, line 62 def [] serial_number MFADevice.new(user, serial_number) end
Deactivates all of the MFA devices in this collection. Virtual MFA devices in this collection will not be deleted. Instead they will be available in the {AWS::IAM#virtual_mfa_devices} collection so that they can either be deleted or enabled for different users.
@return [nil]
# File lib/aws/iam/mfa_device_collection.rb, line 73 def clear each do |device| device.deactivate end nil end
@param [String] serial_number The serial number of the MFA device you
want to disable.
@return [nil]
# File lib/aws/iam/mfa_device_collection.rb, line 54 def disable serial_number self[serial_number].disable nil end
Yields once for each MFA device.
You can limit the number of devices yielded using :limit
.
@param [Hash] options @option options [Integer] :limit The maximum number of devices to yield. @option options [Integer] :batch_size The maximum number of devices
receive each service reqeust.
@yieldparam [User] user @return [nil]
# File lib/aws/iam/mfa_device_collection.rb, line 90 def each options = {}, &block super(options.merge(:user_name => user.name), &block) end
Enables an MFA device for this user. @param [String] serial_number The serial number that uniquely
identifies the MFA device
@param [String] authentication_code_1 An authentication code emitted
by the device.
@param [String] authentication_code_2 A subsequent authentication
code emitted by the device.
@return [MFADevice] Returns the newly enabled MFA device.
# 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
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)
@param (see each) @option (see each) @return [Enumerator]
# File lib/aws/iam/mfa_device_collection.rb, line 103 def enumerator options = {} super(options) end
@private
# File lib/aws/iam/mfa_device_collection.rb, line 109 def each_item response, &block response.mfa_devices.each do |item| if item.serial_number =~ %r^arn:/ mfa_device = VirtualMfaDevice.new_from(:list_mfa_devices, item, item.serial_number, :config => config) else mfa_device = MFADevice.new(user, item.serial_number) end yield(mfa_device) end end