findGroups method

Future<FoundGroups> findGroups({
  1. String? accountId,
  2. String? query,
  3. List<String>? exclude,
  4. List<String>? excludeId,
  5. int? maxResults,
  6. bool? caseInsensitive,
  7. String? userName,
})

Returns a list of groups whose names contain a query string. A list of group names can be provided to exclude groups from the results.

The primary use case for this resource is to populate a group picker suggestions list. To this end, the returned object includes the html field where the matched query term is highlighted in the group name with the HTML strong tag. Also, the groups list is wrapped in a response object that contains a header for use in the picker, specifically Showing X of Y matching groups.

The list returns with the groups sorted. If no groups match the list criteria, an empty list is returned.

This operation can be accessed anonymously.

Permissions required: Browse projects project permission. Anonymous calls and calls by users without the required permission return an empty list.

Browse users and groups global permission. Without this permission, calls where query is not an exact match to an existing group will return an empty list.

Implementation

Future<FoundGroups> findGroups(
    {String? accountId,
    String? query,
    List<String>? exclude,
    List<String>? excludeId,
    int? maxResults,
    bool? caseInsensitive,
    String? userName}) async {
  return FoundGroups.fromJson(await _client.send(
    'get',
    'rest/api/3/groups/picker',
    queryParameters: {
      if (accountId != null) 'accountId': accountId,
      if (query != null) 'query': query,
      if (exclude != null) 'exclude': exclude.map((e) => e).join(','),
      if (excludeId != null) 'excludeId': excludeId.map((e) => e).join(','),
      if (maxResults != null) 'maxResults': '$maxResults',
      if (caseInsensitive != null) 'caseInsensitive': '$caseInsensitive',
      if (userName != null) 'userName': userName,
    },
  ));
}