deleteService method

Future<DeleteServiceResponse> deleteService({
  1. required String service,
  2. String? cluster,
  3. bool? force,
})

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 can't delete it, and you must update the service to a desired task count of zero. For more information, see UpdateService.

May throw AccessDeniedException. May throw ClientException. May throw ClusterNotFoundException. May throw InvalidParameterException. May throw ServerException. 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 wasn't scaled down to zero tasks. It's only necessary to use this if the service uses the REPLICA scheduling strategy.

Implementation

Future<DeleteServiceResponse> deleteService({
  required String service,
  String? cluster,
  bool? force,
}) async {
  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);
}