Skip to content

update_game_session

update_game_session(
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    game_session_id: Optional[ArnStringModel] = None,
    maximum_player_session_count: Optional[WholeNumber] = None,
    name: Optional[NonZeroAndMaxString] = None,
    player_session_creation_policy: Optional[PlayerSessionCreationPolicy] = None,
    protection_policy: Optional[ProtectionPolicy] = None,
    game_properties: Optional[GamePropertyList] = None,
) -> UpdateGameSessionOutput

This API works with the following fleet types: EC2, Anywhere, Container

Updates the mutable properties of a game session.

To update a game session, specify the game session ID and the values you want to change.

If successful, the updated GameSession object is returned.

All APIs by task

Parameters:

  • game_session_id (Optional[ArnStringModel], default: None ) –

    An identifier for the game session that is unique across all regions to update. The value is always a full ARN in the following format: For Home Region game session - arn:aws:gamelift:::gamesession//. For Remote Location game session - arn:aws:gamelift:::gamesession///.

  • maximum_player_session_count (Optional[WholeNumber], default: None ) –

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

  • name (Optional[NonZeroAndMaxString], default: None ) –

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

  • player_session_creation_policy (Optional[PlayerSessionCreationPolicy], default: None ) –

    A policy that determines whether the game session is accepting new players.

  • protection_policy (Optional[ProtectionPolicy], default: None ) –

    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.

  • game_properties (Optional[GamePropertyList], default: None ) –

    A set of key-value pairs that can store custom data in a game session. For example: {"Key": "difficulty", "Value": "novice"}. You can use this parameter to modify game properties in an active game session. This action adds new properties and modifies existing properties. There is no way to delete properties. For an example, see Update the value of a game property.

    • Avoid using periods (".") in property keys if you plan to search for game sessions by properties. Property keys containing periods cannot be searched and will be filtered out from search results due to search index limitations.

    • If you use SearchGameSessions API, there is a limit of 500 game property keys across all game sessions and all fleets per region. If the limit is exceeded, there will potentially be game session entries missing from SearchGameSessions API results.

Raises:

  • ConflictException –

    The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.

  • InternalServiceException –

    The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

  • InvalidGameSessionStatusException –

    The requested operation would cause a conflict with the current state of a resource associated with the request and/or the game instance. Resolve the conflict before retrying.

  • InvalidRequestException –

    One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

  • NotFoundException –

    The requested resource was not found. The resource was either not created yet or deleted.

  • NotReadyException –

    The operation failed because Amazon GameLift Servers has not yet finished validating this compute. We recommend attempting 8 to 10 retries over 3 to 5 minutes with exponential backoffs and jitter.

  • UnauthorizedException –

    The client failed authentication. Clients should not retry such requests.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_gamelift/_services/game_lift.py
def update_game_session(
    self,
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    game_session_id: Optional[
        "capo_gamelift.types.arn_string_model.ArnStringModel"
    ] = None,
    maximum_player_session_count: Optional[
        "capo_gamelift.types.whole_number.WholeNumber"
    ] = None,
    name: Optional[
        "capo_gamelift.types.non_zero_and_max_string.NonZeroAndMaxString"
    ] = None,
    player_session_creation_policy: Optional[
        "capo_gamelift.types.player_session_creation_policy.PlayerSessionCreationPolicy"
    ] = None,
    protection_policy: Optional[
        "capo_gamelift.types.protection_policy.ProtectionPolicy"
    ] = None,
    game_properties: Optional[
        "capo_gamelift.types.game_property_list.GamePropertyList"
    ] = None,
) -> "capo_gamelift.types.update_game_session_output.UpdateGameSessionOutput":
    """<p> <b>This API works with the following fleet types:</b> EC2, Anywhere, Container</p> <p>Updates the mutable properties of a game session. </p> <p>To update a game session, specify the game session ID and the values you want to change. </p> <p>If successful, the updated <code>GameSession</code> object is returned. </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets">All APIs by task</a> </p>

    Args:
        game_session_id: <p>An identifier for the game session that is unique across all regions to update. The value is always a full ARN in the following format: For Home Region game session - <code>arn:aws:gamelift:<home_region>::gamesession/<fleet ID>/<ID string></code>. For Remote Location game session - <code>arn:aws:gamelift:<home_region>::gamesession/<fleet ID>/<location>/<ID string></code>.</p>
        maximum_player_session_count: <p>The maximum number of players that can be connected simultaneously to the game session.</p>
        name: <p>A descriptive label that is associated with a game session. Session names do not need to be unique.</p>
        player_session_creation_policy: <p>A policy that determines whether the game session is accepting new players.</p>
        protection_policy: <p>Game session protection policy to apply to this game session only.</p> <ul> <li> <p> <code>NoProtection</code> -- The game session can be terminated during a scale-down event.</p> </li> <li> <p> <code>FullProtection</code> -- If the game session is in an <code>ACTIVE</code> status, it cannot be terminated during a scale-down event.</p> </li> </ul>
        game_properties: <p>A set of key-value pairs that can store custom data in a game session. For example: <code>{"Key": "difficulty", "Value": "novice"}</code>. You can use this parameter to modify game properties in an active game session. This action adds new properties and modifies existing properties. There is no way to delete properties. For an example, see <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-client-api.html#game-properties-update">Update the value of a game property</a>. </p> <note> <ul> <li> <p>Avoid using periods (".") in property keys if you plan to search for game sessions by properties. Property keys containing periods cannot be searched and will be filtered out from search results due to search index limitations.</p> </li> <li> <p>If you use SearchGameSessions API, there is a limit of 500 game property keys across all game sessions and all fleets per region. If the limit is exceeded, there will potentially be game session entries missing from SearchGameSessions API results.</p> </li> </ul> </note>

    Raises:
        capo_gamelift.errors.conflict_exception.ConflictException: <p>The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.</p> <p></p>
        capo_gamelift.errors.internal_service_exception.InternalServiceException: <p>The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.</p>
        capo_gamelift.errors.invalid_game_session_status_exception.InvalidGameSessionStatusException: <p>The requested operation would cause a conflict with the current state of a resource associated with the request and/or the game instance. Resolve the conflict before retrying.</p>
        capo_gamelift.errors.invalid_request_exception.InvalidRequestException: <p>One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.</p>
        capo_gamelift.errors.not_found_exception.NotFoundException: <p>The requested resource was not found. The resource was either not created yet or deleted.</p>
        capo_gamelift.errors.not_ready_exception.NotReadyException: <p> The operation failed because Amazon GameLift Servers has not yet finished validating this compute. We recommend attempting 8 to 10 retries over 3 to 5 minutes with <a href="http://aws.amazon.com/blogs/https:/aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/">exponential backoffs and jitter</a>. </p>
        capo_gamelift.errors.unauthorized_exception.UnauthorizedException: <p>The client failed authentication. Clients should not retry such requests.</p>
        capo_gamelift.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_gamelift.types.update_game_session_input.UpdateGameSessionInput]",
    ) -> OperationResponse[
        "capo_gamelift.types.update_game_session_output.UpdateGameSessionOutput"
    ]:
        import capo_gamelift._operations.game_lift.update_game_session

        output, http_response = (
            capo_gamelift._operations.game_lift.update_game_session.update_game_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_gamelift.types.update_game_session_input.UpdateGameSessionInput",
    ) -> dict[str, Any]:
        import capo_gamelift.types.update_game_session_input

        return capo_gamelift.types.update_game_session_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_gamelift.types.update_game_session_output.UpdateGameSessionOutput",
    ) -> dict[str, Any]:
        import capo_gamelift.types.update_game_session_output

        return capo_gamelift.types.update_game_session_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateGameSession",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_gamelift.types.update_game_session_input.UpdateGameSessionInput = {}
    if game_session_id is not None:
        input_["game_session_id"] = game_session_id
    if maximum_player_session_count is not None:
        input_["maximum_player_session_count"] = maximum_player_session_count
    if name is not None:
        input_["name"] = name
    if player_session_creation_policy is not None:
        input_["player_session_creation_policy"] = player_session_creation_policy
    if protection_policy is not None:
        input_["protection_policy"] = protection_policy
    if game_properties is not None:
        input_["game_properties"] = game_properties

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output