search_game_sessions
async
¶
search_game_sessions(
*,
config_overrides: Optional[AsyncGameLiftClientConfig] = None,
fleet_id: Optional[FleetIdOrArn] = None,
alias_id: Optional[AliasIdOrArn] = None,
location: Optional[LocationStringModel] = None,
filter_expression: Optional[NonZeroAndMaxString] = None,
sort_expression: Optional[NonZeroAndMaxString] = None,
limit: Optional[PositiveInteger] = None,
next_token: Optional[NonZeroAndMaxString] = None,
) -> SearchGameSessionsOutput
This API works with the following fleet types: EC2, Anywhere, Container
Retrieves all active game sessions that match a set of search criteria and sorts them into a specified order.
This operation is not designed to continually track game session status because that practice can cause you to exceed your API limit and generate errors. Instead, configure an Amazon Simple Notification Service (Amazon SNS) topic to receive notifications from a matchmaker or a game session placement queue.
When searching for game sessions, you specify exactly where you want to search and provide a search filter expression, a sort expression, or both. A search request can search only one fleet, but it can search all of a fleet's locations.
This operation can be used in the following ways:
-
To search all game sessions that are currently running on all locations in a fleet, provide a fleet or alias ID. This approach returns game sessions in the fleet's home Region and all remote locations that fit the search criteria.
-
To search all game sessions that are currently running on a specific fleet location, provide a fleet or alias ID and a location name. For location, you can specify a fleet's home Region or any remote location.
Use the pagination parameters to retrieve results as a set of sequential pages.
If successful, a GameSession object is returned for each game session that matches the request. Search finds game sessions that are in ACTIVE status only. To retrieve information on game sessions in other statuses, use DescribeGameSessions.
To set search and sort criteria, create a filter expression using the following game session attributes. For game session search examples, see the Examples section of this topic.
-
gameSessionId -- An identifier for the game session that is unique across all regions. You must use the full ARN value.
-
gameSessionName -- Name assigned to a game session. Game session names do not need to be unique to a game session.
-
gameSessionProperties -- A set of key-value pairs that can store custom data in a game session. For example:
{"Key": "difficulty", "Value": "novice"}. The filter expression must specify the GameProperty -- aKeyand a stringValueto search for the game sessions.For example, to search for the above key-value pair, specify the following search filter:
gameSessionProperties.difficulty = "novice". All game property values are searched as strings.For examples of searching game sessions, see the ones below, and also see Search game sessions by 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.
-
-
maximumSessions -- Maximum number of player sessions allowed for a game session.
-
creationTimeMillis -- Value indicating when a game session was created. It is expressed in Unix time as milliseconds.
-
playerSessionCount -- Number of players currently connected to a game session. This value changes rapidly as players join the session or drop out.
-
hasAvailablePlayerSessions -- Boolean value indicating whether a game session has reached its maximum number of players. It is highly recommended that all search requests include this filter attribute to optimize search performance and return only sessions that players can join.
Returned values for playerSessionCount and hasAvailablePlayerSessions change quickly as players join sessions and others drop out. Results should be considered a snapshot in time. Be sure to refresh search results often, and handle sessions that fill up before a player can join.
Parameters:
-
fleet_id(Optional[FleetIdOrArn], default:None) –A unique identifier for the fleet to search for active game sessions. You can use either the fleet ID or ARN value. Each request must reference either a fleet ID or alias ID, but not both.
-
alias_id(Optional[AliasIdOrArn], default:None) –A unique identifier for the alias associated with the fleet to search for active game sessions. You can use either the alias ID or ARN value. Each request must reference either a fleet ID or alias ID, but not both.
-
location(Optional[LocationStringModel], default:None) –A fleet location to search for game sessions. You can specify a fleet's home Region or a remote location. Use the Amazon Web Services Region code format, such as
us-west-2. -
filter_expression(Optional[NonZeroAndMaxString], default:None) –String containing the search criteria for the session search. If no filter expression is included, the request returns results for all game sessions in the fleet that are in
ACTIVEstatus.A filter expression can contain one or multiple conditions. Each condition consists of the following:
-
Operand -- Name of a game session attribute. Valid values are
gameSessionName,gameSessionId,gameSessionProperties,maximumSessions,creationTimeMillis,playerSessionCount,hasAvailablePlayerSessions. -
Comparator -- Valid comparators are:
=,<>,<,>,<=,>=. -
Value -- Value to be searched for. Values may be numbers, boolean values (true/false) or strings depending on the operand. String values are case sensitive and must be enclosed in single quotes. Special characters must be escaped. Boolean and string values can only be used with the comparators
=and<>. For example, the following filter expression searches ongameSessionName: "FilterExpression": "gameSessionName = 'Matt\\'s Awesome Game 1'".
To chain multiple conditions in a single expression, use the logical keywords
AND,OR, andNOTand parentheses as needed. For example:x AND y AND NOT z,NOT (x OR y).Session search evaluates conditions from left to right using the following precedence rules:
-
=,<>,<,>,<=,>= -
Parentheses
-
NOT
-
AND
-
OR
For example, this filter expression retrieves game sessions hosting at least ten players that have an open player slot:
"maximumSessions>=10 AND hasAvailablePlayerSessions=true". -
-
sort_expression(Optional[NonZeroAndMaxString], default:None) –Instructions on how to sort the search results. If no sort expression is included, the request returns results in random order. A sort expression consists of the following elements:
-
Operand -- Name of a game session attribute. Valid values are
gameSessionName,gameSessionId,gameSessionProperties,maximumSessions,creationTimeMillis,playerSessionCount,hasAvailablePlayerSessions. -
Order -- Valid sort orders are
ASC(ascending) andDESC(descending).
For example, this sort expression returns the oldest active sessions first:
"SortExpression": "creationTimeMillis ASC". Results with a null value for the sort operand are returned at the end of the list. -
-
limit(Optional[PositiveInteger], default:None) –The maximum number of results to return. Use this parameter with
NextTokento get results as a set of sequential pages. The maximum number of results returned is 20, even if this value is not set or is set higher than 20. -
next_token(Optional[NonZeroAndMaxString], default:None) –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.
Raises:
-
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.
-
TerminalRoutingStrategyException–The service is unable to resolve the routing for a particular alias because it has a terminal
RoutingStrategyassociated with it. The message returned in this exception is the message defined in the routing strategy itself. Such requests should only be retried if the routing strategy for the specified alias is modified. -
UnauthorizedException–The client failed authentication. Clients should not retry such requests.
-
UnsupportedRegionException–The requested operation is not supported in the Region specified.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_gamelift/_services/async_game_lift.py
7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 | |