getEstimatedCarbonEmissions method

Future<GetEstimatedCarbonEmissionsResponse> getEstimatedCarbonEmissions({
  1. required TimePeriod timePeriod,
  2. List<EmissionsType>? emissionsTypes,
  3. FilterExpression? filterBy,
  4. TimeGranularity? granularity,
  5. GranularityConfiguration? granularityConfiguration,
  6. List<Dimension>? groupBy,
  7. int? maxResults,
  8. String? nextToken,
})

Returns estimated carbon emission values based on customer grouping and filtering parameters. We recommend using pagination to ensure that the operation returns quickly and successfully.

May throw AccessDeniedException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException.

Parameter timePeriod : The date range for fetching estimated carbon emissions. The range must include the start date of a month for that month's data to be included in the response.

Parameter emissionsTypes : The emission types to include in the results. If absent, returns TOTAL_LBM_CARBON_EMISSIONS and TOTAL_MBM_CARBON_EMISSIONS emissions types.

Parameter filterBy : The criteria for filtering estimated carbon emissions. To determine which dimensions are available to be filtered by, you can first call GetEstimatedCarbonEmissionsDimensionValues

Parameter granularity : The time granularity for the results. If absent, uses MONTHLY time granularity. The smallest supported granularity for carbon emissions is MONTHLY.

If requesting partial time periods, data will be returned based on the smallest supported granularity. For example, requesting 2025-04-01T00:00:00Z to 2026-04-01T00:00:00Z with YEARLY_CALENDAR granularity will return the last 9 months for 2025 and the first 3 months of 2026.

Parameter granularityConfiguration : Configuration for fiscal year calculations when using YEARLY_FISCAL or QUARTERLY_FISCAL granularity.

Parameter groupBy : The dimensions available for grouping estimated carbon emissions.

Parameter maxResults : The maximum number of results to return in a single call. Default is 1000.

Parameter nextToken : The pagination token specifying which page of results to return in the response. If no token is provided, the default page is the first page.

Implementation

Future<GetEstimatedCarbonEmissionsResponse> getEstimatedCarbonEmissions({
  required TimePeriod timePeriod,
  List<EmissionsType>? emissionsTypes,
  FilterExpression? filterBy,
  TimeGranularity? granularity,
  GranularityConfiguration? granularityConfiguration,
  List<Dimension>? groupBy,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    5000,
  );
  final $payload = <String, dynamic>{
    'TimePeriod': timePeriod,
    if (emissionsTypes != null)
      'EmissionsTypes': emissionsTypes.map((e) => e.value).toList(),
    if (filterBy != null) 'FilterBy': filterBy,
    if (granularity != null) 'Granularity': granularity.value,
    if (granularityConfiguration != null)
      'GranularityConfiguration': granularityConfiguration,
    if (groupBy != null) 'GroupBy': groupBy.map((e) => e.value).toList(),
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/estimated-carbon-emissions',
    exceptionFnMap: _exceptionFns,
  );
  return GetEstimatedCarbonEmissionsResponse.fromJson(response);
}