Skip to content

get_cost_comparison_drivers async

get_cost_comparison_drivers(
    baseline_time_period: DateInterval,
    comparison_time_period: DateInterval,
    metric_for_comparison: MetricName,
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    billing_view_arn: Optional[BillingViewArn] = None,
    filter: Optional[Expression] = None,
    group_by: Optional[GroupDefinitions] = None,
    max_results: Optional[CostComparisonDriversMaxResults] = None,
    next_page_token: Optional[NextPageToken] = None,
) -> GetCostComparisonDriversResponse

Retrieves key factors driving cost changes between two time periods within the last 13 months, such as usage changes, discount changes, and commitment-based savings. If you have enabled multi-year data at monthly granularity, you can go back up to 38 months.

Parameters:

  • billing_view_arn (Optional[BillingViewArn], default: None ) –

    The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.

  • baseline_time_period (DateInterval) –

    The reference time period for comparison. This time period serves as the baseline against which other cost and usage data will be compared. The interval must start and end on the first day of a month, with a duration of exactly one month.

  • comparison_time_period (DateInterval) –

    The comparison time period for analysis. This time period's cost and usage data will be compared against the baseline time period. The interval must start and end on the first day of a month, with a duration of exactly one month.

  • metric_for_comparison (MetricName) –

    The cost and usage metric to compare. Valid values are AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity.

  • group_by (Optional[GroupDefinitions], default: None ) –

    You can group results using the attributes DIMENSION, TAG, and COST_CATEGORY. Note that SERVICE and USAGE_TYPE dimensions are automatically included in the cost comparison drivers analysis.

  • max_results (Optional[CostComparisonDriversMaxResults], default: None ) –

    The maximum number of results that are returned for the request.

  • next_page_token (Optional[NextPageToken], default: None ) –

    The token to retrieve the next set of paginated results.

Raises:

Source code in docs_src/capo_cost_explorer/_services/async_cost_explorer.py
async def get_cost_comparison_drivers(
    self,
    baseline_time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    comparison_time_period: "capo_cost_explorer.types.date_interval.DateInterval",
    metric_for_comparison: "capo_cost_explorer.types.metric_name.MetricName",
    *,
    config_overrides: Optional[AsyncCostExplorerClientConfig] = None,
    billing_view_arn: Optional[
        "capo_cost_explorer.types.billing_view_arn.BillingViewArn"
    ] = None,
    filter: Optional["capo_cost_explorer.types.expression.Expression"] = None,
    group_by: Optional[
        "capo_cost_explorer.types.group_definitions.GroupDefinitions"
    ] = None,
    max_results: Optional[
        "capo_cost_explorer.types.cost_comparison_drivers_max_results.CostComparisonDriversMaxResults"
    ] = None,
    next_page_token: Optional[
        "capo_cost_explorer.types.next_page_token.NextPageToken"
    ] = None,
) -> "capo_cost_explorer.types.get_cost_comparison_drivers_response.GetCostComparisonDriversResponse":
    """<p>Retrieves key factors driving cost changes between two time periods within the last 13 months, such as usage changes, discount changes, and commitment-based savings. If you have enabled multi-year data at monthly granularity, you can go back up to 38 months.</p>

    Args:
        billing_view_arn: <p>The Amazon Resource Name (ARN) that uniquely identifies a specific billing view. The ARN is used to specify which particular billing view you want to interact with or retrieve information from when making API calls related to Amazon Web Services Billing and Cost Management features. The BillingViewArn can be retrieved by calling the ListBillingViews API.</p>
        baseline_time_period: <p>The reference time period for comparison. This time period serves as the baseline against which other cost and usage data will be compared. The interval must start and end on the first day of a month, with a duration of exactly one month.</p>
        comparison_time_period: <p>The comparison time period for analysis. This time period's cost and usage data will be compared against the baseline time period. The interval must start and end on the first day of a month, with a duration of exactly one month.</p>
        metric_for_comparison: <p>The cost and usage metric to compare. Valid values are <code>AmortizedCost</code>, <code>BlendedCost</code>, <code>NetAmortizedCost</code>, <code>NetUnblendedCost</code>, <code>NormalizedUsageAmount</code>, <code>UnblendedCost</code>, and <code>UsageQuantity</code>.</p>
        group_by: <p>You can group results using the attributes <code>DIMENSION</code>, <code>TAG</code>, and <code>COST_CATEGORY</code>. Note that <code>SERVICE</code> and <code>USAGE_TYPE</code> dimensions are automatically included in the cost comparison drivers analysis.</p>
        max_results: <p>The maximum number of results that are returned for the request.</p>
        next_page_token: <p>The token to retrieve the next set of paginated results.</p>

    Raises:
        capo_cost_explorer.errors.billing_view_health_status_exception.BillingViewHealthStatusException: <p> The billing view status must be <code>HEALTHY</code> to perform this action. Try again when the status is <code>HEALTHY</code>. </p>
        capo_cost_explorer.errors.data_unavailable_exception.DataUnavailableException: <p>The requested data is unavailable.</p>
        capo_cost_explorer.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The pagination token is invalid. Try again without a pagination token.</p>
        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.resource_not_found_exception.ResourceNotFoundException: <p> The specified ARN in the request doesn't exist. </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.get_cost_comparison_drivers_request.GetCostComparisonDriversRequest]",
    ) -> AsyncOperationResponse[
        "capo_cost_explorer.types.get_cost_comparison_drivers_response.GetCostComparisonDriversResponse"
    ]:
        import capo_cost_explorer._operations.aws_insights_index_service.get_cost_comparison_drivers

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetCostComparisonDrivers")
    )
    input_: capo_cost_explorer.types.get_cost_comparison_drivers_request.GetCostComparisonDriversRequest = {
        "baseline_time_period": baseline_time_period,
        "comparison_time_period": comparison_time_period,
        "metric_for_comparison": metric_for_comparison,
    }
    if billing_view_arn is not None:
        input_["billing_view_arn"] = billing_view_arn
    if filter is not None:
        input_["filter"] = filter
    if group_by is not None:
        input_["group_by"] = group_by
    if max_results is not None:
        input_["max_results"] = max_results
    if next_page_token is not None:
        input_["next_page_token"] = next_page_token

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