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',
    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.

  • 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.