Sha256: e907540759393138e757c839013240d6ac13400e0b26c54e67b1e1900144a7bd

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class S3

        # Get configured payer for an S3 bucket
        #
        # ==== Parameters
        # * bucket_name<~String> - name of bucket to get payer for
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'Payer'<~String> - Specifies who pays for download and requests
        def get_request_payment(bucket_name)
          request({
            :expects  => 200,
            :headers  => {},
            :host     => "#{bucket_name}.#{@host}",
            :method   => 'GET',
            :parser   => Fog::Parsers::AWS::S3::GetRequestPayment.new,
            :query    => 'requestPayment'
          })
        end

      end
    end
  end

else

  module Fog
    module AWS
      class S3

        def get_request_payment(bucket_name)
          response = Fog::Response.new
          if bucket = Fog::AWS::S3.data[:buckets][bucket_name]
            response.status = 200
            response.body = { 'Payer' => bucket['Payer'] }
          else
            response.status = 404
            raise(Excon::Errors.status_error(200, 404, response))
          end
          response
        end

      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-0.0.31 lib/fog/aws/requests/s3/get_request_payment.rb
fog-0.0.30 lib/fog/aws/requests/s3/get_request_payment.rb