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 eitherDays
orYears
but you must select one. You cannot specifyDays
andYears
at the same time.You can only enable Object Lock for new buckets. If you want to turn on Object Lock for an existing bucket, contact Amazon Web Services Support.
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', 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 applyObjectLockConfiguration
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 eitherDays
orYears
but you must select one. You cannot specifyDays
andYears
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
orYears
but you must select one. You cannot specifyDays
andYears
at the same time.Mode (string) –
The default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Must be used with either
Days
orYears
.Days (integer) –
The number of days that you want to specify for the default retention period. Must be used with
Mode
.Years (integer) –
The number of years that you want to specify for the default retention period. Must be used with
Mode
.
RequestPayer (string) – Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. If either the source or destination Amazon S3 bucket has Requester Pays enabled, the requester will pay for corresponding charges to copy the object. For information about downloading objects from Requester Pays buckets, see Downloading Objects in Requester Pays Buckets in the Amazon S3 User Guide.
Token (string) – A token to allow Object Lock to be enabled for an existing bucket.
ContentMD5 (string) –
The MD5 hash for the request body.
For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.
ChecksumAlgorithm (string) –
Indicates the algorithm used to create the checksum for the object when using the SDK. This header will not provide any additional functionality if not using the SDK. When sending this header, there must be a corresponding
x-amz-checksum
orx-amz-trailer
header sent. Otherwise, Amazon S3 fails the request with the HTTP status code400 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) – The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code
403 Forbidden
(access denied).
- 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.