createSavingsPlan method
Creates a Savings Plan.
May throw ResourceNotFoundException. May throw ValidationException. May throw InternalServerException. May throw ServiceQuotaExceededException.
Parameter commitment
:
The hourly commitment, in USD. This is a value between 0.001 and 1
million. You cannot specify more than three digits after the decimal
point.
Parameter savingsPlanOfferingId
:
The ID of the offering.
Parameter clientToken
:
Unique, case-sensitive identifier that you provide to ensure the
idempotency of the request.
Parameter purchaseTime
:
The time at which to purchase 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
supported only 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 {
ArgumentError.checkNotNull(commitment, 'commitment');
ArgumentError.checkNotNull(savingsPlanOfferingId, 'savingsPlanOfferingId');
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);
}