Class: Mysql2::AwsRdsIam::AuthToken::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql2/aws_rds_iam/auth_token/generator.rb

Instance Method Summary collapse

Constructor Details

#initializeGenerator

Returns a new instance of Generator.



7
8
9
10
11
12
# File 'lib/mysql2/aws_rds_iam/auth_token/generator.rb', line 7

def initialize
  aws_config = Aws::RDS::Client.new.config

  @generator = Aws::RDS::AuthTokenGenerator.new(credentials: aws_config.credentials)
  @region = aws_config.region
end

Instance Method Details

#call(host:, port:, username:) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/mysql2/aws_rds_iam/auth_token/generator.rb', line 14

def call(host:, port:, username:)
  generator.auth_token(
    region: region,
    endpoint: "#{host}:#{port}",
    user_name: username.to_s
  )
end