Skip to content

delete_cache_policy

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

Deletes a cache policy.

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

To delete a cache policy, you must provide the policy's identifier and version. To get these values, you can use ListCachePolicies or GetCachePolicy.

Parameters:

  • id (string) –

    The unique identifier for the cache policy that you are deleting. To get the identifier, you can use ListCachePolicies.

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

    The version of the cache policy that you are deleting. The version is the cache policy's ETag value, which you can get using ListCachePolicies, GetCachePolicy, or GetCachePolicyConfig.

Raises:

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

    Args:
        id: <p>The unique identifier for the cache policy that you are deleting. To get the identifier, you can use <code>ListCachePolicies</code>.</p>
        if_match: <p>The version of the cache policy that you are deleting. The version is the cache policy's <code>ETag</code> value, which you can get using <code>ListCachePolicies</code>, <code>GetCachePolicy</code>, or <code>GetCachePolicyConfig</code>.</p>

    Raises:
        capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
        capo_cloudfront.errors.cache_policy_in_use.CachePolicyInUse: <p>Cannot delete the cache policy because it is attached to one or more cache behaviors.</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_cache_policy.NoSuchCachePolicy: <p>The cache 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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudfront.types.delete_cache_policy_request.DeleteCachePolicyRequest]",
    ) -> OperationResponse[None]:
        import capo_cloudfront._operations.cloudfront2020_05_31.delete_cache_policy

        output, http_response = (
            capo_cloudfront._operations.cloudfront2020_05_31.delete_cache_policy.delete_cache_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output