getBillingPreferences method

Future<GetBillingPreferencesResponse> getBillingPreferences({
  1. required List<BillingFeature> features,
  2. List<BillingFeatureFilter>? filters,
  3. int? maxResults,
  4. String? nextToken,
})

Retrieves billing preferences for the specified feature. Each feature controls a distinct billing capability: which accounts can share Reserved Instances or credits, whether billing alerts are enabled, the historical record of sharing changes, and per-credit options.

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

Parameter features : The feature to retrieve. Specify exactly one value. Valid values: BILLING_ALERTS, RI_SHARING, RI_SHARING_HISTORY, CREDIT_SHARING, CREDIT_SHARING_HISTORY, CREDIT_LEVEL_SHARING, CREDIT_PREFERENCE_OPTIONS.

Parameter filters : Filters to narrow results. Specify exactly one filter when supplied. The supported filter name is PREFERENCE_KEY, which accepts 1 to 10 values to match preference keys.

Parameter maxResults : The maximum number of records to return per page. Range: 1 to 50. Default: 50.

Parameter nextToken : Pagination token from a previous response. Pass the value returned in nextToken to retrieve the next page of results.

Implementation

Future<GetBillingPreferencesResponse> getBillingPreferences({
  required List<BillingFeature> features,
  List<BillingFeatureFilter>? filters,
  int? maxResults,
  String? nextToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSBilling.GetBillingPreferences'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'features': features.map((e) => e.value).toList(),
      if (filters != null) 'filters': filters,
      if (maxResults != null) 'maxResults': maxResults,
      if (nextToken != null) 'nextToken': nextToken,
    },
  );

  return GetBillingPreferencesResponse.fromJson(jsonResponse.body);
}