listGameServers method

Future<ListGameServersOutput> listGameServers({
  1. required String gameServerGroupName,
  2. int? limit,
  3. String? nextToken,
  4. SortOrder? sortOrder,
})

This operation is used with the Amazon GameLift FleetIQ solution and game server groups.

Retrieves information on all game servers that are currently active in a specified game server group. You can opt to sort the list by game server age. Use the pagination parameters to retrieve results in a set of sequential segments.

Learn more

GameLift FleetIQ Guide

Related operations

May throw InvalidRequestException. May throw UnauthorizedException. May throw InternalServiceException.

Parameter gameServerGroupName : An identifier for the game server group to retrieve a list of game servers from. Use either the GameServerGroup name or ARN value.

Parameter limit : The maximum number of results to return. Use this parameter with NextToken to get results as a set of sequential segments.

Parameter nextToken : A token that indicates the start of the next sequential segment of results. Use the token returned with the previous call to this operation. To start at the beginning of the result set, do not specify a value.

Parameter sortOrder : Indicates how to sort the returned data based on game server registration timestamp. Use ASCENDING to retrieve oldest game servers first, or use DESCENDING to retrieve newest game servers first. If this parameter is left empty, game servers are returned in no particular order.

Implementation

Future<ListGameServersOutput> listGameServers({
  required String gameServerGroupName,
  int? limit,
  String? nextToken,
  SortOrder? sortOrder,
}) async {
  ArgumentError.checkNotNull(gameServerGroupName, 'gameServerGroupName');
  _s.validateStringLength(
    'gameServerGroupName',
    gameServerGroupName,
    1,
    256,
    isRequired: true,
  );
  _s.validateNumRange(
    'limit',
    limit,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.ListGameServers'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GameServerGroupName': gameServerGroupName,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
      if (sortOrder != null) 'SortOrder': sortOrder.toValue(),
    },
  );

  return ListGameServersOutput.fromJson(jsonResponse.body);
}