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
|
# frozen_string_literal: true
require 'securerandom'
module Aws
module Plugins
# Provides support for auto filling operation parameters
# that enabled with `idempotencyToken` trait with random UUID v4
# when no value is provided
# @api private
class IdempotencyToken < Seahorse::Client::Plugin
# @api private
class Handler < Seahorse::Client::Handler
def call(context)
auto_fill(context.params, context.operation.input)
@handler.call(context)
end
private
def auto_fill(params, ref)
ref.shape.members.each do |name, member_ref|
if member_ref['idempotencyToken']
params[name] ||= SecureRandom.uuid
end
end
end
end
handler(Handler, step: :initialize)
end
end
end
|