Skip to content

get_bucket_ownership_controls async

get_bucket_ownership_controls(
    bucket: BucketName,
    *,
    config_overrides: Optional[AsyncS3ClientConfig] = None,
    expected_bucket_owner: Optional[AccountId] = None,
) -> GetBucketOwnershipControlsOutput

This operation is not supported for directory buckets.

Retrieves OwnershipControls for an Amazon S3 bucket. To use this operation, you must have the s3:GetBucketOwnershipControls permission. For more information about Amazon S3 permissions, see Specifying permissions in a policy.

A bucket doesn't have OwnershipControls settings in the following cases:

  • The bucket was created before the BucketOwnerEnforced ownership setting was introduced and you've never explicitly applied this value

  • You've manually deleted the bucket ownership control value using the DeleteBucketOwnershipControls API operation.

By default, Amazon S3 sets OwnershipControls for all newly created buckets.

For information about Amazon S3 Object Ownership, see Using Object Ownership.

The following operations are related to GetBucketOwnershipControls:

You must URL encode any signed header values that contain spaces. For example, if your header value is my file.txt, containing two spaces after my, you must URL encode this value to my%20%20file.txt.

Parameters:

  • bucket (BucketName) –

    The name of the Amazon S3 bucket whose OwnershipControls you want to retrieve.

  • expected_bucket_owner (Optional[AccountId], default: None ) –

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

Raises:

Source code in docs_src/capo_s3/_services/async_s3.py
async def get_bucket_ownership_controls(
    self,
    bucket: "capo_s3.types.bucket_name.BucketName",
    *,
    config_overrides: Optional[AsyncS3ClientConfig] = None,
    expected_bucket_owner: Optional["capo_s3.types.account_id.AccountId"] = None,
) -> "capo_s3.types.get_bucket_ownership_controls_output.GetBucketOwnershipControlsOutput":
    """<note> <p>This operation is not supported for directory buckets.</p> </note> <p>Retrieves <code>OwnershipControls</code> for an Amazon S3 bucket. To use this operation, you must have the <code>s3:GetBucketOwnershipControls</code> permission. For more information about Amazon S3 permissions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html">Specifying permissions in a policy</a>. </p> <note> <p>A bucket doesn't have <code>OwnershipControls</code> settings in the following cases:</p> <ul> <li> <p>The bucket was created before the <code>BucketOwnerEnforced</code> ownership setting was introduced and you've never explicitly applied this value</p> </li> <li> <p>You've manually deleted the bucket ownership control value using the <code>DeleteBucketOwnershipControls</code> API operation.</p> </li> </ul> <p>By default, Amazon S3 sets <code>OwnershipControls</code> for all newly created buckets.</p> </note> <p>For information about Amazon S3 Object Ownership, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html">Using Object Ownership</a>. </p> <p>The following operations are related to <code>GetBucketOwnershipControls</code>:</p> <ul> <li> <p> <a>PutBucketOwnershipControls</a> </p> </li> <li> <p> <a>DeleteBucketOwnershipControls</a> </p> </li> </ul> <important> <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p> </important>

    Args:
        bucket: <p>The name of the Amazon S3 bucket whose <code>OwnershipControls</code> you want to retrieve. </p>
        expected_bucket_owner: <p>The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code <code>403 Forbidden</code> (access denied).</p>

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

    async def _handler(
        req: "AsyncOperationRequest[capo_s3.types.get_bucket_ownership_controls_request.GetBucketOwnershipControlsRequest]",
    ) -> AsyncOperationResponse[
        "capo_s3.types.get_bucket_ownership_controls_output.GetBucketOwnershipControlsOutput"
    ]:
        import capo_s3._operations.amazon_s3.get_bucket_ownership_controls

        (
            output,
            http_response,
        ) = await capo_s3._operations.amazon_s3.get_bucket_ownership_controls.async_get_bucket_ownership_controls(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetBucketOwnershipControls")
    )
    input_: capo_s3.types.get_bucket_ownership_controls_request.GetBucketOwnershipControlsRequest = {
        "bucket": bucket
    }
    if expected_bucket_owner is not None:
        input_["expected_bucket_owner"] = expected_bucket_owner

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