Class: Aws::IAM::CurrentUser

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-iam/current_user.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CurrentUser

Returns a new instance of CurrentUser.

Options Hash (options):



15
16
17
18
19
# File 'lib/aws-sdk-iam/current_user.rb', line 15

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#access_keys(options = {}) ⇒ AccessKey::Collection

Examples:

Request syntax with placeholder values


access_keys = current_user.access_keys({
  user_name: "existingUserNameType",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :user_name (String)

    The name of the user.

    This parameter allows (per its [regex pattern]) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters:

    ,.@-

    [1]: wikipedia.org/wiki/regex

Returns:



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(options = {})
  batches = Enumerator.new do |y|
    resp = @client.list_access_keys(options)
    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

#arnString

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

Returns:

  • (String)


60
61
62
# File 'lib/aws-sdk-iam/current_user.rb', line 60

def arn
  data.arn
end

#clientClient

Returns:



103
104
105
# File 'lib/aws-sdk-iam/current_user.rb', line 103

def client
  @client
end

#create_dateTime

The date and time, in [ISO 8601 date-time format], when the user was created.

[1]: www.iso.org/iso/iso8601

Returns:

  • (Time)


71
72
73
# File 'lib/aws-sdk-iam/current_user.rb', line 71

def create_date
  data.create_date
end

#dataTypes::User

Returns the data for this Aws::IAM::CurrentUser. Calls Aws::IAM::Client#get_user if #data_loaded? is ‘false`.

Returns:



123
124
125
126
# File 'lib/aws-sdk-iam/current_user.rb', line 123

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



131
132
133
# File 'lib/aws-sdk-iam/current_user.rb', line 131

def data_loaded?
  !!@data
end

#identifiersObject

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.

Deprecated.


263
264
265
# File 'lib/aws-sdk-iam/current_user.rb', line 263

def identifiers
  {}
end

#loadself 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

Returns:

  • (self)


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

Examples:

Request syntax with placeholder values


mfa_devices = current_user.mfa_devices({
  user_name: "existingUserNameType",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :user_name (String)

    The name of the user whose MFA devices you want to list.

    This parameter allows (per its [regex pattern]) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters:

    ,.@-

    [1]: wikipedia.org/wiki/regex

Returns:



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(options = {})
  batches = Enumerator.new do |y|
    resp = @client.list_mfa_devices(options)
    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_usedTime

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

Returns:

  • (Time)


96
97
98
# File 'lib/aws-sdk-iam/current_user.rb', line 96

def password_last_used
  data.password_last_used
end

#pathString

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

Returns:

  • (String)


30
31
32
# File 'lib/aws-sdk-iam/current_user.rb', line 30

def path
  data.path
end

#signing_certificates(options = {}) ⇒ SigningCertificate::Collection

Examples:

Request syntax with placeholder values


signing_certificates = current_user.signing_certificates({
  user_name: "existingUserNameType",
})

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :user_name (String)

    The name of the IAM user whose signing certificates you want to examine.

    This parameter allows (per its [regex pattern]) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters:

    ,.@-

    [1]: wikipedia.org/wiki/regex

Returns:



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(options = {})
  batches = Enumerator.new do |y|
    resp = @client.list_signing_certificates(options)
    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

#userUser?

Returns:



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_idString

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

Returns:

  • (String)


48
49
50
# File 'lib/aws-sdk-iam/current_user.rb', line 48

def user_id
  data.user_id
end

#user_nameString

The friendly name identifying the user.

Returns:

  • (String)


36
37
38
# File 'lib/aws-sdk-iam/current_user.rb', line 36

def user_name
  data.user_name
end