listGameServers method

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

This API works with the following fleet types: EC2 (FleetIQ)

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

Amazon GameLift Servers FleetIQ Guide

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

Parameter gameServerGroupName : An identifier for the game server group to retrieve a list of game servers from. Use either the 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 pages.

Parameter nextToken : A token that indicates the start of the next sequential page of results. Use the token that is returned with a 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 {
  _s.validateNumRange(
    'limit',
    limit,
    1,
    1152921504606846976,
  );
  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.value,
    },
  );

  return ListGameServersOutput.fromJson(jsonResponse.body);
}