Skip to content

put_bucket_versioning async

put_bucket_versioning(
    account_id: AccountId,
    bucket: BucketName,
    versioning_configuration: VersioningConfiguration,
    *,
    config_overrides: Optional[AsyncS3ControlClientConfig] = None,
    mfa: Optional[MFA] = None,
) -> None

This operation sets the versioning state for S3 on Outposts buckets only. To set the versioning state for an S3 bucket, see PutBucketVersioning in the Amazon S3 API Reference.

Sets the versioning state for an S3 on Outposts bucket. With S3 Versioning, you can save multiple distinct copies of your objects and recover from unintended user actions and application failures.

You can set the versioning state to one of the following:

  • Enabled - Enables versioning for the objects in the bucket. All objects added to the bucket receive a unique version ID.

  • Suspended - Suspends versioning for the objects in the bucket. All objects added to the bucket receive the version ID null.

If you've never set versioning on your bucket, it has no versioning state. In that case, a GetBucketVersioning request does not return a versioning state value.

When you enable S3 Versioning, for each object in your bucket, you have a current version and zero or more noncurrent versions. You can configure your bucket S3 Lifecycle rules to expire noncurrent versions after a specified time period. For more information, see Creating and managing a lifecycle configuration for your S3 on Outposts bucket in the Amazon S3 User Guide.

If you have an object expiration lifecycle configuration in your non-versioned bucket and you want to maintain the same permanent delete behavior when you enable versioning, you must add a noncurrent expiration policy. The noncurrent expiration lifecycle configuration will manage the deletes of the noncurrent object versions in the version-enabled bucket. For more information, see Versioning in the Amazon S3 User Guide.

All Amazon S3 on Outposts REST API requests for this action require an additional parameter of x-amz-outpost-id to be passed with the request. In addition, you must use an S3 on Outposts endpoint hostname prefix instead of s3-control. For an example of the request syntax for Amazon S3 on Outposts that uses the S3 on Outposts endpoint hostname prefix and the x-amz-outpost-id derived by using the access point ARN, see the Examples section.

The following operations are related to PutBucketVersioning for S3 on Outposts.

Parameters:

  • account_id (AccountId) –

    The Amazon Web Services account ID of the S3 on Outposts bucket.

  • bucket (BucketName) –

    The S3 on Outposts bucket to set the versioning state for.

  • mfa (Optional[MFA], default: None ) –

    The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.

  • versioning_configuration (VersioningConfiguration) –

    The root-level tag for the VersioningConfiguration parameters.

Raises:

Source code in docs_src/capo_s3_control/_services/async_s3_control.py
async def put_bucket_versioning(
    self,
    account_id: "capo_s3_control.types.account_id.AccountId",
    bucket: "capo_s3_control.types.bucket_name.BucketName",
    versioning_configuration: "capo_s3_control.types.versioning_configuration.VersioningConfiguration",
    *,
    config_overrides: Optional[AsyncS3ControlClientConfig] = None,
    mfa: Optional["capo_s3_control.types.mfa.MFA"] = None,
) -> None:
    """<note> <p>This operation sets the versioning state for S3 on Outposts buckets only. To set the versioning state for an S3 bucket, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketVersioning.html">PutBucketVersioning</a> in the <i>Amazon S3 API Reference</i>. </p> </note> <p>Sets the versioning state for an S3 on Outposts bucket. With S3 Versioning, you can save multiple distinct copies of your objects and recover from unintended user actions and application failures.</p> <p>You can set the versioning state to one of the following:</p> <ul> <li> <p> <b>Enabled</b> - Enables versioning for the objects in the bucket. All objects added to the bucket receive a unique version ID.</p> </li> <li> <p> <b>Suspended</b> - Suspends versioning for the objects in the bucket. All objects added to the bucket receive the version ID <code>null</code>.</p> </li> </ul> <p>If you've never set versioning on your bucket, it has no versioning state. In that case, a <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_GetBucketVersioning.html"> GetBucketVersioning</a> request does not return a versioning state value.</p> <p>When you enable S3 Versioning, for each object in your bucket, you have a current version and zero or more noncurrent versions. You can configure your bucket S3 Lifecycle rules to expire noncurrent versions after a specified time period. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3OutpostsLifecycleManaging.html"> Creating and managing a lifecycle configuration for your S3 on Outposts bucket</a> in the <i>Amazon S3 User Guide</i>.</p> <p>If you have an object expiration lifecycle configuration in your non-versioned bucket and you want to maintain the same permanent delete behavior when you enable versioning, you must add a noncurrent expiration policy. The noncurrent expiration lifecycle configuration will manage the deletes of the noncurrent object versions in the version-enabled bucket. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Versioning.html">Versioning</a> in the <i>Amazon S3 User Guide</i>.</p> <p>All Amazon S3 on Outposts REST API requests for this action require an additional parameter of <code>x-amz-outpost-id</code> to be passed with the request. In addition, you must use an S3 on Outposts endpoint hostname prefix instead of <code>s3-control</code>. For an example of the request syntax for Amazon S3 on Outposts that uses the S3 on Outposts endpoint hostname prefix and the <code>x-amz-outpost-id</code> derived by using the access point ARN, see the <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_PutBucketVersioning.html#API_control_PutBucketVersioning_Examples">Examples</a> section.</p> <p>The following operations are related to <code>PutBucketVersioning</code> for S3 on Outposts.</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_GetBucketVersioning.html">GetBucketVersioning</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_PutBucketLifecycleConfiguration.html">PutBucketLifecycleConfiguration</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_control_GetBucketLifecycleConfiguration.html">GetBucketLifecycleConfiguration</a> </p> </li> </ul>

    Args:
        account_id: <p>The Amazon Web Services account ID of the S3 on Outposts bucket.</p>
        bucket: <p>The S3 on Outposts bucket to set the versioning state for.</p>
        mfa: <p>The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.</p>
        versioning_configuration: <p>The root-level tag for the <code>VersioningConfiguration</code> parameters.</p>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_s3_control.types.put_bucket_versioning_request.PutBucketVersioningRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_s3_control._operations.awss3_control_service_v20180820.put_bucket_versioning

        (
            output,
            http_response,
        ) = await capo_s3_control._operations.awss3_control_service_v20180820.put_bucket_versioning.async_put_bucket_versioning(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutBucketVersioning")
    )
    input_: capo_s3_control.types.put_bucket_versioning_request.PutBucketVersioningRequest = {
        "account_id": account_id,
        "bucket": bucket,
        "versioning_configuration": versioning_configuration,
    }
    if mfa is not None:
        input_["mfa"] = mfa

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output