1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 50 51 52 53 54 55 56 57
|
# frozen_string_literal: true
require 'set'
module Aws
module S3
# @api private
class AccessGrantsCredentials
include CredentialProvider
include RefreshingCredentials
def initialize(options = {})
@client = options[:client]
@get_data_access_params = {}
options.each_pair do |key, value|
if self.class.get_data_access_options.include?(key)
@get_data_access_params[key] = value
end
end
@async_refresh = true
super
end
# @return [S3Control::Client]
attr_reader :client
# @return [String]
attr_reader :matched_grant_target
private
def refresh
c = @client.get_data_access(@get_data_access_params)
credentials = c.credentials
@matched_grant_target = c.matched_grant_target
@credentials = Credentials.new(
credentials.access_key_id,
credentials.secret_access_key,
credentials.session_token
)
@expiration = credentials.expiration
end
class << self
# @api private
def get_data_access_options
@gdao ||= begin
input = Aws::S3Control::Client.api.operation(:get_data_access).input
Set.new(input.shape.member_names)
end
end
end
end
end
end
|