Skip to content

update_key_group

update_key_group(
    key_group_config: KeyGroupConfig,
    id: string,
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
    if_match: Optional[string] = None,
) -> UpdateKeyGroupResult

Updates a key group.

When you update a key group, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update a key group:

  1. Get the current key group with GetKeyGroup or GetKeyGroupConfig.

  2. Locally modify the fields in the key group that you want to update. For example, add or remove public key IDs.

  3. Call UpdateKeyGroup with the entire key group object, including the fields that you modified and those that you didn't.

Parameters:

  • key_group_config (KeyGroupConfig) –

    The key group configuration.

  • id (string) –

    The identifier of the key group that you are updating.

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

    The version of the key group that you are updating. The version is the key group's ETag value.

Raises:

  • InvalidArgument –

    An argument is invalid.

  • InvalidIfMatchVersion –

    The If-Match version is missing or not valid.

  • KeyGroupAlreadyExists –

    A key group with this name already exists. You must provide a unique name. To modify an existing key group, use UpdateKeyGroup.

  • NoSuchResource –

    A resource that was specified is not valid.

  • PreconditionFailed –

    The precondition in one or more of the request fields evaluated to false.

  • TooManyPublicKeysInKeyGroup –

    The number of public keys in this key group is more than the maximum allowed. For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_cloudfront/_services/cloud_front.py
def update_key_group(
    self,
    key_group_config: "capo_cloudfront.types.key_group_config.KeyGroupConfig",
    id: "capo_cloudfront.types.string.string",
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
    if_match: Optional["capo_cloudfront.types.string.string"] = None,
) -> "capo_cloudfront.types.update_key_group_result.UpdateKeyGroupResult":
    """<p>Updates a key group.</p> <p>When you update a key group, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update a key group:</p> <ol> <li> <p>Get the current key group with <code>GetKeyGroup</code> or <code>GetKeyGroupConfig</code>.</p> </li> <li> <p>Locally modify the fields in the key group that you want to update. For example, add or remove public key IDs.</p> </li> <li> <p>Call <code>UpdateKeyGroup</code> with the entire key group object, including the fields that you modified and those that you didn't.</p> </li> </ol>

    Args:
        key_group_config: <p>The key group configuration.</p>
        id: <p>The identifier of the key group that you are updating.</p>
        if_match: <p>The version of the key group that you are updating. The version is the key group's <code>ETag</code> value.</p>

    Raises:
        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.key_group_already_exists.KeyGroupAlreadyExists: <p>A key group with this name already exists. You must provide a unique name. To modify an existing key group, use <code>UpdateKeyGroup</code>.</p>
        capo_cloudfront.errors.no_such_resource.NoSuchResource: <p>A resource that was specified is not valid.</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.too_many_public_keys_in_key_group.TooManyPublicKeysInKeyGroup: <p>The number of public keys in this key group is more than the maximum allowed. 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.
    """

    def _handler(
        req: "OperationRequest[capo_cloudfront.types.update_key_group_request.UpdateKeyGroupRequest]",
    ) -> OperationResponse[
        "capo_cloudfront.types.update_key_group_result.UpdateKeyGroupResult"
    ]:
        import capo_cloudfront._operations.cloudfront2020_05_31.update_key_group

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateKeyGroup")
    )
    input_: capo_cloudfront.types.update_key_group_request.UpdateKeyGroupRequest = {
        "key_group_config": key_group_config,
        "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