CostExplorer class
You can use the Cost Explorer API to programmatically query your cost and usage data. You can query for aggregated data such as total monthly costs or total daily usage. You can also query for granular data. This might include the number of daily write operations for Amazon DynamoDB database tables in your production environment.
Service Endpoint
The Cost Explorer API provides the following endpoint:
-
https://ce.us-east-1.amazonaws.com
Constructors
- CostExplorer({required String region, AwsClientCredentials? credentials, AwsClientCredentialsProvider? credentialsProvider, Client? client, String? endpointUrl})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Closes the internal HTTP client if none was provided at creation. If a client was passed as a constructor argument, this becomes a noop.
-
createAnomalyMonitor(
{required AnomalyMonitor anomalyMonitor, List< ResourceTag> ? resourceTags}) → Future<CreateAnomalyMonitorResponse> - Creates a new cost anomaly detection monitor with the requested type and monitor specification.
-
createAnomalySubscription(
{required AnomalySubscription anomalySubscription, List< ResourceTag> ? resourceTags}) → Future<CreateAnomalySubscriptionResponse> - Adds an alert subscription to a cost anomaly detection monitor. You can use each subscription to define subscribers with email or SNS notifications. Email subscribers can set an absolute or percentage threshold and a time frequency for receiving notifications.
-
createCostCategoryDefinition(
{required String name, required CostCategoryRuleVersion ruleVersion, required List< CostCategoryRule> rules, String? defaultValue, String? effectiveStart, List<ResourceTag> ? resourceTags, List<CostCategorySplitChargeRule> ? splitChargeRules}) → Future<CreateCostCategoryDefinitionResponse> - Creates a new cost category with the requested name and rules.
-
deleteAnomalyMonitor(
{required String monitorArn}) → Future< void> - Deletes a cost anomaly monitor.
-
deleteAnomalySubscription(
{required String subscriptionArn}) → Future< void> - Deletes a cost anomaly subscription.
-
deleteCostCategoryDefinition(
{required String costCategoryArn}) → Future< DeleteCostCategoryDefinitionResponse> - Deletes a cost category. Expenses from this month going forward will no longer be categorized with this cost category.
-
describeCostCategoryDefinition(
{required String costCategoryArn, String? effectiveOn}) → Future< DescribeCostCategoryDefinitionResponse> - Returns the name, Amazon Resource Name (ARN), rules, definition, and effective dates of a cost category that's defined in the account.
-
getAnomalies(
{required AnomalyDateInterval dateInterval, AnomalyFeedbackType? feedback, int? maxResults, String? monitorArn, String? nextPageToken, TotalImpactFilter? totalImpact}) → Future< GetAnomaliesResponse> -
Retrieves all of the cost anomalies detected on your account during the
time period that's specified by the
DateIntervalobject. Anomalies are available for up to 90 days. -
getAnomalyMonitors(
{int? maxResults, List< String> ? monitorArnList, String? nextPageToken}) → Future<GetAnomalyMonitorsResponse> - Retrieves the cost anomaly monitor definitions for your account. You can filter using a list of cost anomaly monitor Amazon Resource Names (ARNs).
-
getAnomalySubscriptions(
{int? maxResults, String? monitorArn, String? nextPageToken, List< String> ? subscriptionArnList}) → Future<GetAnomalySubscriptionsResponse> - Retrieves the cost anomaly subscription objects for your account. You can filter using a list of cost anomaly monitor Amazon Resource Names (ARNs).
-
getApproximateUsageRecords(
{required ApproximationDimension approximationDimension, required Granularity granularity, List< String> ? services}) → Future<GetApproximateUsageRecordsResponse> - Retrieves estimated usage records for hourly granularity or resource-level data at daily granularity.
-
getCommitmentPurchaseAnalysis(
{required String analysisId}) → Future< GetCommitmentPurchaseAnalysisResponse> -
Retrieves a commitment purchase analysis result based on the
AnalysisId. -
getCostAndUsage(
{required Granularity granularity, required List< String> metrics, required DateInterval timePeriod, String? billingViewArn, Expression? filter, List<GroupDefinition> ? groupBy, String? nextPageToken}) → Future<GetCostAndUsageResponse> -
Retrieves cost and usage metrics for your account. You can specify which
cost and usage-related metric that you want the request to return. For
example, you can specify
BlendedCostsorUsageQuantity. You can also filter and group your data by various dimensions, such asSERVICEorAZ, in a specific time range. For a complete list of valid dimensions, see the GetDimensionValues operation. Management account in an organization in Organizations have access to all member accounts. -
getCostAndUsageComparisons(
{required DateInterval baselineTimePeriod, required DateInterval comparisonTimePeriod, required String metricForComparison, String? billingViewArn, Expression? filter, List< GroupDefinition> ? groupBy, int? maxResults, String? nextPageToken}) → Future<GetCostAndUsageComparisonsResponse> - Retrieves cost and usage comparisons for your account between two periods within the last 13 months. If you have enabled multi-year data at monthly granularity, you can go back up to 38 months.
-
getCostAndUsageWithResources(
{required Expression filter, required Granularity granularity, required DateInterval timePeriod, String? billingViewArn, List< GroupDefinition> ? groupBy, List<String> ? metrics, String? nextPageToken}) → Future<GetCostAndUsageWithResourcesResponse> -
Retrieves cost and usage metrics with resources for your account. You can
specify which cost and usage-related metric, such as
BlendedCostsorUsageQuantity, that you want the request to return. You can also filter and group your data by various dimensions, such asSERVICEorAZ, in a specific time range. For a complete list of valid dimensions, see the GetDimensionValues operation. Management account in an organization in Organizations have access to all member accounts. -
getCostCategories(
{required DateInterval timePeriod, String? billingViewArn, String? costCategoryName, Expression? filter, int? maxResults, String? nextPageToken, String? searchString, List< SortDefinition> ? sortBy}) → Future<GetCostCategoriesResponse> - Retrieves an array of cost category names and values incurred cost.
-
getCostComparisonDrivers(
{required DateInterval baselineTimePeriod, required DateInterval comparisonTimePeriod, required String metricForComparison, String? billingViewArn, Expression? filter, List< GroupDefinition> ? groupBy, int? maxResults, String? nextPageToken}) → Future<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.
-
getCostForecast(
{required Granularity granularity, required Metric metric, required DateInterval timePeriod, String? billingViewArn, Expression? filter, int? predictionIntervalLevel}) → Future< GetCostForecastResponse> - Retrieves a forecast for how much Amazon Web Services predicts that you will spend over the forecast time period that you select, based on your past costs.
-
getDimensionValues(
{required Dimension dimension, required DateInterval timePeriod, String? billingViewArn, Context? context, Expression? filter, int? maxResults, String? nextPageToken, String? searchString, List< SortDefinition> ? sortBy}) → Future<GetDimensionValuesResponse> - Retrieves all available filter values for a specified filter over a period of time. You can search the dimension values for an arbitrary string.
-
getReservationCoverage(
{required DateInterval timePeriod, Expression? filter, Granularity? granularity, List< GroupDefinition> ? groupBy, int? maxResults, List<String> ? metrics, String? nextPageToken, SortDefinition? sortBy}) → Future<GetReservationCoverageResponse> - Retrieves the reservation coverage for your account, which you can use to see how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or Amazon Redshift usage is covered by a reservation. An organization's management account can see the coverage of the associated member accounts. This supports dimensions, cost categories, and nested expressions. For any time period, you can filter data about reservation usage by the following dimensions:
-
getReservationPurchaseRecommendation(
{required String service, String? accountId, AccountScope? accountScope, Expression? filter, LookbackPeriodInDays? lookbackPeriodInDays, String? nextPageToken, int? pageSize, PaymentOption? paymentOption, ServiceSpecification? serviceSpecification, TermInYears? termInYears}) → Future< GetReservationPurchaseRecommendationResponse> - Gets recommendations for reservation purchases. These recommendations might help you to reduce your costs. Reservations provide a discounted hourly rate (up to 75%) compared to On-Demand pricing.
-
getReservationUtilization(
{required DateInterval timePeriod, Expression? filter, Granularity? granularity, List< GroupDefinition> ? groupBy, int? maxResults, String? nextPageToken, SortDefinition? sortBy}) → Future<GetReservationUtilizationResponse> -
Retrieves the reservation utilization for your account. Management account
in an organization have access to member accounts. You can filter data by
dimensions in a time period. You can use
GetDimensionValuesto determine the possible dimension values. Currently, you can group only bySUBSCRIPTION_ID. -
getRightsizingRecommendation(
{required String service, RightsizingRecommendationConfiguration? configuration, Expression? filter, String? nextPageToken, int? pageSize}) → Future< GetRightsizingRecommendationResponse> - Creates recommendations that help you save cost by identifying idle and underutilized Amazon EC2 instances.
-
getSavingsPlanPurchaseRecommendationDetails(
{required String recommendationDetailId}) → Future< GetSavingsPlanPurchaseRecommendationDetailsResponse> - Retrieves the details for a Savings Plan recommendation. These details include the hourly data-points that construct the cost, coverage, and utilization charts.
-
getSavingsPlansCoverage(
{required DateInterval timePeriod, Expression? filter, Granularity? granularity, List< GroupDefinition> ? groupBy, int? maxResults, List<String> ? metrics, String? nextToken, SortDefinition? sortBy}) → Future<GetSavingsPlansCoverageResponse> - Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by a Savings Plan. An organization’s management account can see the coverage of the associated member accounts. This supports dimensions, cost categories, and nested expressions. For any time period, you can filter data for Savings Plans usage with the following dimensions:
-
getSavingsPlansPurchaseRecommendation(
{required LookbackPeriodInDays lookbackPeriodInDays, required PaymentOption paymentOption, required SupportedSavingsPlansType savingsPlansType, required TermInYears termInYears, AccountScope? accountScope, Expression? filter, String? nextPageToken, int? pageSize}) → Future< GetSavingsPlansPurchaseRecommendationResponse> -
Retrieves the Savings Plans recommendations for your account. First use
StartSavingsPlansPurchaseRecommendationGenerationto generate a new set of recommendations, and then useGetSavingsPlansPurchaseRecommendationto retrieve them. -
getSavingsPlansUtilization(
{required DateInterval timePeriod, Expression? filter, Granularity? granularity, SortDefinition? sortBy}) → Future< GetSavingsPlansUtilizationResponse> -
Retrieves the Savings Plans utilization for your account across date
ranges with daily or monthly granularity. Management account in an
organization have access to member accounts. You can use
GetDimensionValuesinSAVINGS_PLANSto determine the possible dimension values. -
getSavingsPlansUtilizationDetails(
{required DateInterval timePeriod, List< SavingsPlansDataType> ? dataType, Expression? filter, int? maxResults, String? nextToken, SortDefinition? sortBy}) → Future<GetSavingsPlansUtilizationDetailsResponse> -
Retrieves attribute data along with aggregate utilization and savings data
for a given time period. This doesn't support granular or grouped data
(daily/monthly) in response. You can't retrieve data by dates in a single
response similar to
GetSavingsPlanUtilization, but you have the option to make multiple calls toGetSavingsPlanUtilizationDetailsby providing individual dates. You can useGetDimensionValuesinSAVINGS_PLANSto determine the possible dimension values. -
getTags(
{required DateInterval timePeriod, String? billingViewArn, Expression? filter, int? maxResults, String? nextPageToken, String? searchString, List< SortDefinition> ? sortBy, String? tagKey}) → Future<GetTagsResponse> - Queries for available tag keys and tag values for a specified period. You can search the tag values for an arbitrary string.
-
getUsageForecast(
{required Granularity granularity, required Metric metric, required DateInterval timePeriod, String? billingViewArn, Expression? filter, int? predictionIntervalLevel}) → Future< GetUsageForecastResponse> - Retrieves a forecast for how much Amazon Web Services predicts that you will use over the forecast time period that you select, based on your past usage.
-
listCommitmentPurchaseAnalyses(
{List< String> ? analysisIds, AnalysisStatus? analysisStatus, String? nextPageToken, int? pageSize}) → Future<ListCommitmentPurchaseAnalysesResponse> - Lists the commitment purchase analyses for your account.
-
listCostAllocationTagBackfillHistory(
{int? maxResults, String? nextToken}) → Future< ListCostAllocationTagBackfillHistoryResponse> - Retrieves a list of your historical cost allocation tag backfill requests.
-
listCostAllocationTags(
{int? maxResults, String? nextToken, CostAllocationTagStatus? status, List< String> ? tagKeys, CostAllocationTagType? type}) → Future<ListCostAllocationTagsResponse> - Get a list of cost allocation tags. All inputs in the API are optional and serve as filters. By default, all cost allocation tags are returned.
-
listCostCategoryDefinitions(
{String? effectiveOn, int? maxResults, String? nextToken, List< String> ? supportedResourceTypes}) → Future<ListCostCategoryDefinitionsResponse> -
Returns the name, Amazon Resource Name (ARN),
NumberOfRulesand effective dates of all cost categories defined in the account. You have the option to useEffectiveOnandSupportedResourceTypesto return a list of cost categories that were active on a specific date. If there is noEffectiveOnspecified, you’ll see cost categories that are effective on the current date. If cost category is still effective,EffectiveEndis omitted in the response.ListCostCategoryDefinitionssupports pagination. The request can have aMaxResultsrange up to 100. -
listCostCategoryResourceAssociations(
{String? costCategoryArn, int? maxResults, String? nextToken}) → Future< ListCostCategoryResourceAssociationsResponse> -
Returns resource associations of all cost categories defined in the
account. You have the option to use
CostCategoryArnto get the association for a specific cost category.ListCostCategoryResourceAssociationssupports pagination. The request can have aMaxResultsrange up to 100. -
listSavingsPlansPurchaseRecommendationGeneration(
{GenerationStatus? generationStatus, String? nextPageToken, int? pageSize, List< String> ? recommendationIds}) → Future<ListSavingsPlansPurchaseRecommendationGenerationResponse> - Retrieves a list of your historical recommendation generations within the past 30 days.
-
listTagsForResource(
{required String resourceArn}) → Future< ListTagsForResourceResponse> - Returns a list of resource tags associated with the resource specified by the Amazon Resource Name (ARN).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
provideAnomalyFeedback(
{required String anomalyId, required AnomalyFeedbackType feedback}) → Future< ProvideAnomalyFeedbackResponse> - Modifies the feedback property of a given cost anomaly.
-
startCommitmentPurchaseAnalysis(
{required CommitmentPurchaseAnalysisConfiguration commitmentPurchaseAnalysisConfiguration}) → Future< StartCommitmentPurchaseAnalysisResponse> - Specifies the parameters of a planned commitment purchase and starts the generation of the analysis. This enables you to estimate the cost, coverage, and utilization impact of your planned commitment purchases.
-
startCostAllocationTagBackfill(
{required String backfillFrom}) → Future< StartCostAllocationTagBackfillResponse> -
Request a cost allocation tag backfill. This will backfill the activation
status (either
activeorinactive) for all tag keys frompara:BackfillFromup to the time this request is made. -
startSavingsPlansPurchaseRecommendationGeneration(
) → Future< StartSavingsPlansPurchaseRecommendationGenerationResponse> - Requests a Savings Plans recommendation generation. This enables you to calculate a fresh set of Savings Plans recommendations that takes your latest usage data and current Savings Plans inventory into account. You can refresh Savings Plans recommendations up to three times daily for a consolidated billing family.
-
tagResource(
{required String resourceArn, required List< ResourceTag> resourceTags}) → Future<void> - An API operation for adding one or more tags (key-value pairs) to a resource.
-
toString(
) → String -
A string representation of this object.
inherited
-
untagResource(
{required String resourceArn, required List< String> resourceTagKeys}) → Future<void> - Removes one or more tags from a resource. Specify only tag keys in your request. Don't specify the value.
-
updateAnomalyMonitor(
{required String monitorArn, String? monitorName}) → Future< UpdateAnomalyMonitorResponse> - Updates an existing cost anomaly monitor. The changes made are applied going forward, and doesn't change anomalies detected in the past.
-
updateAnomalySubscription(
{required String subscriptionArn, AnomalySubscriptionFrequency? frequency, List< String> ? monitorArnList, List<Subscriber> ? subscribers, String? subscriptionName, double? threshold, Expression? thresholdExpression}) → Future<UpdateAnomalySubscriptionResponse> - Updates an existing cost anomaly subscription. Specify the fields that you want to update. Omitted fields are unchanged.
-
updateCostAllocationTagsStatus(
{required List< CostAllocationTagStatusEntry> costAllocationTagsStatus}) → Future<UpdateCostAllocationTagsStatusResponse> - Updates status for cost allocation tags in bulk, with maximum batch size of 20. If the tag status that's updated is the same as the existing tag status, the request doesn't fail. Instead, it doesn't have any effect on the tag status (for example, activating the active tag).
-
updateCostCategoryDefinition(
{required String costCategoryArn, required CostCategoryRuleVersion ruleVersion, required List< CostCategoryRule> rules, String? defaultValue, String? effectiveStart, List<CostCategorySplitChargeRule> ? splitChargeRules}) → Future<UpdateCostCategoryDefinitionResponse> - Updates an existing cost category. Changes made to the cost category rules will be used to categorize the current month’s expenses and future expenses. This won’t change categorization for the previous months.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited