list_tasks
¶
list_tasks(
*,
config_overrides: Optional[ECSClientConfig] = None,
cluster: Optional[String] = None,
container_instance: Optional[String] = None,
family: Optional[String] = None,
next_token: Optional[String] = None,
max_results: Optional[BoxedInteger] = None,
started_by: Optional[String] = None,
service_name: Optional[String] = None,
desired_status: Optional[DesiredStatus] = None,
launch_type: Optional[LaunchType] = None,
daemon_name: Optional[String] = None,
) -> ListTasksResponse
Returns a list of tasks. You can filter the results by cluster, task definition family, container instance, launch type, what IAM principal started the task, or by the desired status of the task.
Recently stopped tasks might appear in the returned results.
Parameters:
-
cluster(Optional[String], default:None) –The short name or full Amazon Resource Name (ARN) of the cluster to use when filtering the
ListTasksresults. If you do not specify a cluster, the default cluster is assumed. -
container_instance(Optional[String], default:None) –The container instance ID or full ARN of the container instance to use when filtering the
ListTasksresults. Specifying acontainerInstancelimits the results to tasks that belong to that container instance. -
family(Optional[String], default:None) –The name of the task definition family to use when filtering the
ListTasksresults. Specifying afamilylimits the results to tasks that belong to that family. -
next_token(Optional[String], default:None) –The
nextTokenvalue returned from aListTasksrequest indicating that more results are available to fulfill the request and further calls will be needed. IfmaxResultswas provided, it's possible the number of results to be fewer thanmaxResults.This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.
-
max_results(Optional[BoxedInteger], default:None) –The maximum number of task results that
ListTasksreturned in paginated output. When this parameter is used,ListTasksonly returnsmaxResultsresults in a single page along with anextTokenresponse element. The remaining results of the initial request can be seen by sending anotherListTasksrequest with the returnednextTokenvalue. This value can be between 1 and 100. If this parameter isn't used, thenListTasksreturns up to 100 results and anextTokenvalue if applicable. -
started_by(Optional[String], default:None) –The
startedByvalue to filter the task results with. Specifying astartedByvalue limits the results to tasks that were started with that value.When you specify
startedByas the filter, it must be the only filter that you use. -
service_name(Optional[String], default:None) –The name of the service to use when filtering the
ListTasksresults. Specifying aserviceNamelimits the results to tasks that belong to that service. -
desired_status(Optional[DesiredStatus], default:None) –The task desired status to use when filtering the
ListTasksresults. Specifying adesiredStatusofSTOPPEDlimits the results to tasks that Amazon ECS has set the desired status toSTOPPED. This can be useful for debugging tasks that aren't starting properly or have died or finished. The default status filter isRUNNING, which shows tasks that Amazon ECS has set the desired status toRUNNING.Although you can filter results based on a desired status of
PENDING, this doesn't return any results. Amazon ECS never sets the desired status of a task to that value (only a task'slastStatusmay have a value ofPENDING). -
launch_type(Optional[LaunchType], default:None) –The launch type to use when filtering the
ListTasksresults. -
daemon_name(Optional[String], default:None) –The name of the daemon to use when filtering the
ListTasksresults. Specifying adaemonNamelimits the results to tasks that belong to that daemon.
Raises:
-
AccessDeniedException–You don't have authorization to perform the requested action.
-
ClientException–These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.
-
ClusterNotFoundException–The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.
-
InvalidParameterException–The specified parameter isn't valid. Review the available parameters for the API request.
For more information about service event errors, see Amazon ECS service event messages.
-
ServerException–These errors are usually caused by a server issue.
-
ServiceNotFoundException–The specified service wasn't found. You can view your available services with ListServices. Amazon ECS services are cluster specific and Region specific.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To list the tasks in a cluster This example lists all of the tasks in a cluster.
>>> client.list_tasks(cluster='default')
To list the tasks on a particular container instance
This example lists the tasks of a specified container instance. Specifying a ``containerInstance`` value limits the results to tasks that belong to that container instance.
Source code in docs_src/capo_ecs/_services/ecs.py
2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 | |