search method

Future<SearchMessagesResponse> search(
  1. SearchMessagesRequest request,
  2. String parent, {
  3. String? $fields,
})

Searches for messages in Google Chat that the calling user has access to.

Returns a list of messages matching the search criteria. To search across all spaces the user has access to, set parent to spaces/-. Using any other value for parent results in an INVALID_ARGUMENT error. The returned messages have their name field populated with the full resource name, which includes the specific space in which the message resides. This API doesn't return all message types. The types of messages listed below aren't included in the response. Use ListMessages to list all messages. - Private Messages that are visible to the authenticated user. - Messages posted by Chat apps in spaces or group chats. - Messages in a Chat app DM. - Messages from blocked users. - Messages in spaces that the caller has muted. Requires user authentication with one of the following authorization scopes:

  • https://www.googleapis.com/auth/chat.messages.readonly - https://www.googleapis.com/auth/chat.messages

request - The metadata request object.

Request parameters:

parent - Required. The resource name of the space to search within. To search across all spaces the user has access to, set this field to spaces/-. Using any other value for parent results in an INVALID_ARGUMENT error. To limit the search to one or more spaces, use space.name or space.display_name in the filter. Value must have pattern ^spaces/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a SearchMessagesResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<SearchMessagesResponse> search(
  SearchMessagesRequest request,
  core.String parent, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/messages:search';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return SearchMessagesResponse.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}