Sha256: 40b7c76a413c6d8258d688a590ba019368a38bfe29081d88a4a7e71c35add2ec

Contents?: true

Size: 1.26 KB

Versions: 18

Compression:

Stored size: 1.26 KB

Contents

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])
              _resolved_bucket, _resolved_region, arn = BucketARN.resolve_arn!(
                bucket,
                context.config.region,
                context.config.s3_use_arn_region
              )
              if !arn && 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

18 entries across 18 versions & 1 rubygems

Version Path
aws-sdk-s3-1.68.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.67.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.67.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.66.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.65.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.64.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.63.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.63.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.62.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.61.2 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.61.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.61.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.60.2 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.60.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.60.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.59.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.59.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.58.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb