listInsights method

Future<ListInsightsResponse> listInsights({
  1. required InsightEntity entity,
  2. int? maxResults,
  3. String? nextToken,
  4. InsightSortOrder? sortOrder,
  5. InsightTimeRange? timeRange,
})

Lists insights for an Amazon OpenSearch Service domain or Amazon Web Services account. Returns a paginated list of insights based on the specified entity, filters, time range, and sort order.

May throw BaseException. May throw DisabledOperationException. May throw InternalException. May throw LimitExceededException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter entity : The entity for which to list insights. Specifies the type and value of the entity, such as a domain name or Amazon Web Services account ID.

Parameter maxResults : An optional parameter that specifies the maximum number of results to return. You can use NextToken to get the next page of results. Valid values are 1 to 500.

Parameter nextToken : If your initial ListInsights operation returns a NextToken, include the returned NextToken in subsequent ListInsights operations to retrieve the next page of results.

Parameter sortOrder : The sort order for the results. Possible values are ASC (ascending) and DESC (descending).

Parameter timeRange : The time range for filtering insights, specified as epoch millisecond timestamps.

Implementation

Future<ListInsightsResponse> listInsights({
  required InsightEntity entity,
  int? maxResults,
  String? nextToken,
  InsightSortOrder? sortOrder,
  InsightTimeRange? timeRange,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    500,
  );
  final $payload = <String, dynamic>{
    'Entity': entity,
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
    if (sortOrder != null) 'SortOrder': sortOrder.value,
    if (timeRange != null) 'TimeRange': timeRange,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/2021-01-01/opensearch/insights',
    exceptionFnMap: _exceptionFns,
  );
  return ListInsightsResponse.fromJson(response);
}