Skip to content

update_rule

update_rule(
    identifier: RuleIdentifier,
    *,
    config_overrides: Optional[rbinClientConfig] = None,
    retention_period: Optional[RetentionPeriod] = None,
    description: Optional[Description] = None,
    resource_type: Optional[ResourceType] = None,
    resource_tags: Optional[ResourceTags] = None,
    exclude_resource_tags: Optional[ExcludeResourceTags] = None,
) -> UpdateRuleResponse

Updates an existing Recycle Bin retention rule. You can update a retention rule's description, resource tags, and retention period at any time after creation. You can't update a retention rule's resource type after creation. For more information, see Update Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide.

Parameters:

  • identifier (RuleIdentifier) –

    The unique ID of the retention rule.

  • retention_period (Optional[RetentionPeriod], default: None ) –

    Information about the retention period for which the retention rule is to retain resources.

  • description (Optional[Description], default: None ) –

    The retention rule description.

  • resource_type (Optional[ResourceType], default: None ) –

    This parameter is currently not supported. You can't update a retention rule's resource type after creation.

  • resource_tags (Optional[ResourceTags], default: None ) –

    [Tag-level retention rules only] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

    You can add the same tag key and value pair to a maximum or five retention rules.

    To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.

  • exclude_resource_tags (Optional[ExcludeResourceTags], default: None ) –

    [Region-level retention rules only] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. Resources that have any of these tags are not retained by the retention rule upon deletion.

    You can't specify exclusion tags for tag-level retention rules.

Raises:

Source code in docs_src/capo_rbin/_services/rbin.py
def update_rule(
    self,
    identifier: "capo_rbin.types.rule_identifier.RuleIdentifier",
    *,
    config_overrides: Optional[rbinClientConfig] = None,
    retention_period: Optional[
        "capo_rbin.types.retention_period.RetentionPeriod"
    ] = None,
    description: Optional["capo_rbin.types.description.Description"] = None,
    resource_type: Optional["capo_rbin.types.resource_type.ResourceType"] = None,
    resource_tags: Optional["capo_rbin.types.resource_tags.ResourceTags"] = None,
    exclude_resource_tags: Optional[
        "capo_rbin.types.exclude_resource_tags.ExcludeResourceTags"
    ] = None,
) -> "capo_rbin.types.update_rule_response.UpdateRuleResponse":
    """<p>Updates an existing Recycle Bin retention rule. You can update a retention rule's description, resource tags, and retention period at any time after creation. You can't update a retention rule's resource type after creation. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recycle-bin-working-with-rules.html#recycle-bin-update-rule"> Update Recycle Bin retention rules</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>

    Args:
        identifier: <p>The unique ID of the retention rule.</p>
        retention_period: <p>Information about the retention period for which the retention rule is to retain resources.</p>
        description: <p>The retention rule description.</p>
        resource_type: <note> <p>This parameter is currently not supported. You can't update a retention rule's resource type after creation.</p> </note>
        resource_tags: <p>[Tag-level retention rules only] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.</p> <p>You can add the same tag key and value pair to a maximum or five retention rules.</p> <p>To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.</p>
        exclude_resource_tags: <p>[Region-level retention rules only] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. Resources that have any of these tags are not retained by the retention rule upon deletion.</p> <p>You can't specify exclusion tags for tag-level retention rules.</p>

    Raises:
        capo_rbin.errors.conflict_exception.ConflictException: <p>The specified retention rule lock request can't be completed.</p>
        capo_rbin.errors.internal_server_exception.InternalServerException: <p>The service could not respond to the request due to an internal problem.</p>
        capo_rbin.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_rbin.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota for the number of tags per resource to be exceeded.</p>
        capo_rbin.errors.validation_exception.ValidationException: <p>One or more of the parameters in the request is not valid.</p>
        capo_rbin.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_rbin.types.update_rule_request.UpdateRuleRequest]",
    ) -> OperationResponse[
        "capo_rbin.types.update_rule_response.UpdateRuleResponse"
    ]:
        import capo_rbin._operations.amazon_recycle_bin.update_rule

        output, http_response = (
            capo_rbin._operations.amazon_recycle_bin.update_rule.update_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateRule")
    )
    input_: capo_rbin.types.update_rule_request.UpdateRuleRequest = {
        "identifier": identifier
    }
    if retention_period is not None:
        input_["retention_period"] = retention_period
    if description is not None:
        input_["description"] = description
    if resource_type is not None:
        input_["resource_type"] = resource_type
    if resource_tags is not None:
        input_["resource_tags"] = resource_tags
    if exclude_resource_tags is not None:
        input_["exclude_resource_tags"] = exclude_resource_tags

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