getCostEstimate method

Future<GetCostEstimateResult> getCostEstimate({
  1. required DateTime endTime,
  2. required String resourceName,
  3. required DateTime startTime,
})

Retrieves information about the cost estimate for a specified resource. A cost estimate will not generate for a resource that has been deleted.

May throw AccessDeniedException. May throw InvalidInputException. May throw NotFoundException. May throw RegionSetupInProgressException. May throw ServiceException. May throw UnauthenticatedException.

Parameter endTime : The cost estimate end time.

Constraints:

  • Specified in Coordinated Universal Time (UTC).
  • Specified in the Unix time format.

    For example, if you want to use an end time of October 1, 2018, at 9 PM UTC, specify 1538427600 as the end time.

You can convert a human-friendly time to Unix time format using a converter like Epoch converter.

Parameter resourceName : The resource name.

Parameter startTime : The cost estimate start time.

Constraints:

  • Specified in Coordinated Universal Time (UTC).
  • Specified in the Unix time format.

    For example, if you want to use a start time of October 1, 2018, at 8 PM UTC, specify 1538424000 as the start time.

You can convert a human-friendly time to Unix time format using a converter like Epoch converter.

Implementation

Future<GetCostEstimateResult> getCostEstimate({
  required DateTime endTime,
  required String resourceName,
  required DateTime startTime,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.GetCostEstimate'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'endTime': unixTimestampToJson(endTime),
      'resourceName': resourceName,
      'startTime': unixTimestampToJson(startTime),
    },
  );

  return GetCostEstimateResult.fromJson(jsonResponse.body);
}