Skip to content

update_response_headers_policy async

update_response_headers_policy(
    response_headers_policy_config: ResponseHeadersPolicyConfig,
    id: string,
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    if_match: Optional[string] = None,
) -> UpdateResponseHeadersPolicyResult

Updates a response headers policy.

When you update a response headers policy, the entire policy is replaced. You cannot update some policy fields independent of others. To update a response headers policy configuration:

  1. Use GetResponseHeadersPolicyConfig to get the current policy's configuration.

  2. Modify the fields in the response headers policy configuration that you want to update.

  3. Call UpdateResponseHeadersPolicy, providing the entire response headers policy configuration, including the fields that you modified and those that you didn't.

Parameters:

  • response_headers_policy_config (ResponseHeadersPolicyConfig) –

    A response headers policy configuration.

  • id (string) –

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

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

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

    The version is returned in the cache policy's ETag field in the response to GetResponseHeadersPolicyConfig.

Raises:

Source code in docs_src/capo_cloudfront/_services/async_cloud_front.py
async def update_response_headers_policy(
    self,
    response_headers_policy_config: "capo_cloudfront.types.response_headers_policy_config.ResponseHeadersPolicyConfig",
    id: "capo_cloudfront.types.string.string",
    *,
    config_overrides: Optional[AsyncCloudFrontClientConfig] = None,
    if_match: Optional["capo_cloudfront.types.string.string"] = None,
) -> "capo_cloudfront.types.update_response_headers_policy_result.UpdateResponseHeadersPolicyResult":
    """<p>Updates a response headers policy.</p> <p>When you update a response headers policy, the entire policy is replaced. You cannot update some policy fields independent of others. To update a response headers policy configuration:</p> <ol> <li> <p>Use <code>GetResponseHeadersPolicyConfig</code> to get the current policy's configuration.</p> </li> <li> <p>Modify the fields in the response headers policy configuration that you want to update.</p> </li> <li> <p>Call <code>UpdateResponseHeadersPolicy</code>, providing the entire response headers policy configuration, including the fields that you modified and those that you didn't.</p> </li> </ol>

    Args:
        response_headers_policy_config: <p>A response headers policy configuration.</p>
        id: <p>The identifier for the response headers policy that you are updating.</p>
        if_match: <p>The version of the response headers policy that you are updating.</p> <p>The version is returned in the cache policy's <code>ETag</code> field in the response to <code>GetResponseHeadersPolicyConfig</code>.</p>

    Raises:
        capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
        capo_cloudfront.errors.illegal_update.IllegalUpdate: <p>The update contains modifications that are not allowed.</p>
        capo_cloudfront.errors.inconsistent_quantities.InconsistentQuantities: <p>The value of <code>Quantity</code> and the size of <code>Items</code> don't match.</p>
        capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</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_already_exists.ResponseHeadersPolicyAlreadyExists: <p>A response headers policy with this name already exists. You must provide a unique name. To modify an existing response headers policy, use <code>UpdateResponseHeadersPolicy</code>.</p>
        capo_cloudfront.errors.too_long_csp_in_response_headers_policy.TooLongCSPInResponseHeadersPolicy: <p>The length of the <code>Content-Security-Policy</code> header value in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_custom_headers_in_response_headers_policy.TooManyCustomHeadersInResponseHeadersPolicy: <p>The number of custom headers in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.too_many_remove_headers_in_response_headers_policy.TooManyRemoveHeadersInResponseHeadersPolicy: <p>The number of headers in <code>RemoveHeadersConfig</code> in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudfront.types.update_response_headers_policy_request.UpdateResponseHeadersPolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_cloudfront.types.update_response_headers_policy_result.UpdateResponseHeadersPolicyResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.update_response_headers_policy

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateResponseHeadersPolicy")
    )
    input_: capo_cloudfront.types.update_response_headers_policy_request.UpdateResponseHeadersPolicyRequest = {
        "response_headers_policy_config": response_headers_policy_config,
        "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