Class: Aws::Crt::Auth::CredentialsOptions

Inherits:
Object
  • Object
show all
Includes:
ManagedNative
Defined in:
lib/aws-crt/auth/credentials.rb

Overview

CRT CredentialOptions

Constant Summary collapse

UINT64_MAX =
18_446_744_073_709_551_615

Instance Method Summary collapse

Methods included from ManagedNative

included, #manage_native, #native, #native_set?, #release

Constructor Details

#initialize(access_key_id, secret_access_key, session_token = nil, expiration = nil) ⇒ CredentialsOptions

Returns a new instance of CredentialsOptions.

Parameters:

  • access_key_id (String)
  • secret_access_key (String)
  • session_token (String) (defaults to: nil)

    (nil)

  • expiration (Time|int) (defaults to: nil)

    (nil) - Either a Time or an int seconds since unix epoch



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/aws-crt/auth/credentials.rb', line 18

def initialize(access_key_id, secret_access_key,
               session_token = nil, expiration = nil)
  if !access_key_id || access_key_id.empty?
    raise ArgumentError, 'access_key_id  must be set'
  end

  if !secret_access_key || secret_access_key.empty?
    raise ArgumentError, 'secret_access_key  must be set'
  end

  manage_native do
    Aws::Crt::Native.credentials_options_new
  end

  Aws::Crt::Native.credentials_options_set_access_key_id(
    native, access_key_id, access_key_id.length
  )

  Aws::Crt::Native.credentials_options_set_secret_access_key(
    native, secret_access_key, secret_access_key.length
  )

  if session_token && !session_token.empty?
    Aws::Crt::Native.credentials_options_set_session_token(
      native, session_token, session_token.length
    )
  end

  Aws::Crt::Native.credentials_options_set_expiration_timepoint_seconds(
    native, expiration&.to_i || UINT64_MAX
  )
end