deleteCapacityProvider method

Future<DeleteCapacityProviderResponse> deleteCapacityProvider({
  1. required String capacityProvider,
  2. String? cluster,
})

Deletes the specified capacity provider. Prior to a capacity provider being deleted, the capacity provider must be removed from the capacity provider strategy from all services. The UpdateService API can be used to remove a capacity provider from a service's capacity provider strategy. When updating a service, the forceNewDeployment option can be used to ensure that any tasks using the Amazon EC2 instance capacity provided by the capacity provider are transitioned to use the capacity from the remaining capacity providers. Only capacity providers that aren't associated with a cluster can be deleted. To remove a capacity provider from a cluster, you can either use PutClusterCapacityProviders or delete the cluster.

May throw AccessDeniedException. May throw ClientException. May throw ClusterNotFoundException. May throw InvalidParameterException. May throw ServerException. May throw UnsupportedFeatureException. May throw UpdateInProgressException.

Parameter capacityProvider : The short name or full Amazon Resource Name (ARN) of the capacity provider to delete.

Parameter cluster : The name of the cluster that contains the capacity provider to delete. Managed instances capacity providers are cluster-scoped and can only be deleted from their associated cluster.

Implementation

Future<DeleteCapacityProviderResponse> deleteCapacityProvider({
  required String capacityProvider,
  String? cluster,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'AmazonEC2ContainerServiceV20141113.DeleteCapacityProvider'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'capacityProvider': capacityProvider,
      if (cluster != null) 'cluster': cluster,
    },
  );

  return DeleteCapacityProviderResponse.fromJson(jsonResponse.body);
}