listChannels method

Future<ListChannelsResponse> listChannels({
  1. required String appInstanceArn,
  2. int? maxResults,
  3. String? nextToken,
  4. 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 UnauthorizedClientException. May throw ThrottledClientException. May throw ServiceUnavailableException. May throw ServiceFailureException.

Parameter appInstanceArn : The ARN of the app instance.

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 app instance administrator can retrieve private channels.

Implementation

Future<ListChannelsResponse> listChannels({
  required String appInstanceArn,
  int? maxResults,
  String? nextToken,
  ChannelPrivacy? privacy,
}) async {
  ArgumentError.checkNotNull(appInstanceArn, 'appInstanceArn');
  _s.validateStringLength(
    'appInstanceArn',
    appInstanceArn,
    5,
    1600,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    50,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    2048,
  );
  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.toValue()],
  };
  final response = await _protocol.send(
    payload: null,
    method: 'GET',
    requestUri: '/channels',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return ListChannelsResponse.fromJson(response);
}