batchAddClusterNodes method

Future<BatchAddClusterNodesResponse> batchAddClusterNodes({
  1. required String clusterName,
  2. required List<AddClusterNodeSpecification> nodesToAdd,
  3. String? clientToken,
})

Adds nodes to a HyperPod cluster by incrementing the target count for one or more instance groups. This operation returns a unique NodeLogicalId for each node being added, which can be used to track the provisioning status of the node. This API provides a safer alternative to UpdateCluster for scaling operations by avoiding unintended configuration changes.

May throw ResourceLimitExceeded. May throw ResourceNotFound.

Parameter clusterName : The name of the HyperPod cluster to which you want to add nodes.

Parameter nodesToAdd : A list of instance groups and the number of nodes to add to each. You can specify up to 5 instance groups in a single request, with a maximum of 50 nodes total across all instance groups.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. This token is valid for 8 hours. If you retry the request with the same client token within this timeframe and the same parameters, the API returns the same set of NodeLogicalIds with their latest status.

Implementation

Future<BatchAddClusterNodesResponse> batchAddClusterNodes({
  required String clusterName,
  required List<AddClusterNodeSpecification> nodesToAdd,
  String? clientToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SageMaker.BatchAddClusterNodes'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ClusterName': clusterName,
      'NodesToAdd': nodesToAdd,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    },
  );

  return BatchAddClusterNodesResponse.fromJson(jsonResponse.body);
}