Skip to content

claim_game_server

claim_game_server(
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    game_server_group_name: Optional[GameServerGroupNameOrArn] = None,
    game_server_id: Optional[GameServerId] = None,
    game_server_data: Optional[GameServerData] = None,
    filter_option: Optional[ClaimFilterOption] = None,
) -> ClaimGameServerOutput

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

Locates an available game server and temporarily reserves it to host gameplay and players. This operation is called from a game client or client service (such as a matchmaker) to request hosting resources for a new game session. In response, Amazon GameLift Servers FleetIQ locates an available game server, places it in CLAIMED status for 60 seconds, and returns connection information that players can use to connect to the game server.

To claim a game server, identify a game server group. You can also specify a game server ID, although this approach bypasses Amazon GameLift Servers FleetIQ placement optimization. Optionally, include game data to pass to the game server at the start of a game session, such as a game map or player information. Add filter options to further restrict how a game server is chosen, such as only allowing game servers on ACTIVE instances to be claimed.

When a game server is successfully claimed, connection information is returned. A claimed game server's utilization status remains AVAILABLE while the claim status is set to CLAIMED for up to 60 seconds. This time period gives the game server time to update its status to UTILIZED after players join. If the game server's status is not updated within 60 seconds, the game server reverts to unclaimed status and is available to be claimed by another request. The claim time period is a fixed value and is not configurable.

If you try to claim a specific game server, this request will fail in the following cases:

  • If the game server utilization status is UTILIZED.

  • If the game server claim status is CLAIMED.

  • If the game server is running on an instance in DRAINING status and the provided filter option does not allow placing on DRAINING instances.

Learn more

Amazon GameLift Servers FleetIQ Guide

Parameters:

  • game_server_group_name (Optional[GameServerGroupNameOrArn], default: None ) –

    A unique identifier for the game server group where the game server is running. If you are not specifying a game server to claim, this value identifies where you want Amazon GameLift Servers FleetIQ to look for an available game server to claim.

  • game_server_id (Optional[GameServerId], default: None ) –

    A custom string that uniquely identifies the game server to claim. If this parameter is left empty, Amazon GameLift Servers FleetIQ searches for an available game server in the specified game server group.

  • game_server_data (Optional[GameServerData], default: None ) –

    A set of custom game server properties, formatted as a single string value. This data is passed to a game client or service when it requests information on game servers.

  • filter_option (Optional[ClaimFilterOption], default: None ) –

    Object that restricts how a claimed game server is chosen.

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.

  • 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.

  • OutOfCapacityException –

    The specified game server group has no available game servers to fulfill a ClaimGameServer request. Clients can retry such requests immediately or after a waiting period.

  • 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 claim_game_server(
    self,
    *,
    config_overrides: Optional[GameLiftClientConfig] = None,
    game_server_group_name: Optional[
        "capo_gamelift.types.game_server_group_name_or_arn.GameServerGroupNameOrArn"
    ] = None,
    game_server_id: Optional[
        "capo_gamelift.types.game_server_id.GameServerId"
    ] = None,
    game_server_data: Optional[
        "capo_gamelift.types.game_server_data.GameServerData"
    ] = None,
    filter_option: Optional[
        "capo_gamelift.types.claim_filter_option.ClaimFilterOption"
    ] = None,
) -> "capo_gamelift.types.claim_game_server_output.ClaimGameServerOutput":
    """<p> <b>This API works with the following fleet types:</b> EC2 (FleetIQ)</p> <p>Locates an available game server and temporarily reserves it to host gameplay and players. This operation is called from a game client or client service (such as a matchmaker) to request hosting resources for a new game session. In response, Amazon GameLift Servers FleetIQ locates an available game server, places it in <code>CLAIMED</code> status for 60 seconds, and returns connection information that players can use to connect to the game server. </p> <p>To claim a game server, identify a game server group. You can also specify a game server ID, although this approach bypasses Amazon GameLift Servers FleetIQ placement optimization. Optionally, include game data to pass to the game server at the start of a game session, such as a game map or player information. Add filter options to further restrict how a game server is chosen, such as only allowing game servers on <code>ACTIVE</code> instances to be claimed.</p> <p>When a game server is successfully claimed, connection information is returned. A claimed game server's utilization status remains <code>AVAILABLE</code> while the claim status is set to <code>CLAIMED</code> for up to 60 seconds. This time period gives the game server time to update its status to <code>UTILIZED</code> after players join. If the game server's status is not updated within 60 seconds, the game server reverts to unclaimed status and is available to be claimed by another request. The claim time period is a fixed value and is not configurable.</p> <p>If you try to claim a specific game server, this request will fail in the following cases:</p> <ul> <li> <p>If the game server utilization status is <code>UTILIZED</code>.</p> </li> <li> <p>If the game server claim status is <code>CLAIMED</code>.</p> </li> <li> <p>If the game server is running on an instance in <code>DRAINING</code> status and the provided filter option does not allow placing on <code>DRAINING</code> instances.</p> </li> </ul> <p> <b>Learn more</b> </p> <p> <a href="https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html">Amazon GameLift Servers FleetIQ Guide</a> </p>

    Args:
        game_server_group_name: <p>A unique identifier for the game server group where the game server is running. If you are not specifying a game server to claim, this value identifies where you want Amazon GameLift Servers FleetIQ to look for an available game server to claim. </p>
        game_server_id: <p>A custom string that uniquely identifies the game server to claim. If this parameter is left empty, Amazon GameLift Servers FleetIQ searches for an available game server in the specified game server group.</p>
        game_server_data: <p>A set of custom game server properties, formatted as a single string value. This data is passed to a game client or service when it requests information on game servers. </p>
        filter_option: <p>Object that restricts how a claimed game server is chosen.</p>

    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_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.out_of_capacity_exception.OutOfCapacityException: <p>The specified game server group has no available game servers to fulfill a <code>ClaimGameServer</code> request. Clients can retry such requests immediately or after a waiting period.</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.claim_game_server_input.ClaimGameServerInput]",
    ) -> OperationResponse[
        "capo_gamelift.types.claim_game_server_output.ClaimGameServerOutput"
    ]:
        import capo_gamelift._operations.game_lift.claim_game_server

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

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

        return capo_gamelift.types.claim_game_server_input.redact_sensitive(input_)

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

        return capo_gamelift.types.claim_game_server_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ClaimGameServer",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_gamelift.types.claim_game_server_input.ClaimGameServerInput = {}
    if game_server_group_name is not None:
        input_["game_server_group_name"] = game_server_group_name
    if game_server_id is not None:
        input_["game_server_id"] = game_server_id
    if game_server_data is not None:
        input_["game_server_data"] = game_server_data
    if filter_option is not None:
        input_["filter_option"] = filter_option

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