閱讀712 返回首頁    go 小米MIX


列舉所有__SDK接口說明_Python版SDK_批量計算-阿裏雲

easy_list

參數說明:

屬性 類型 描述
resource_type str 資源類型,目前僅允許列舉”jobs”, “clusters”, “tasks”, “instances”
*resource_info tuple 位置參數,包含列舉資源需要提供的其他所有信息,如列舉”instances”時需要提供job_id和task_name
**filters dict 鍵值對參數,可以設置多個資源過濾條件

返回值說明:

easy_list方法返回一個 list 對象,其中包含了 resource_type 中所有符合過濾條件的資源實例。

e.g.

  1. try:
  2. client = Client(...
  3. ...
  4. # List all jobs which named "PythonSDK" and have a description of "test list job".
  5. for job in client.easy_list("jobs", Name="PythonSDK", Description="test list job")
  6. print (job.Name, job.Description)
  7. # List all jobs which named "PythonSDK" and have a description of "test list job".
  8. # filters can be also unpacked from a dict.
  9. job_filters = {
  10. "Name": "PythonSDK",
  11. "Description": "test list job"
  12. }
  13. for job in client.easy_list("jobs", **job_filters):
  14. print (job.Name, job.Description)
  15. # List all jobs whose state is "Waiting" or "Running".
  16. # `filetrs` with a tuple value also available.
  17. for job in client.easy_list('jobs', State=['Waiting', 'Running']):
  18. print (job.Name, job.Description)
  19. # List all jobs whose state is "Waiting" or "Running".
  20. # `filters` with a function value defined by users.
  21. state_filter = lambda state: state in ['Waiting', 'Running']
  22. for job in client.easy_list('jobs', State=state_filter):
  23. print (job.Name, job.Description)
  24. # List all "Runing" tasks in a job.
  25. job_id = 'job-xxx'
  26. client.easy_list('tasks', job_id, State='Running')
  27. # List all "Running" instances in a task.
  28. job_id = 'job-xxx'
  29. task_name = 'Echo'
  30. client.easy_list('instances', job_id, task_name, State='Running')
  31. except ClientError, e:
  32. print(e)

最後更新:2016-11-23 16:04:16

  上一篇:go 重建集群實例__SDK接口說明_Python版SDK_批量計算-阿裏雲
  下一篇:go 輪詢作業__SDK接口說明_Python版SDK_批量計算-阿裏雲