describeGameSessions method

Future<DescribeGameSessionsOutput> describeGameSessions({
  1. String? aliasId,
  2. String? fleetId,
  3. String? gameSessionId,
  4. int? limit,
  5. String? nextToken,
  6. String? statusFilter,
})

Retrieves a set of one or more game sessions. Request a specific game session or request all game sessions on a fleet. Alternatively, use SearchGameSessions to request a set of active game sessions that are filtered by certain criteria. To retrieve protection policy settings for game sessions, use DescribeGameSessionDetails.

To get game sessions, specify one of the following: game session ID, fleet ID, or alias ID. You can filter this request by game session status. Use the pagination parameters to retrieve results as a set of sequential pages. If successful, a GameSession object is returned for each game session matching the request.

Available in Amazon GameLift Local.

May throw InternalServiceException. May throw NotFoundException. May throw InvalidRequestException. May throw UnauthorizedException. May throw TerminalRoutingStrategyException.

Parameter aliasId : A unique identifier for an alias associated with the fleet to retrieve all game sessions for. You can use either the alias ID or ARN value.

Parameter fleetId : A unique identifier for a fleet to retrieve all game sessions for. You can use either the fleet ID or ARN value.

Parameter gameSessionId : A unique identifier for the game session to retrieve.

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 : 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 statusFilter : Game session status to filter results on. Possible game session statuses include ACTIVE, TERMINATED, ACTIVATING, and TERMINATING (the last two are transitory).

Implementation

Future<DescribeGameSessionsOutput> describeGameSessions({
  String? aliasId,
  String? fleetId,
  String? gameSessionId,
  int? limit,
  String? nextToken,
  String? statusFilter,
}) async {
  _s.validateStringLength(
    'gameSessionId',
    gameSessionId,
    1,
    256,
  );
  _s.validateNumRange(
    'limit',
    limit,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1024,
  );
  _s.validateStringLength(
    'statusFilter',
    statusFilter,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.DescribeGameSessions'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (aliasId != null) 'AliasId': aliasId,
      if (fleetId != null) 'FleetId': fleetId,
      if (gameSessionId != null) 'GameSessionId': gameSessionId,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
      if (statusFilter != null) 'StatusFilter': statusFilter,
    },
  );

  return DescribeGameSessionsOutput.fromJson(jsonResponse.body);
}