deleteService method
Deletes a specified service within a cluster. You can delete a service if you have no running tasks in it and the desired task count is zero. If the service is actively maintaining tasks, you cannot delete it, and you must update the service to a desired task count of zero. For more information, see UpdateService.
May throw ServerException. May throw ClientException. May throw InvalidParameterException. May throw ClusterNotFoundException. May throw ServiceNotFoundException.
Parameter service
:
The name of the service to delete.
Parameter cluster
:
The short name or full Amazon Resource Name (ARN) of the cluster that
hosts the service to delete. If you do not specify a cluster, the default
cluster is assumed.
Parameter force
:
If true
, allows you to delete a service even if it has not
been scaled down to zero tasks. It is only necessary to use this if the
service is using the REPLICA
scheduling strategy.
Implementation
Future<DeleteServiceResponse> deleteService({
required String service,
String? cluster,
bool? force,
}) async {
ArgumentError.checkNotNull(service, 'service');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonEC2ContainerServiceV20141113.DeleteService'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'service': service,
if (cluster != null) 'cluster': cluster,
if (force != null) 'force': force,
},
);
return DeleteServiceResponse.fromJson(jsonResponse.body);
}