S3 / Client / put_object_lock_configuration

put_object_lock_configuration#

S3.Client.put_object_lock_configuration(**kwargs)#

Places an Object Lock configuration on the specified bucket. The rule specified in the Object Lock configuration will be applied by default to every new object placed in the specified bucket. For more information, see Locking Objects.

Note

  • The DefaultRetention settings require both a mode and a period.

  • The DefaultRetention period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.

See also: AWS API Documentation

Request Syntax

response = client.put_object_lock_configuration(
    Bucket='string',
    ObjectLockConfiguration={
        'ObjectLockEnabled': 'Enabled',
        'Rule': {
            'DefaultRetention': {
                'Mode': 'GOVERNANCE'|'COMPLIANCE',
                'Days': 123,
                'Years': 123
            }
        }
    },
    RequestPayer='requester',
    Token='string',
    ContentMD5='string',
    ChecksumAlgorithm='CRC32'|'CRC32C'|'SHA1'|'SHA256'|'CRC64NVME',
    ExpectedBucketOwner='string'
)
Parameters:
  • Bucket (string) –

    [REQUIRED]

    The bucket whose Object Lock configuration you want to create or replace.

  • ObjectLockConfiguration (dict) –

    The Object Lock configuration that you want to apply to the specified bucket.

    • ObjectLockEnabled (string) –

      Indicates whether this bucket has an Object Lock configuration enabled. Enable ObjectLockEnabled when you apply ObjectLockConfiguration to a bucket.

    • Rule (dict) –

      Specifies the Object Lock rule for the specified object. Enable the this rule when you apply ObjectLockConfiguration to a bucket. Bucket settings require both a mode and a period. The period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.

      • DefaultRetention (dict) –

        The default Object Lock retention mode and period that you want to apply to new objects placed in the specified bucket. Bucket settings require both a mode and a period. The period can be either Days or Years but you must select one. You cannot specify Days and Years at the same time.

        • Mode (string) –

          The default Object Lock retention mode you want to apply to new objects placed in the specified bucket.

        • Days (integer) –

          The number of days that you want to specify for the default retention period.

        • Years (integer) –

          The number of years that you want to specify for the default retention period.

  • RequestPayer (string) – Ignored by COS if present.

  • Token (string) – Ignored by COS if present.

  • ContentMD5 (string) –

    The MD5 hash for the request body.

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

  • ChecksumAlgorithm (string) –

    Indicates the algorithm used to create the checksum for the object 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.

  • ExpectedBucketOwner (string) – Ignored by COS if present.

Return type:

dict

Returns:

Response Syntax

{
    'RequestCharged': 'requester'
}

Response Structure

  • (dict) –

    • RequestCharged (string) –

      If present, indicates that the requester was successfully charged for the request.