describeInstances method

Future<DescribeInstancesOutput> describeInstances({
  1. required String fleetId,
  2. String? instanceId,
  3. int? limit,
  4. String? nextToken,
})

Retrieves information about a fleet's instances, including instance IDs. Use this operation to get details on all instances in the fleet or get details on one specific instance.

To get a specific instance, specify fleet ID and instance ID. To get all instances in a fleet, specify a fleet ID only. Use the pagination parameters to retrieve results as a set of sequential pages. If successful, an Instance object is returned for each result.

Learn more

Remotely Access Fleet Instances

Debug Fleet Issues

Related operations

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

Parameter fleetId : A unique identifier for a fleet to retrieve instance information for. You can use either the fleet ID or ARN value.

Parameter instanceId : A unique identifier for an instance to retrieve. Specify an instance ID or leave blank to retrieve all instances in the fleet.

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.

Implementation

Future<DescribeInstancesOutput> describeInstances({
  required String fleetId,
  String? instanceId,
  int? limit,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(fleetId, 'fleetId');
  _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.DescribeInstances'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'FleetId': fleetId,
      if (instanceId != null) 'InstanceId': instanceId,
      if (limit != null) 'Limit': limit,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return DescribeInstancesOutput.fromJson(jsonResponse.body);
}