Sha256: b967334c670fdfe420163c7a4533180652d6ece4de8dcaa6744997b8bdf19351

Contents?: true

Size: 1.29 KB

Versions: 16

Compression:

Stored size: 1.29 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])
              _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

16 entries across 16 versions & 1 rubygems

Version Path
aws-sdk-s3-1.81.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.81.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.80.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.79.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.79.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.78.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.77.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.76.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.75.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.74.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.73.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.72.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.71.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.70.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.69.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.69.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb