Sha256: f83260e5d833d32381f31b3c67290e36431e06daf3933f6daeac0500bd36d8dd

Contents?: true

Size: 841 Bytes

Versions: 190

Compression:

Stored size: 841 Bytes

Contents

# 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

Version data entries

190 entries across 190 versions & 1 rubygems

Version Path
aws-sdk-core-3.190.3 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.190.2 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.190.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.190.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.189.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.188.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.187.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.187.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.186.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.185.2 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.185.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.185.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.184.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.183.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.183.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.182.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.181.1 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.181.0 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.180.3 lib/aws-sdk-core/plugins/idempotency_token.rb
aws-sdk-core-3.180.2 lib/aws-sdk-core/plugins/idempotency_token.rb