Sha256: e09ef148d7dc5e3bb912f1a2462735dcf363ab879fa64fd3b2cdfaa581f4b6cb

Contents?: true

Size: 1.27 KB

Versions: 53

Compression:

Stored size: 1.27 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_region, arn = ARN.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

53 entries across 53 versions & 1 rubygems

Version Path
aws-sdk-s3-1.116.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.115.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.114.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.113.2 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.113.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.113.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.112.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.111.3 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.111.2 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.111.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.111.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.110.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.109.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.108.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.107.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.106.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.105.1 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.105.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.104.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb
aws-sdk-s3-1.103.0 lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb