Skip to content

update_anomaly_subscription async

update_anomaly_subscription(
    subscription_arn: GenericString,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    threshold: Optional[NullableNonNegativeDouble] = None,
    frequency: Optional[AnomalySubscriptionFrequency] = None,
    monitor_arn_list: Optional[MonitorArnList] = None,
    subscribers: Optional[Subscribers] = None,
    subscription_name: Optional[GenericString] = None,
    threshold_expression: Optional[Expression] = None,
) -> UpdateAnomalySubscriptionResponse

Updates an existing cost anomaly subscription. Specify the fields that you want to update. Omitted fields are unchanged.

The JSON below describes the generic construct for each type. See Request Parameters for possible values as they apply to AnomalySubscription.

Parameters:

  • subscription_arn (GenericString) –

    A cost anomaly subscription Amazon Resource Name (ARN).

  • threshold (Optional[NullableNonNegativeDouble], default: None ) –

    (deprecated)

    The update to the threshold value for receiving notifications.

    This field has been deprecated. To update a threshold, use ThresholdExpression. Continued use of Threshold will be treated as shorthand syntax for a ThresholdExpression.

    You can specify either Threshold or ThresholdExpression, but not both.

  • frequency (Optional[AnomalySubscriptionFrequency], default: None ) –

    The update to the frequency value that subscribers receive notifications.

  • monitor_arn_list (Optional[MonitorArnList], default: None ) –

    A list of cost anomaly monitor ARNs.

  • subscribers (Optional[Subscribers], default: None ) –

    The update to the subscriber list.

  • subscription_name (Optional[GenericString], default: None ) –

    The new name of the subscription.

  • threshold_expression (Optional[Expression], default: None ) –

    The update to the Expression object used to specify the anomalies that you want to generate alerts for. This supports dimensions and nested expressions. The supported dimensions are ANOMALY_TOTAL_IMPACT_ABSOLUTE and ANOMALY_TOTAL_IMPACT_PERCENTAGE, corresponding to an anomaly’s TotalImpact and TotalImpactPercentage, respectively (see Impact for more details). The supported nested expression types are AND and OR. The match option GREATER_THAN_OR_EQUAL is required. Values must be numbers between 0 and 10,000,000,000 in string format.

    You can specify either Threshold or ThresholdExpression, but not both.

    The following are examples of valid ThresholdExpressions:

    • Absolute threshold: { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }

    • Percentage threshold: { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }

    • AND two thresholds together: { "And": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }

    • OR two thresholds together: { "Or": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def update_anomaly_subscription(
    self,
    subscription_arn: "capo_cost_explorer.types.generic_string.GenericString",
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    threshold: Optional[
        "capo_cost_explorer.types.nullable_non_negative_double.NullableNonNegativeDouble"
    ] = None,
    frequency: Optional[
        "capo_cost_explorer.types.anomaly_subscription_frequency.AnomalySubscriptionFrequency"
    ] = None,
    monitor_arn_list: Optional[
        "capo_cost_explorer.types.monitor_arn_list.MonitorArnList"
    ] = None,
    subscribers: Optional[
        "capo_cost_explorer.types.subscribers.Subscribers"
    ] = None,
    subscription_name: Optional[
        "capo_cost_explorer.types.generic_string.GenericString"
    ] = None,
    threshold_expression: Optional[
        "capo_cost_explorer.types.expression.Expression"
    ] = None,
) -> "capo_cost_explorer.types.update_anomaly_subscription_response.UpdateAnomalySubscriptionResponse":
    """<p>Updates an existing cost anomaly subscription. Specify the fields that you want to update. Omitted fields are unchanged.</p> <note> <p>The JSON below describes the generic construct for each type. See <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_UpdateAnomalySubscription.html#API_UpdateAnomalySubscription_RequestParameters">Request Parameters</a> for possible values as they apply to <code>AnomalySubscription</code>.</p> </note>

    Args:
        subscription_arn: <p>A cost anomaly subscription Amazon Resource Name (ARN). </p>
        threshold: <p>(deprecated)</p> <p>The update to the threshold value for receiving notifications. </p> <p>This field has been deprecated. To update a threshold, use ThresholdExpression. Continued use of Threshold will be treated as shorthand syntax for a ThresholdExpression.</p> <p>You can specify either Threshold or ThresholdExpression, but not both.</p>
        frequency: <p>The update to the frequency value that subscribers receive notifications. </p>
        monitor_arn_list: <p>A list of cost anomaly monitor ARNs. </p>
        subscribers: <p>The update to the subscriber list. </p>
        subscription_name: <p>The new name of the subscription. </p>
        threshold_expression: <p>The update to the <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html">Expression</a> object used to specify the anomalies that you want to generate alerts for. This supports dimensions and nested expressions. The supported dimensions are <code>ANOMALY_TOTAL_IMPACT_ABSOLUTE</code> and <code>ANOMALY_TOTAL_IMPACT_PERCENTAGE</code>, corresponding to an anomaly’s TotalImpact and TotalImpactPercentage, respectively (see <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Impact.html">Impact</a> for more details). The supported nested expression types are <code>AND</code> and <code>OR</code>. The match option <code>GREATER_THAN_OR_EQUAL</code> is required. Values must be numbers between 0 and 10,000,000,000 in string format.</p> <p>You can specify either Threshold or ThresholdExpression, but not both.</p> <p>The following are examples of valid ThresholdExpressions:</p> <ul> <li> <p>Absolute threshold: <code>{ "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }</code> </p> </li> <li> <p>Percentage threshold: <code>{ "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }</code> </p> </li> <li> <p> <code>AND</code> two thresholds together: <code>{ "And": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }</code> </p> </li> <li> <p> <code>OR</code> two thresholds together: <code>{ "Or": [ { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } }, { "Dimensions": { "Key": "ANOMALY_TOTAL_IMPACT_PERCENTAGE", "MatchOptions": [ "GREATER_THAN_OR_EQUAL" ], "Values": [ "100" ] } } ] }</code> </p> </li> </ul>

    Raises:
        capo_cost_explorer.errors.limit_exceeded_exception.LimitExceededException: <p>You made too many calls in a short period of time. Try again later.</p>
        capo_cost_explorer.errors.unknown_monitor_exception.UnknownMonitorException: <p>The cost anomaly monitor does not exist for the account. </p>
        capo_cost_explorer.errors.unknown_subscription_exception.UnknownSubscriptionException: <p>The cost anomaly subscription does not exist for the account. </p>
        capo_cost_explorer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cost_explorer.types.update_anomaly_subscription_request.UpdateAnomalySubscriptionRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.update_anomaly_subscription_response.UpdateAnomalySubscriptionResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.update_anomaly_subscription

        (
            output,
            http_response,
        ) = await capo_cost_explorer._operations.aws_insights_index_service.update_anomaly_subscription.async_update_anomaly_subscription(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateAnomalySubscription")
    )
    input_: capo_cost_explorer.types.update_anomaly_subscription_request.UpdateAnomalySubscriptionRequest = {
        "subscription_arn": subscription_arn
    }
    if threshold is not None:
        input_["threshold"] = threshold
    if frequency is not None:
        input_["frequency"] = frequency
    if monitor_arn_list is not None:
        input_["monitor_arn_list"] = monitor_arn_list
    if subscribers is not None:
        input_["subscribers"] = subscribers
    if subscription_name is not None:
        input_["subscription_name"] = subscription_name
    if threshold_expression is not None:
        input_["threshold_expression"] = threshold_expression

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output