updateGameSession method

Future<UpdateGameSessionOutput> updateGameSession({
  1. required String gameSessionId,
  2. int? maximumPlayerSessionCount,
  3. String? name,
  4. PlayerSessionCreationPolicy? playerSessionCreationPolicy,
  5. ProtectionPolicy? protectionPolicy,
})

Updates game session properties. This includes the session name, maximum player count, protection policy, which controls whether or not an active game session can be terminated during a scale-down event, and the player session creation policy, which controls whether or not new players can join the session. To update a game session, specify the game session ID and the values you want to change. If successful, an updated GameSession object is returned.

May throw NotFoundException. May throw ConflictException. May throw InternalServiceException. May throw UnauthorizedException. May throw InvalidGameSessionStatusException. May throw InvalidRequestException.

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

Parameter maximumPlayerSessionCount : The maximum number of players that can be connected simultaneously to the game session.

Parameter name : A descriptive label that is associated with a game session. Session names do not need to be unique.

Parameter playerSessionCreationPolicy : Policy determining whether or not the game session accepts new players.

Parameter protectionPolicy : Game session protection policy to apply to this game session only.

  • NoProtection -- The game session can be terminated during a scale-down event.
  • FullProtection -- If the game session is in an ACTIVE status, it cannot be terminated during a scale-down event.

Implementation

Future<UpdateGameSessionOutput> updateGameSession({
  required String gameSessionId,
  int? maximumPlayerSessionCount,
  String? name,
  PlayerSessionCreationPolicy? playerSessionCreationPolicy,
  ProtectionPolicy? protectionPolicy,
}) async {
  ArgumentError.checkNotNull(gameSessionId, 'gameSessionId');
  _s.validateStringLength(
    'gameSessionId',
    gameSessionId,
    1,
    256,
    isRequired: true,
  );
  _s.validateNumRange(
    'maximumPlayerSessionCount',
    maximumPlayerSessionCount,
    0,
    1152921504606846976,
  );
  _s.validateStringLength(
    'name',
    name,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.UpdateGameSession'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'GameSessionId': gameSessionId,
      if (maximumPlayerSessionCount != null)
        'MaximumPlayerSessionCount': maximumPlayerSessionCount,
      if (name != null) 'Name': name,
      if (playerSessionCreationPolicy != null)
        'PlayerSessionCreationPolicy': playerSessionCreationPolicy.toValue(),
      if (protectionPolicy != null)
        'ProtectionPolicy': protectionPolicy.toValue(),
    },
  );

  return UpdateGameSessionOutput.fromJson(jsonResponse.body);
}