createSavingsPlan method
Creates a Savings Plan.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ValidationException.
Parameter commitment :
The hourly commitment, in the same currency of the
savingsPlanOfferingId. This is a value between 0.001 and 1
million. You cannot specify more than five digits after the decimal point.
Parameter savingsPlanOfferingId :
The ID of the offering.
Parameter clientToken :
A unique, case-sensitive identifier that you provide to ensure the
idempotency of the request.
Parameter purchaseTime :
The purchase time of the Savings Plan in UTC format
(YYYY-MM-DDTHH:MM:SSZ).
Parameter tags :
One or more tags.
Parameter upfrontPaymentAmount :
The up-front payment amount. This is a whole number between 50 and 99
percent of the total value of the Savings Plan. This parameter is only
supported if the payment option is Partial Upfront.
Implementation
Future<CreateSavingsPlanResponse> createSavingsPlan({
required String commitment,
required String savingsPlanOfferingId,
String? clientToken,
DateTime? purchaseTime,
Map<String, String>? tags,
String? upfrontPaymentAmount,
}) async {
final $payload = <String, dynamic>{
'commitment': commitment,
'savingsPlanOfferingId': savingsPlanOfferingId,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (purchaseTime != null)
'purchaseTime': unixTimestampToJson(purchaseTime),
if (tags != null) 'tags': tags,
if (upfrontPaymentAmount != null)
'upfrontPaymentAmount': upfrontPaymentAmount,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/CreateSavingsPlan',
exceptionFnMap: _exceptionFns,
);
return CreateSavingsPlanResponse.fromJson(response);
}