listFleets method

Future<ListFleetsOutput> listFleets({
  1. String? buildId,
  2. int? limit,
  3. String? nextToken,
  4. String? scriptId,
})

Retrieves a collection of fleet resources for this AWS account. You can filter the result set to find only those fleets that are deployed with a specific build or script. Use the pagination parameters to retrieve results in sequential pages. Learn more

Setting up GameLift Fleets

Related operations

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

Parameter buildId : A unique identifier for a build to return fleets for. Use this parameter to return only fleets using a specified build. Use either the build ID or ARN value. To retrieve all fleets, do not include either a BuildId and ScriptID parameter.

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 scriptId : A unique identifier for a Realtime script to return fleets for. Use this parameter to return only fleets using a specified script. Use either the script ID or ARN value. To retrieve all fleets, leave this parameter empty.

Implementation

Future<ListFleetsOutput> listFleets({
  String? buildId,
  int? limit,
  String? nextToken,
  String? scriptId,
}) async {
  _s.validateNumRange(
    'limit',
    limit,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.ListFleets'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (buildId != null) 'BuildId': buildId,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
      if (scriptId != null) 'ScriptId': scriptId,
    },
  );

  return ListFleetsOutput.fromJson(jsonResponse.body);
}