Sha256: de0f89ca36e6f29c67cb66dff0657aabd315aecf8ee4b2839d7e27007df7cc1e

Contents?: true

Size: 1.11 KB

Versions: 79

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Aws
  module S3
    module Plugins
      # @api private
      class BucketNameRestrictions < Seahorse::Client::Plugin
        class Handler < Seahorse::Client::Handler

          # Useful because Aws::S3::Errors::SignatureDoesNotMatch is thrown
          # when passed a bucket with a forward slash. Instead provide a more
          # helpful error. Ideally should not be a plugin?
          def call(context)
            bucket_member = _bucket_member(context.operation.input.shape)
            if bucket_member && (bucket = context.params[bucket_member])
              if !Aws::ARNParser.arn?(bucket) && bucket.include?('/')
                raise ArgumentError,
                      'bucket name must not contain a forward-slash (/)'
              end
            end
            @handler.call(context)
          end

          private

          def _bucket_member(input)
            input.members.each do |member, ref|
              return member if ref.shape.name == 'BucketName'
            end
            nil
          end

        end

        handler(Handler)

      end
    end
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
aws-sdk-s3-1.181.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.180.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.179.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.178.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.177.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.176.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.176.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.175.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.174.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.173.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.172.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.171.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.170.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.170.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.169.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.168.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.167.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.166.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.165.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.164.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb