Sha256: ac985176f0673ca88eb6277059bf26e6a569464bc383d81c01a3942027c29896

Contents?: true

Size: 810 Bytes

Versions: 163

Compression:

Stored size: 810 Bytes

Contents

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

Version data entries

163 entries across 163 versions & 1 rubygems

Version Path
aws-sdk-core-3.100.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.99.2 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.99.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.99.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.98.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.97.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.97.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.96.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.96.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.95.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.94.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.94.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.93.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.92.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.91.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.91.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.90.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.90.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.89.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.89.0 lib/aws-sdk-core/plugins/idempotency_token.rb