Parameter description
Attribute | Type | Description |
---|---|---|
resource_type | str | Resource type. Currently, only “jobs”, “clusters”, “tasks”, or “instances” can be listed |
resource_info | tuple | Location parameter, containing all other information required to list resources. For example, job_id and task_name must be provided when instances are listed |
filters | dict | Key-value pair. You can set multiple resource filtering conditions |
Response description
The easy_list method returns a list
object, which contains all resource instances that meet filtering conditions in resource_type
.
Example
try:
client = Client(...
...
# List all jobs which named "PythonSDK" and have a description of "test list job".
for job in client.easy_list("jobs", Name="PythonSDK", Description="test list job"):
print (job.Name, job.Id)
# List all jobs which named "PythonSDK" and have a description of "test list job".
# filters can be also unpacked from a dict.
job_filters = {
"Name": "PythonSDK",
"Description": "test list job"
}
for job in client.easy_list("jobs", **job_filters):
print (job.Name, job.Id)
# List all jobs whose state is "Waiting" or "Running".
# `filetrs` with a tuple value also available.
for job in client.easy_list('jobs', State=['Waiting', 'Running']):
print (job.Name, job.Id)
# List all jobs whose state is "Waiting" or "Running".
# `filters` with a function value defined by users.
state_filter = lambda state: state in ['Waiting', 'Running']
for job in client.easy_list('jobs', State=state_filter):
print (job.Name, job.Id)
# List all "Runing" tasks in a job.
job_id = 'job-xxx'
client.easy_list('tasks', job_id, State='Running')
# List all "Running" instances in a task.
job_id = 'job-xxx'
task_name = 'Echo'
client.easy_list('instances', job_id, task_name, State='Running')
except ClientError, e:
print(e)