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 AWS website.
-
#path ⇒ String
The path to 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.
Constructor Details
#initialize(options = {}) ⇒ CurrentUser
Returns a new instance of CurrentUser.
15 16 17 18 19 |
# File 'lib/aws-sdk-iam/current_user.rb', line 15 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#access_keys(options = {}) ⇒ AccessKey::Collection
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/aws-sdk-iam/current_user.rb', line 155 def access_keys( = {}) batches = Enumerator.new do |y| resp = @client.list_access_keys() 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 *Using IAM* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
60 61 62 |
# File 'lib/aws-sdk-iam/current_user.rb', line 60 def arn data.arn end |
#client ⇒ Client
103 104 105 |
# File 'lib/aws-sdk-iam/current_user.rb', line 103 def client @client end |
#create_date ⇒ Time
The date and time, in [ISO 8601 date-time format], when the user was created.
71 72 73 |
# File 'lib/aws-sdk-iam/current_user.rb', line 71 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`.
123 124 125 126 |
# File 'lib/aws-sdk-iam/current_user.rb', line 123 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
131 132 133 |
# File 'lib/aws-sdk-iam/current_user.rb', line 131 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.
263 264 265 |
# File 'lib/aws-sdk-iam/current_user.rb', line 263 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
113 114 115 116 117 |
# File 'lib/aws-sdk-iam/current_user.rb', line 113 def load resp = @client.get_user @data = resp.user self end |
#mfa_devices(options = {}) ⇒ MfaDevice::Collection
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/aws-sdk-iam/current_user.rb', line 192 def mfa_devices( = {}) batches = Enumerator.new do |y| resp = @client.list_mfa_devices() 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 AWS website. For a list of AWS websites that capture a user’s last sign-in time, see the [Credential Reports] topic in the *Using IAM* guide. If a password is used more than once in a five-minute span, only the first use is returned in this field. This field is null (not present) when:
-
The user does not have a password
-
The password exists but has never been used (at least not since IAM started tracking this information on October 20th, 2014
-
there is no sign-in data associated with the user
This value is returned only in the GetUser and ListUsers actions.
[1]: www.iso.org/iso/iso8601 [2]: docs.aws.amazon.com/IAM/latest/UserGuide/credential-reports.html
96 97 98 |
# File 'lib/aws-sdk-iam/current_user.rb', line 96 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 *Using IAM* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
30 31 32 |
# File 'lib/aws-sdk-iam/current_user.rb', line 30 def path data.path end |
#signing_certificates(options = {}) ⇒ SigningCertificate::Collection
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/aws-sdk-iam/current_user.rb', line 230 def signing_certificates( = {}) batches = Enumerator.new do |y| resp = @client.list_signing_certificates() 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 |
#user ⇒ User?
250 251 252 253 254 255 256 257 258 259 |
# File 'lib/aws-sdk-iam/current_user.rb', line 250 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 *Using IAM* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
48 49 50 |
# File 'lib/aws-sdk-iam/current_user.rb', line 48 def user_id data.user_id end |
#user_name ⇒ String
The friendly name identifying the user.
36 37 38 |
# File 'lib/aws-sdk-iam/current_user.rb', line 36 def user_name data.user_name end |