getReservationPurchaseRecommendation method

Future<GetReservationPurchaseRecommendationResponse> getReservationPurchaseRecommendation({
  1. required String service,
  2. String? accountId,
  3. AccountScope? accountScope,
  4. LookbackPeriodInDays? lookbackPeriodInDays,
  5. String? nextPageToken,
  6. int? pageSize,
  7. PaymentOption? paymentOption,
  8. ServiceSpecification? serviceSpecification,
  9. TermInYears? termInYears,
})

Gets recommendations for which reservations to purchase. These recommendations could help you reduce your costs. Reservations provide a discounted hourly rate (up to 75%) compared to On-Demand pricing.

AWS generates your recommendations by identifying your On-Demand usage during a specific time period and collecting your usage into categories that are eligible for a reservation. After AWS has these categories, it simulates every combination of reservations in each category of usage to identify the best number of each type of RI to purchase to maximize your estimated savings.

For example, AWS automatically aggregates your Amazon EC2 Linux, shared tenancy, and c4 family usage in the US West (Oregon) Region and recommends that you buy size-flexible regional reservations to apply to the c4 family usage. AWS recommends the smallest size instance in an instance family. This makes it easier to purchase a size-flexible RI. AWS also shows the equal number of normalized units so that you can purchase any instance size that you want. For this example, your RI recommendation would be for c4.large because that is the smallest size instance in the c4 instance family.

May throw LimitExceededException. May throw DataUnavailableException. May throw InvalidNextTokenException.

Parameter service : The specific service that you want recommendations for.

Parameter accountId : The account ID that is associated with the recommendation.

Parameter accountScope : The account scope that you want your recommendations for. Amazon Web Services calculates recommendations including the management account and member accounts if the value is set to PAYER. If the value is LINKED, recommendations are calculated for individual member accounts only.

Parameter lookbackPeriodInDays : The number of previous days that you want AWS to consider when it calculates your recommendations.

Parameter nextPageToken : The pagination token that indicates the next set of results that you want to retrieve.

Parameter pageSize : The number of recommendations that you want returned in a single response object.

Parameter paymentOption : The reservation purchase option that you want recommendations for.

Parameter serviceSpecification : The hardware specifications for the service instances that you want recommendations for, such as standard or convertible Amazon EC2 instances.

Parameter termInYears : The reservation term that you want recommendations for.

Implementation

Future<GetReservationPurchaseRecommendationResponse>
    getReservationPurchaseRecommendation({
  required String service,
  String? accountId,
  AccountScope? accountScope,
  LookbackPeriodInDays? lookbackPeriodInDays,
  String? nextPageToken,
  int? pageSize,
  PaymentOption? paymentOption,
  ServiceSpecification? serviceSpecification,
  TermInYears? termInYears,
}) async {
  ArgumentError.checkNotNull(service, 'service');
  _s.validateStringLength(
    'service',
    service,
    0,
    1024,
    isRequired: true,
  );
  _s.validateStringLength(
    'accountId',
    accountId,
    0,
    1024,
  );
  _s.validateStringLength(
    'nextPageToken',
    nextPageToken,
    0,
    8192,
  );
  _s.validateNumRange(
    'pageSize',
    pageSize,
    0,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AWSInsightsIndexService.GetReservationPurchaseRecommendation'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Service': service,
      if (accountId != null) 'AccountId': accountId,
      if (accountScope != null) 'AccountScope': accountScope.toValue(),
      if (lookbackPeriodInDays != null)
        'LookbackPeriodInDays': lookbackPeriodInDays.toValue(),
      if (nextPageToken != null) 'NextPageToken': nextPageToken,
      if (pageSize != null) 'PageSize': pageSize,
      if (paymentOption != null) 'PaymentOption': paymentOption.toValue(),
      if (serviceSpecification != null)
        'ServiceSpecification': serviceSpecification,
      if (termInYears != null) 'TermInYears': termInYears.toValue(),
    },
  );

  return GetReservationPurchaseRecommendationResponse.fromJson(
      jsonResponse.body);
}