Class: Aws::IAM::CurrentUser
- Inherits:
-
Object
- Object
- Aws::IAM::CurrentUser
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-iam/current_user.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#arn ⇒ String
The Amazon Resource Name (ARN) that identifies the user.
-
#create_date ⇒ Time
The date and time, in [ISO 8601 date-time format], when the user was created.
-
#password_last_used ⇒ Time
The date and time, in [ISO 8601 date-time format], when the user’s password was last used to sign in to an Amazon Web Services website.
-
#path ⇒ String
The path to the user.
-
#permissions_boundary ⇒ Types::AttachedPermissionsBoundary
For more information about permissions boundaries, see [Permissions boundaries for IAM identities ][1] in the *IAM User Guide*.
-
#tags ⇒ Array<Types::Tag>
A list of tags that are associated with the user.
-
#user_id ⇒ String
The stable and unique string identifying the user.
-
#user_name ⇒ String
The friendly name identifying the user.
Associations collapse
- #access_keys(options = {}) ⇒ AccessKey::Collection
- #identifiers ⇒ Object deprecated private Deprecated.
- #mfa_devices(options = {}) ⇒ MfaDevice::Collection
- #signing_certificates(options = {}) ⇒ SigningCertificate::Collection
- #user ⇒ User?
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::User
Returns the data for this CurrentUser.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(options = {}) ⇒ CurrentUser
constructor
A new instance of CurrentUser.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current CurrentUser.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::IAM::Client] #wait_until instead
Constructor Details
#initialize(options = {}) ⇒ CurrentUser
Returns a new instance of CurrentUser.
18 19 20 21 22 23 |
# File 'lib/aws-sdk-iam/current_user.rb', line 18 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#access_keys(options = {}) ⇒ AccessKey::Collection
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/aws-sdk-iam/current_user.rb', line 290 def access_keys( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_access_keys() end resp.each_page do |page| batch = [] page.data..each do |a| batch << AccessKey.new( user_name: a.user_name, id: a.access_key_id, data: a, client: @client ) end y.yield(batch) end end AccessKey::Collection.new(batches) end |
#arn ⇒ String
The Amazon Resource Name (ARN) that identifies the user. For more information about ARNs and how to use ARNs in policies, see [IAM Identifiers] in the *IAM User Guide*.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
67 68 69 |
# File 'lib/aws-sdk-iam/current_user.rb', line 67 def arn data[:arn] end |
#client ⇒ Client
137 138 139 |
# File 'lib/aws-sdk-iam/current_user.rb', line 137 def client @client end |
#create_date ⇒ Time
The date and time, in [ISO 8601 date-time format], when the user was created.
78 79 80 |
# File 'lib/aws-sdk-iam/current_user.rb', line 78 def create_date data[:create_date] end |
#data ⇒ Types::User
Returns the data for this Aws::IAM::CurrentUser. Calls Aws::IAM::Client#get_user if #data_loaded? is ‘false`.
159 160 161 162 |
# File 'lib/aws-sdk-iam/current_user.rb', line 159 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
167 168 169 |
# File 'lib/aws-sdk-iam/current_user.rb', line 167 def data_loaded? !!@data end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
404 405 406 |
# File 'lib/aws-sdk-iam/current_user.rb', line 404 def identifiers {} end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::IAM::CurrentUser. Returns ‘self` making it possible to chain methods.
current_user.reload.data
147 148 149 150 151 152 153 |
# File 'lib/aws-sdk-iam/current_user.rb', line 147 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.get_user end @data = resp.user self end |
#mfa_devices(options = {}) ⇒ MfaDevice::Collection
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/aws-sdk-iam/current_user.rb', line 329 def mfa_devices( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_mfa_devices() end resp.each_page do |page| batch = [] page.data.mfa_devices.each do |m| batch << MfaDevice.new( user_name: m.user_name, serial_number: m.serial_number, data: m, client: @client ) end y.yield(batch) end end MfaDevice::Collection.new(batches) end |
#password_last_used ⇒ Time
The date and time, in [ISO 8601 date-time format], when the user’s password was last used to sign in to an Amazon Web Services website. For a list of Amazon Web Services websites that capture a user’s last sign-in time, see the [Credential reports] topic in the *IAM User Guide*. If a password is used more than once in a five-minute span, only the first use is returned in this field. If the field is null (no value), then it indicates that they never signed in with a password. This can be because:
-
The user never had a password.
-
A password exists but has not been used since IAM started tracking this information on October 20, 2014.
A null value does not mean that the user never had a password. Also, if the user does not currently have a password but had one in the past, then this field contains the date and time the most recent password was used.
This value is returned only in the GetUser and ListUsers operations.
[1]: www.iso.org/iso/iso8601 [2]: docs.aws.amazon.com/IAM/latest/UserGuide/credential-reports.html
108 109 110 |
# File 'lib/aws-sdk-iam/current_user.rb', line 108 def password_last_used data[:password_last_used] end |
#path ⇒ String
The path to the user. For more information about paths, see [IAM identifiers] in the *IAM User Guide*.
The ARN of the policy used to set the permissions boundary for the user.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
37 38 39 |
# File 'lib/aws-sdk-iam/current_user.rb', line 37 def path data[:path] end |
#permissions_boundary ⇒ Types::AttachedPermissionsBoundary
For more information about permissions boundaries, see [Permissions boundaries for IAM identities ][1] in the *IAM User Guide*.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html
119 120 121 |
# File 'lib/aws-sdk-iam/current_user.rb', line 119 def data[:permissions_boundary] end |
#signing_certificates(options = {}) ⇒ SigningCertificate::Collection
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/aws-sdk-iam/current_user.rb', line 369 def signing_certificates( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_signing_certificates() end resp.each_page do |page| batch = [] page.data.certificates.each do |c| batch << SigningCertificate.new( user_name: c.user_name, id: c.certificate_id, data: c, client: @client ) end y.yield(batch) end end SigningCertificate::Collection.new(batches) end |
#tags ⇒ Array<Types::Tag>
A list of tags that are associated with the user. For more information about tagging, see [Tagging IAM resources] in the *IAM User Guide*.
130 131 132 |
# File 'lib/aws-sdk-iam/current_user.rb', line 130 def data[:tags] end |
#user ⇒ User?
391 392 393 394 395 396 397 398 399 400 |
# File 'lib/aws-sdk-iam/current_user.rb', line 391 def user if data[:user_name] User.new( name: data[:user_name], client: @client ) else nil end end |
#user_id ⇒ String
The stable and unique string identifying the user. For more information about IDs, see [IAM identifiers] in the *IAM User Guide*.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
55 56 57 |
# File 'lib/aws-sdk-iam/current_user.rb', line 55 def user_id data[:user_id] end |
#user_name ⇒ String
The friendly name identifying the user.
43 44 45 |
# File 'lib/aws-sdk-iam/current_user.rb', line 43 def user_name data[:user_name] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::IAM::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
## Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
## Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
## Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
## Callbacks
You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
## Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/aws-sdk-iam/current_user.rb', line 251 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |