getAllChannels method
Get a list of all channels
Permissions manage_system
Parameters:
-
String notAssociatedToGroup: A group id to exclude channels that are associated with that group via GroupChannel records. This can also be left blank with
not_associated_to_group=
. -
int page:
-
int perPage:
-
bool excludeDefaultChannels: Whether to exclude default channels (ex Town Square, Off-Topic) from the results.
-
bool includeDeleted: Include channels that have been archived. This correlates to the
DeleteAt
flag being set in the database. -
bool includeTotalCount: Appends a total count of returned channels inside the response object - ex:
{ \"channels\": [], \"total_count\" : 0 }
. -
bool excludePolicyConstrained: If set to true, channels which are part of a data retention policy will be excluded. The
sysconsole_read_compliance
permission is required to use this parameter. Minimum server version: 5.35
Implementation
Future<List<MmChannelWithTeamData>?> getAllChannels({
String? notAssociatedToGroup,
int? page,
int? perPage,
bool? excludeDefaultChannels,
bool? includeDeleted,
bool? includeTotalCount,
bool? excludePolicyConstrained,
}) async {
final response = await getAllChannelsWithHttpInfo(
notAssociatedToGroup: notAssociatedToGroup,
page: page,
perPage: perPage,
excludeDefaultChannels: excludeDefaultChannels,
includeDeleted: includeDeleted,
includeTotalCount: includeTotalCount,
excludePolicyConstrained: excludePolicyConstrained,
);
if (response.statusCode >= HttpStatus.badRequest) {
throw MmApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<MmChannelWithTeamData>') as List)
.cast<MmChannelWithTeamData>()
.toList();
}
return null;
}