listChannels method

Future<ListChannelsResponse> listChannels({
  1. required String appInstanceArn,
  2. required String chimeBearer,
  3. int? maxResults,
  4. String? nextToken,
  5. ChannelPrivacy? privacy,
})

Lists all Channels created under a single Chime App as a paginated list. You can specify filters to narrow results.

Functionality & restrictions

  • Use privacy = PUBLIC to retrieve all public channels in the account.
  • Only an AppInstanceAdmin can set privacy = PRIVATE to list the private channels in an account.

May throw BadRequestException. May throw ForbiddenException. May throw ServiceFailureException. May throw ServiceUnavailableException. May throw ThrottledClientException. May throw UnauthorizedClientException.

Parameter appInstanceArn : The ARN of the AppInstance.

Parameter chimeBearer : The ARN of the AppInstanceUser or AppInstanceBot that makes the API call.

Parameter maxResults : The maximum number of channels that you want to return.

Parameter nextToken : The token passed by previous API calls until all requested channels are returned.

Parameter privacy : The privacy setting. PUBLIC retrieves all the public channels. PRIVATE retrieves private channels. Only an AppInstanceAdmin can retrieve private channels.

Implementation

Future<ListChannelsResponse> listChannels({
  required String appInstanceArn,
  required String chimeBearer,
  int? maxResults,
  String? nextToken,
  ChannelPrivacy? privacy,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    50,
  );
  final headers = <String, String>{
    'x-amz-chime-bearer': chimeBearer.toString(),
  };
  final $query = <String, List<String>>{
    'app-instance-arn': [appInstanceArn],
    if (maxResults != null) 'max-results': [maxResults.toString()],
    if (nextToken != null) 'next-token': [nextToken],
    if (privacy != null) 'privacy': [privacy.value],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/channels',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return ListChannelsResponse.fromJson(response);
}