Skip to content

delete_response_headers_policy async

delete_response_headers_policy(
    id: string,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    if_match: Optional[string] = None,
) -> None

Deletes a response headers policy.

You cannot delete a response headers policy if it's attached to a cache behavior. First update your distributions to remove the response headers policy from all cache behaviors, then delete the response headers policy.

To delete a response headers policy, you must provide the policy's identifier and version. To get these values, you can use ListResponseHeadersPolicies or GetResponseHeadersPolicy.

Parameters:

  • id (string) –

    The identifier for the response headers policy that you are deleting.

    To get the identifier, you can use ListResponseHeadersPolicies.

  • if_match (Optional[string], default: None ) –

    The version of the response headers policy that you are deleting.

    The version is the response headers policy's ETag value, which you can get using ListResponseHeadersPolicies, GetResponseHeadersPolicy, or GetResponseHeadersPolicyConfig.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def delete_response_headers_policy(
    self,
    id: "capo_cloudfront.types.string.string",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    if_match: Optional["capo_cloudfront.types.string.string"] = None,
) -> None:
    """<p>Deletes a response headers policy.</p> <p>You cannot delete a response headers policy if it's attached to a cache behavior. First update your distributions to remove the response headers policy from all cache behaviors, then delete the response headers policy.</p> <p>To delete a response headers policy, you must provide the policy's identifier and version. To get these values, you can use <code>ListResponseHeadersPolicies</code> or <code>GetResponseHeadersPolicy</code>.</p>

    Args:
        id: <p>The identifier for the response headers policy that you are deleting.</p> <p>To get the identifier, you can use <code>ListResponseHeadersPolicies</code>.</p>
        if_match: <p>The version of the response headers policy that you are deleting.</p> <p>The version is the response headers policy's <code>ETag</code> value, which you can get using <code>ListResponseHeadersPolicies</code>, <code>GetResponseHeadersPolicy</code>, or <code>GetResponseHeadersPolicyConfig</code>.</p>

    Raises:
        capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
        capo_cloudfront.errors.illegal_delete.IllegalDelete: <p>Deletion is not allowed for this entity.</p>
        capo_cloudfront.errors.invalid_if_match_version.InvalidIfMatchVersion: <p>The <code>If-Match</code> version is missing or not valid.</p>
        capo_cloudfront.errors.no_such_response_headers_policy.NoSuchResponseHeadersPolicy: <p>The response headers policy does not exist.</p>
        capo_cloudfront.errors.precondition_failed.PreconditionFailed: <p>The precondition in one or more of the request fields evaluated to <code>false</code>.</p>
        capo_cloudfront.errors.response_headers_policy_in_use.ResponseHeadersPolicyInUse: <p>Cannot delete the response headers policy because it is attached to one or more cache behaviors in a CloudFront distribution.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.delete_response_headers_policy_request.DeleteResponseHeadersPolicyRequest]",
    ) -> AsyncOperationResponse[None]:
        import capo_cloudfront._operations.cloudfront2020_05_31.delete_response_headers_policy

        (
            output,
            http_response,
        ) = await capo_cloudfront._operations.cloudfront2020_05_31.delete_response_headers_policy.async_delete_response_headers_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteResponseHeadersPolicy")
    )
    input_: capo_cloudfront.types.delete_response_headers_policy_request.DeleteResponseHeadersPolicyRequest = {
        "id": id
    }
    if if_match is not None:
        input_["if_match"] = if_match

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