Skip to content

update_alert

update_alert(
    space_id: SpaceId,
    alert_id: AlertId,
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    profile_id: Optional[ProfileId] = None,
    name: Optional[str] = None,
    description: Optional[str] = None,
    rule: Optional[Rule] = None,
    notifications_enabled: Optional[bool] = None,
    notification_rules: Optional[NotificationRuleList] = None,
) -> UpdateAlertOutput

Updates an existing alert. Only non-null fields overwrite existing values.

Parameters:

  • space_id (SpaceId) –

    The unique ID of the space.

  • alert_id (AlertId) –

    The alert to update.

  • profile_id (Optional[ProfileId], default: None ) –

    The ID of the access profile associated with the alert.

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

    A new display name for the alert. Omit to leave the name unchanged (apply-if-present / PATCH). Same constraints as CreateAlert.name; the name is not the alert's identity, so a rename never changes the alertId.

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

    A new description of the alert. Omit to leave unchanged.

  • rule (Optional[Rule], default: None ) –

    The rule that defines how the alert is evaluated. Omit to leave unchanged. Each sub-block is replaced whole when present: {@code query}, {@code condition}, {@code evaluation} and {@code noData} are applied only when supplied, and within a supplied block an omitted optional member is cleared to unset (null/absent) rather than preserved from the stored alert or defaulted. See {@link AlertCondition} and {@link AlertEvaluation}.

  • notifications_enabled (Optional[bool], default: None ) –

    Whether actions (notifications) are enabled for this alert. Omitted = leave existing value unchanged.

  • notification_rules (Optional[NotificationRuleList], default: None ) –

    Replaces the entire notification rule list when present; full-replace, not merge. Omitted = leave existing rules unchanged. An empty list clears all rules (the alert keeps evaluating; only notifications stop).

Raises:

Examples:

Raise an alert's thresholds The following example replaces only the condition of an alert's rule; the query, the evaluation cadence and the notification rules are left unchanged. A supplied condition is replaced whole rather than merged, so every threshold to keep is sent again. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> client.update_alert(space_id='a1b2c3d4-5e6f-4a3b-8c9d-0e1f2a3b4c5d', alert_id='c3d4e5f67a8b4c9d8e0f1a2b3c4d5e6f', rule={'telemetryRule': {'condition': {'thresholdMode': 'FIELD_VALUE', 'thresholdField': 'error_count', 'comparator': 'GT', 'warningThreshold': 100.0, 'criticalThreshold': 400.0}}})
Source code in docs_src/capo_cloudwatchomni/_services/cloud_watch_omni.py
def update_alert(
    self,
    space_id: "capo_cloudwatchomni.types.space_id.SpaceId",
    alert_id: "capo_cloudwatchomni.types.alert_id.AlertId",
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    profile_id: Optional["capo_cloudwatchomni.types.profile_id.ProfileId"] = None,
    name: Optional[str] = None,
    description: Optional[str] = None,
    rule: Optional["capo_cloudwatchomni.types.rule.Rule"] = None,
    notifications_enabled: Optional[bool] = None,
    notification_rules: Optional[
        "capo_cloudwatchomni.types.notification_rule_list.NotificationRuleList"
    ] = None,
) -> "capo_cloudwatchomni.types.update_alert_output.UpdateAlertOutput":
    """Updates an existing alert. Only non-null fields overwrite existing values.

    Args:
        space_id: The unique ID of the space.
        alert_id: The alert to update.
        profile_id: The ID of the access profile associated with the alert.
        name: A new display name for the alert. Omit to leave the name unchanged (apply-if-present / PATCH). Same constraints as CreateAlert.name; the name is not the alert's identity, so a rename never changes the alertId.
        description: A new description of the alert. Omit to leave unchanged.
        rule: The rule that defines how the alert is evaluated. Omit to leave unchanged. Each sub-block is replaced whole when present: {@code query}, {@code condition}, {@code evaluation} and {@code noData} are applied only when supplied, and within a supplied block an omitted optional member is cleared to unset (null/absent) rather than preserved from the stored alert or defaulted. See {@link AlertCondition} and {@link AlertEvaluation}.
        notifications_enabled: Whether actions (notifications) are enabled for this alert. Omitted = leave existing value unchanged.
        notification_rules: Replaces the entire notification rule list when present; full-replace, not merge. Omitted = leave existing rules unchanged. An empty list clears all rules (the alert keeps evaluating; only notifications stop).

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.conflict_exception.ConflictException: The operation could not be completed because of a conflict with the current state of the resource.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Raise an alert's thresholds
        The following example replaces only the condition of an alert's rule; the query, the evaluation cadence and the notification rules are left unchanged. A supplied condition is replaced whole rather than merged, so every threshold to keep is sent again. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.update_alert(space_id='a1b2c3d4-5e6f-4a3b-8c9d-0e1f2a3b4c5d', alert_id='c3d4e5f67a8b4c9d8e0f1a2b3c4d5e6f', rule={'telemetryRule': {'condition': {'thresholdMode': 'FIELD_VALUE', 'thresholdField': 'error_count', 'comparator': 'GT', 'warningThreshold': 100.0, 'criticalThreshold': 400.0}}})
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatchomni.types.update_alert_input.UpdateAlertInput]",
    ) -> OperationResponse[
        "capo_cloudwatchomni.types.update_alert_output.UpdateAlertOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.update_alert

        output, http_response = (
            capo_cloudwatchomni._operations.cloud_watch_omni_frontend.update_alert.update_alert(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateAlert")
    )
    input_: capo_cloudwatchomni.types.update_alert_input.UpdateAlertInput = {
        "space_id": space_id,
        "alert_id": alert_id,
    }
    if profile_id is not None:
        input_["profile_id"] = profile_id
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if rule is not None:
        input_["rule"] = rule
    if notifications_enabled is not None:
        input_["notifications_enabled"] = notifications_enabled
    if notification_rules is not None:
        input_["notification_rules"] = notification_rules

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