@SdkInternalApi
    final PutBucketVersioningResult executePutBucketVersioning(PutBucketVersioningRequest putBucketVersioningRequest) {

        ExecutionContext executionContext = createExecutionContext(putBucketVersioningRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<PutBucketVersioningRequest> request = null;
        Response<PutBucketVersioningResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                String bucket = putBucketVersioningRequest.getBucket();
                Arn arn = null;
                if (bucket != null && bucket.startsWith("arn:")) {
                    arn = Arn.fromString(bucket);
                    AwsResource awsResource = com.amazonaws.services.s3control.internal.S3ControlArnConverter.getInstance().convertArn(arn);

                    if (!(awsResource instanceof com.amazonaws.services.s3control.internal.S3ControlBucketResource)) {
                        throw new IllegalArgumentException("Unsupported ARN type: " + awsResource.getClass()
                                + ". Expected com.amazonaws.services.s3control.internal.S3ControlBucketResource.");
                    }

                    com.amazonaws.services.s3control.internal.S3ControlBucketResource resource = (com.amazonaws.services.s3control.internal.S3ControlBucketResource) awsResource;

                    putBucketVersioningRequest = putBucketVersioningRequest.clone();
                    putBucketVersioningRequest.setBucket(resource.getBucketName());

                    String accountId = putBucketVersioningRequest.getAccountId();
                    String accountIdInArn = resource.getAccountId();
                    if (accountId != null && !accountId.equals(accountIdInArn)) {
                        throw new IllegalArgumentException(String.format("%s field provided from the request (%s) is different from the one in the ARN (%s)",
                                "accountId", accountId, accountIdInArn));
                    }
                    putBucketVersioningRequest.setAccountId(accountIdInArn);
                }
                request = new PutBucketVersioningRequestMarshaller().marshall(super.beforeMarshalling(putBucketVersioningRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "S3 Control");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutBucketVersioning");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
                request.addHandlerContext(S3ControlHandlerContextKey.S3_ARNABLE_FIELD, new S3ArnableField().withArn(arn));

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            URI endpointTraitHost = null;
            if (!clientConfiguration.isDisableHostPrefixInjection()) {
                ValidationUtils.assertStringNotEmpty(putBucketVersioningRequest.getAccountId(), "AccountId");
                HostnameValidator.validateHostnameCompliant(putBucketVersioningRequest.getAccountId(), "AccountId", "putBucketVersioningRequest");

                String hostPrefix = "{AccountId}.";
                String resolvedHostPrefix = String.format("%s.", putBucketVersioningRequest.getAccountId());

                endpointTraitHost = UriResourcePathUtils.updateUriHost(endpoint, resolvedHostPrefix);
            }

            StaxResponseHandler<PutBucketVersioningResult> responseHandler = new com.amazonaws.services.s3control.internal.S3ControlStaxResponseHandler<PutBucketVersioningResult>(
                    new PutBucketVersioningResultStaxUnmarshaller());

            response = invoke(request, responseHandler, executionContext, null, endpointTraitHost);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<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>

@param putBucketVersioningRequest
@return Result of the PutBucketVersioning operation returned by the service.
@sample AWSS3Control.PutBucketVersioning
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/s3control-2018-08-20/PutBucketVersioning" target="_top">AWS
     API Documentation</a>
aws-java-sdk-s3control/src/main/java/com/amazonaws/services/s3control/AWSS3ControlClient.java