Skip to content

put_bucket_request_payment

put_bucket_request_payment(
    bucket: BucketName,
    request_payment_configuration: RequestPaymentConfiguration,
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    content_md5: Optional[ContentMD5] = None,
    checksum_algorithm: Optional[ChecksumAlgorithm] = None,
    expected_bucket_owner: Optional[AccountId] = None,
) -> None

This operation is not supported for directory buckets.

Sets the request payment configuration for a bucket. By default, the bucket owner pays for downloads from the bucket. This configuration parameter enables the bucket owner (only) to specify that the person requesting the download will be charged for the download. For more information, see Requester Pays Buckets.

The following operations are related to PutBucketRequestPayment:

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

  • bucket (BucketName) –

    The bucket name.

  • content_md5 (Optional[ContentMD5], default: None ) –

    The Base64 encoded 128-bit MD5 digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see RFC 1864.

    For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.

  • checksum_algorithm (Optional[ChecksumAlgorithm], default: None ) –

    Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding x-amz-checksum or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the HTTP status code 400 Bad Request. For more information, see Checking object integrity in the Amazon S3 User Guide.

    If you provide an individual checksum, Amazon S3 ignores any provided ChecksumAlgorithm parameter.

  • request_payment_configuration (RequestPaymentConfiguration) –

    Container for Payer.

  • expected_bucket_owner (Optional[AccountId], default: None ) –

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

Raises:

Examples:

Set request payment configuration on a bucket. The following example sets request payment configuration on a bucket so that person requesting the download is charged.

>>> client.put_bucket_request_payment(bucket='examplebucket', request_payment_configuration={'Payer': 'Requester'})
Source code in docs_src/capo_s3/_services/s3.py
def put_bucket_request_payment(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    request_payment_configuration: "capo_s3.types.request_payment_configuration.RequestPaymentConfiguration",
    *,
    config_overrides: Optional[S3ClientConfig] = None,
    content_md5: Optional["capo_s3.types.content_md5.ContentMD5"] = None,
    checksum_algorithm: Optional[
        "capo_s3.types.checksum_algorithm.ChecksumAlgorithm"
    ] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
) -> None:
    """<note> <p>This operation is not supported for directory buckets.</p> </note> <p>Sets the request payment configuration for a bucket. By default, the bucket owner pays for downloads from the bucket. This configuration parameter enables the bucket owner (only) to specify that the person requesting the download will be charged for the download. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/RequesterPaysBuckets.html">Requester Pays Buckets</a>.</p> <p>The following operations are related to <code>PutBucketRequestPayment</code>:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html">CreateBucket</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketRequestPayment.html">GetBucketRequestPayment</a> </p> </li> </ul> <important> <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p> </important>

    Args:
        bucket: <p>The bucket name.</p>
        content_md5: <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864</a>.</p> <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
        checksum_algorithm: <p>Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding <code>x-amz-checksum</code> or <code>x-amz-trailer</code> header sent. Otherwise, Amazon S3 fails the request with the HTTP status code <code>400 Bad Request</code>. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html">Checking object integrity</a> in the <i>Amazon S3 User Guide</i>.</p> <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
        request_payment_configuration: <p>Container for Payer.</p>
        expected_bucket_owner: <p>The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code <code>403 Forbidden</code> (access denied).</p>

    Raises:
        capo_s3.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Set request payment configuration on a bucket.
        The following example sets request payment configuration on a bucket so that person requesting the download is charged.

        >>> client.put_bucket_request_payment(bucket='examplebucket', request_payment_configuration={'Payer': 'Requester'})
    """

    def _handler(
        req: "OperationRequest[capo_s3.types.put_bucket_request_payment_request.PutBucketRequestPaymentRequest]",
    ) -> OperationResponse[None]:
        import capo_s3._operations.amazon_s3.put_bucket_request_payment

        output, http_response = (
            capo_s3._operations.amazon_s3.put_bucket_request_payment.put_bucket_request_payment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutBucketRequestPayment")
    )
    input_: capo_s3.types.put_bucket_request_payment_request.PutBucketRequestPaymentRequest = {
        "bucket": bucket,
        "request_payment_configuration": request_payment_configuration,
    }
    if content_md5 is not None:
        input_["content_md5"] = content_md5
    if checksum_algorithm is not None:
        input_["checksum_algorithm"] = checksum_algorithm
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output