searchMessageTemplates method

Future<SearchMessageTemplatesResponse> searchMessageTemplates({
  1. required String knowledgeBaseId,
  2. required MessageTemplateSearchExpression searchExpression,
  3. int? maxResults,
  4. String? nextToken,
})

Searches for Amazon Q in Connect message templates in the specified knowledge base.

May throw AccessDeniedException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter knowledgeBaseId : The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.

Parameter searchExpression : The search expression for querying the message template.

Parameter maxResults : The maximum number of results to return per page.

Parameter nextToken : The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

Implementation

Future<SearchMessageTemplatesResponse> searchMessageTemplates({
  required String knowledgeBaseId,
  required MessageTemplateSearchExpression searchExpression,
  int? maxResults,
  String? nextToken,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $query = <String, List<String>>{
    if (maxResults != null) 'maxResults': [maxResults.toString()],
    if (nextToken != null) 'nextToken': [nextToken],
  };
  final $payload = <String, dynamic>{
    'searchExpression': searchExpression,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/knowledgeBases/${Uri.encodeComponent(knowledgeBaseId)}/search/messageTemplates',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return SearchMessageTemplatesResponse.fromJson(response);
}