Skip to content

update_automation_rule

update_automation_rule(
    rule_arn: RuleArn,
    rule_revision: int,
    *,
    config_overrides: Optional[ComputeOptimizerAutomationClientConfig] = None,
    name: Optional[RuleName] = None,
    description: Optional[RuleDescription] = None,
    rule_type: Optional[RuleType] = None,
    organization_configuration: Optional[OrganizationConfiguration] = None,
    priority: Optional[str] = None,
    recommended_action_types: Optional[RecommendedActionTypeList] = None,
    criteria: Optional[Criteria] = None,
    schedule: Optional[Schedule] = None,
    status: Optional[RuleStatus] = None,
    client_token: Optional[ClientToken] = None,
) -> UpdateAutomationRuleResponse

Updates an existing automation rule.

Parameters:

  • rule_arn (RuleArn) –

    The ARN of the rule to update.

  • rule_revision (int) –

    The revision number of the rule to update.

  • name (Optional[RuleName], default: None ) –

    The updated name of the automation rule. Must be 1-128 characters long and contain only alphanumeric characters, underscores, and hyphens.

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

    The updated description of the automation rule. Can be up to 1024 characters long and contain alphanumeric characters, underscores, hyphens, spaces, and certain special characters.

  • rule_type (Optional[RuleType], default: None ) –

    The updated type of automation rule. Can be either OrganizationRule for organization-wide rules or AccountRule for account-specific rules.

  • organization_configuration (Optional[OrganizationConfiguration], default: None ) –

    Updated configuration settings for organization-wide rules, including rule application order and target account IDs.

  • priority (Optional[str], default: None ) –

    The updated priority level of the automation rule, used to determine execution order when multiple rules apply to the same resource.

  • recommended_action_types (Optional[RecommendedActionTypeList], default: None ) –

    Updated list of recommended action types that this rule can execute, such as SnapshotAndDeleteUnattachedEbsVolume or UpgradeEbsVolumeType.

  • schedule (Optional[Schedule], default: None ) –

    The updated schedule configuration for when the automation rule should execute, including cron expression, timezone, and execution window.

  • status (Optional[RuleStatus], default: None ) –

    The updated status of the automation rule. Can be Active or Inactive.

  • client_token (Optional[ClientToken], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Must be 1-64 characters long and contain only alphanumeric characters, underscores, and hyphens.

Raises:

Source code in docs_src/capo_compute_optimizer_automation/_services/compute_optimizer_automation.py
def update_automation_rule(
    self,
    rule_arn: "capo_compute_optimizer_automation.types.rule_arn.RuleArn",
    rule_revision: int,
    *,
    config_overrides: Optional[ComputeOptimizerAutomationClientConfig] = None,
    name: Optional[
        "capo_compute_optimizer_automation.types.rule_name.RuleName"
    ] = None,
    description: Optional[
        "capo_compute_optimizer_automation.types.rule_description.RuleDescription"
    ] = None,
    rule_type: Optional[
        "capo_compute_optimizer_automation.types.rule_type.RuleType"
    ] = None,
    organization_configuration: Optional[
        "capo_compute_optimizer_automation.types.organization_configuration.OrganizationConfiguration"
    ] = None,
    priority: Optional[str] = None,
    recommended_action_types: Optional[
        "capo_compute_optimizer_automation.types.recommended_action_type_list.RecommendedActionTypeList"
    ] = None,
    criteria: Optional[
        "capo_compute_optimizer_automation.types.criteria.Criteria"
    ] = None,
    schedule: Optional[
        "capo_compute_optimizer_automation.types.schedule.Schedule"
    ] = None,
    status: Optional[
        "capo_compute_optimizer_automation.types.rule_status.RuleStatus"
    ] = None,
    client_token: Optional[
        "capo_compute_optimizer_automation.types.client_token.ClientToken"
    ] = None,
) -> "capo_compute_optimizer_automation.types.update_automation_rule_response.UpdateAutomationRuleResponse":
    """<p> Updates an existing automation rule. </p>

    Args:
        rule_arn: <p> The ARN of the rule to update. </p>
        rule_revision: <p> The revision number of the rule to update. </p>
        name: <p>The updated name of the automation rule. Must be 1-128 characters long and contain only alphanumeric characters, underscores, and hyphens.</p>
        description: <p>The updated description of the automation rule. Can be up to 1024 characters long and contain alphanumeric characters, underscores, hyphens, spaces, and certain special characters.</p>
        rule_type: <p>The updated type of automation rule. Can be either OrganizationRule for organization-wide rules or AccountRule for account-specific rules.</p>
        organization_configuration: <p>Updated configuration settings for organization-wide rules, including rule application order and target account IDs.</p>
        priority: <p>The updated priority level of the automation rule, used to determine execution order when multiple rules apply to the same resource.</p>
        recommended_action_types: <p>Updated list of recommended action types that this rule can execute, such as SnapshotAndDeleteUnattachedEbsVolume or UpgradeEbsVolumeType.</p>
        schedule: <p>The updated schedule configuration for when the automation rule should execute, including cron expression, timezone, and execution window.</p>
        status: <p>The updated status of the automation rule. Can be Active or Inactive.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Must be 1-64 characters long and contain only alphanumeric characters, underscores, and hyphens.</p>

    Raises:
        capo_compute_optimizer_automation.errors.access_denied_exception.AccessDeniedException: <p> You do not have sufficient permissions to perform this action. </p>
        capo_compute_optimizer_automation.errors.forbidden_exception.ForbiddenException: <p> You are not authorized to perform this action. </p>
        capo_compute_optimizer_automation.errors.idempotency_token_in_use_exception.IdempotencyTokenInUseException: <p> The specified client token is already in use. </p>
        capo_compute_optimizer_automation.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>Exception thrown when the same client token is used with different parameters, indicating a mismatch in idempotent request parameters.</p>
        capo_compute_optimizer_automation.errors.internal_server_exception.InternalServerException: <p> An internal error occurred while processing the request. </p>
        capo_compute_optimizer_automation.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p> One or more parameter values are not valid. </p>
        capo_compute_optimizer_automation.errors.opt_in_required_exception.OptInRequiredException: <p> The account must be opted in to Compute Optimizer Automation before performing this action. </p>
        capo_compute_optimizer_automation.errors.resource_not_found_exception.ResourceNotFoundException: <p> The specified resource was not found. </p>
        capo_compute_optimizer_automation.errors.service_unavailable_exception.ServiceUnavailableException: <p> The service is temporarily unavailable. </p>
        capo_compute_optimizer_automation.errors.throttling_exception.ThrottlingException: <p> The request was denied due to request throttling. </p>
        capo_compute_optimizer_automation.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_compute_optimizer_automation.types.update_automation_rule_request.UpdateAutomationRuleRequest]",
    ) -> OperationResponse[
        "capo_compute_optimizer_automation.types.update_automation_rule_response.UpdateAutomationRuleResponse"
    ]:
        import capo_compute_optimizer_automation._operations.compute_optimizer_automation_service.update_automation_rule

        output, http_response = (
            capo_compute_optimizer_automation._operations.compute_optimizer_automation_service.update_automation_rule.update_automation_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateAutomationRule")
    )
    input_: capo_compute_optimizer_automation.types.update_automation_rule_request.UpdateAutomationRuleRequest = {
        "rule_arn": rule_arn,
        "rule_revision": rule_revision,
    }
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if rule_type is not None:
        input_["rule_type"] = rule_type
    if organization_configuration is not None:
        input_["organization_configuration"] = organization_configuration
    if priority is not None:
        input_["priority"] = priority
    if recommended_action_types is not None:
        input_["recommended_action_types"] = recommended_action_types
    if criteria is not None:
        input_["criteria"] = criteria
    if schedule is not None:
        input_["schedule"] = schedule
    if status is not None:
        input_["status"] = status
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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