getProducts method

Future<GetProductsResponse> getProducts({
  1. List<Filter>? filters,
  2. String? formatVersion,
  3. int? maxResults,
  4. String? nextToken,
  5. String? serviceCode,
})

Returns a list of all products that match the filter criteria.

May throw InternalErrorException. May throw InvalidParameterException. May throw NotFoundException. May throw InvalidNextTokenException. May throw ExpiredNextTokenException.

Parameter filters : The list of filters that limit the returned products. only products that match all filters are returned.

Parameter formatVersion : The format version that you want the response to be in.

Valid values are: aws_v1

Parameter maxResults : The maximum number of results to return in the response.

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

Parameter serviceCode : The code for the service whose products you want to retrieve.

Implementation

Future<GetProductsResponse> getProducts({
  List<Filter>? filters,
  String? formatVersion,
  int? maxResults,
  String? nextToken,
  String? serviceCode,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSPriceListService.GetProducts'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (filters != null) 'Filters': filters,
      if (formatVersion != null) 'FormatVersion': formatVersion,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
      if (serviceCode != null) 'ServiceCode': serviceCode,
    },
  );

  return GetProductsResponse.fromJson(jsonResponse.body);
}