listForecasts method

Future<ListForecastsResponse> listForecasts({
  1. List<Filter>? filters,
  2. int? maxResults,
  3. String? nextToken,
})

Returns a list of forecasts created using the CreateForecast operation. For each forecast, this operation returns a summary of its properties, including its Amazon Resource Name (ARN). To retrieve the complete set of properties, specify the ARN with the DescribeForecast operation. You can filter the list using an array of Filter objects.

May throw InvalidNextTokenException. May throw InvalidInputException.

Parameter filters : An array of filters. For each filter, you provide a condition and a match statement. The condition is either IS or IS_NOT, which specifies whether to include or exclude the forecasts that match the statement from the list, respectively. The match statement consists of a key and a value.

Filter properties

  • Condition - The condition to apply. Valid values are IS and IS_NOT. To include the forecasts that match the statement, specify IS. To exclude matching forecasts, specify IS_NOT.
  • Key - The name of the parameter to filter on. Valid values are DatasetGroupArn, PredictorArn, and Status.
  • Value - The value to match.
For example, to list all forecasts whose status is not ACTIVE, you would specify:

"Filters": { "Condition": "IS_NOT", "Key": "Status", "Value": "ACTIVE" }

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

Parameter nextToken : If the result of the previous request was truncated, the response includes a NextToken. To retrieve the next set of results, use the token in the next request. Tokens expire after 24 hours.

Implementation

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

  return ListForecastsResponse.fromJson(jsonResponse.body);
}