getRecommendations method
Retrieves recommendations for the specified session. To avoid retrieving
the same recommendations in subsequent calls, use NotifyRecommendationsReceived.
This API supports long-polling behavior with the
waitTimeSeconds parameter. Short poll is the default behavior
and only returns recommendations already available. To perform a manual
query against an assistant, use QueryAssistant.
May throw AccessDeniedException.
May throw ResourceNotFoundException.
May throw ValidationException.
Parameter assistantId :
The identifier of the Wisdom assistant. Can be either the ID or the ARN.
URLs cannot contain the ARN.
Parameter sessionId :
The identifier of the session. Can be either the ID or the ARN. URLs
cannot contain the ARN.
Parameter maxResults :
The maximum number of results to return per page.
Parameter waitTimeSeconds :
The duration (in seconds) for which the call waits for a recommendation to
be made available before returning. If a recommendation is available, the
call returns sooner than WaitTimeSeconds. If no messages are
available and the wait time expires, the call returns successfully with an
empty list.
Implementation
Future<GetRecommendationsResponse> getRecommendations({
required String assistantId,
required String sessionId,
int? maxResults,
int? waitTimeSeconds,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
100,
);
_s.validateNumRange(
'waitTimeSeconds',
waitTimeSeconds,
0,
20,
);
final $query = <String, List<String>>{
if (maxResults != null) 'maxResults': [maxResults.toString()],
if (waitTimeSeconds != null)
'waitTimeSeconds': [waitTimeSeconds.toString()],
};
final response = await _protocol.send(
payload: null,
method: 'GET',
requestUri:
'/assistants/${Uri.encodeComponent(assistantId)}/sessions/${Uri.encodeComponent(sessionId)}/recommendations',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
return GetRecommendationsResponse.fromJson(response);
}