adminListGroupsForUser method

Future<AdminListGroupsForUserResponse> adminListGroupsForUser({
  1. required String userPoolId,
  2. required String username,
  3. int? limit,
  4. String? nextToken,
})

Lists the groups that the user belongs to.

Calling this action requires developer credentials.

May throw InvalidParameterException. May throw ResourceNotFoundException. May throw TooManyRequestsException. May throw NotAuthorizedException. May throw UserNotFoundException. May throw InternalErrorException.

Parameter userPoolId : The user pool ID for the user pool.

Parameter username : The username for the user.

Parameter limit : The limit of the request to list groups.

Parameter nextToken : An identifier that was returned from the previous call to this operation, which can be used to return the next set of items in the list.

Implementation

Future<AdminListGroupsForUserResponse> adminListGroupsForUser({
  required String userPoolId,
  required String username,
  int? limit,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(userPoolId, 'userPoolId');
  _s.validateStringLength(
    'userPoolId',
    userPoolId,
    1,
    55,
    isRequired: true,
  );
  ArgumentError.checkNotNull(username, 'username');
  _s.validateStringLength(
    'username',
    username,
    1,
    128,
    isRequired: true,
  );
  _s.validateNumRange(
    'limit',
    limit,
    0,
    60,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1152921504606846976,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminListGroupsForUser'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'UserPoolId': userPoolId,
      'Username': username,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return AdminListGroupsForUserResponse.fromJson(jsonResponse.body);
}