
# 查询服务对象列表
获取当前用户服务对象列表。
#### 示例代码
在ModelArts Notebook平台，Session鉴权无需输入鉴权参数。其它平台的Session鉴权请参见[Session鉴权](https://support.huaweicloud.com/sdkreference-modelarts/modelarts_04_0123.html)。
- **场景1** ：查询当前用户所有服务对象
  ```
  from modelarts.session import Session
  from modelarts.model import Predictor
  session = Session()
  predictor_list_object_resp = Predictor.get_service_object_list(session)
  print(predictor_list_object_resp)
  ```
  

- **场景2** ：按照检索条件查询当前用户服务对象
  ```
  from modelarts.session import Session
  from modelarts.model import Predictor
  session = Session()
  predictor_object_list = Predictor.get_service_object_list(session, service_name="digit", order="asc", offset="0", infer_type="real-time")
  print(predictor_object_list)
  ```
  
 
#### 参数说明
- 查询服务列表，返回list，list大小等于当前用户所有已经部署的服务个数，list中每个元素都是Predictor对象，对象属性同本章初始化服务。 查询服务列表返回说明：service_list_resp = \[service_instance1, service_instance2, service_instance3 ...\]，列表中元素"service_instance"对象即为服务管理章节描述的可调用服务接口。
  
- 支持按照检索参数查询服务列表，返回满足检索条件的服务list，检索参数如[表1]所示。
- 在查询列表时，返回list的同时，默认会打印模型列表的详细信息，如[表2]和[表3]所示。
 表1查询检索参数说明 
| 参数           | 是否必选 | 参数类型    | 描述                                                                                                     |
|:---|:---|:---|:---|
| session      | 是    | Object  | 会话对象，初始化方法见[Session鉴权](https://support.huaweicloud.com/sdkreference-modelarts/modelarts_04_0123.html)。 |
| is_show      | 否    | Boolean | 是否打印出服务对象信息，默认为"True"。                                                                                 |
| service_id   | 否    | String  | 服务ID，默认不过滤服务ID。                                                                                        |
| service_name | 否    | String  | 服务名称，默认不过滤服务名。                                                                                         |
| infer_type   | 否    | String  | 推理方式，取值为：real-time/batch/edge，默认不过滤推理方式。                                                               |
| offset       | 否    | Integer | 分页列表的起始页，默认为"0"。                                                                                       |
| limit        | 否    | Integer | 指定每一页返回的最大条目数，默认为"1000"。                                                                               |
| sort_by      | 否    | String  | 指定排序字段，可选"publish_at"、"service_name"，默认可选"publish_at"。                                                 |
| order        | 否    | String  | 排序方式，可选"asc"或"desc"，代表递增排序及递减排序，默认为："desc"。                                                            |
| model_id     | 否    | String  | 模型ID，默认不过滤模型ID。                                                                                        |
   
 表2get_service_list返回参数说明 
| 参数          | 参数类型        | 描述                                              |
|:---|:---|:---|
| total_count | Integer     | 不分页的情况下，符合查询条件的总服务数量。                           |
| count       | Integer     | 当前查询结果的服务数量，不设置offset、limit查询参数时，count与total相同。 |
| services    | service结构数组 | 查询到的服务集合。                                       |
   
 表3service结构 
| 参数               | 参数类型    | 描述                                                             |
|:---|:---|:---|
| service_id       | String  | 服务ID。                                                          |
| service_name     | String  | 服务名称。                                                          |
| description      | String  | 服务描述。                                                          |
| tenant           | String  | 服务归属租户。                                                        |
| project          | String  | 服务归属项目。                                                        |
| owner            | String  | 服务归属用户。                                                        |
| publish_at       | Number  | 服务最新的发布时间，距'1970.1.1 0:0:0 UTC'的毫秒数。                           |
| infer_type       | String  | 推理方式，取值为：real-time/batch/edge。                                 |
| status           | String  | 服务状态，取值为：running/deploying/concerning/failed/stopped/finished。 |
| progress         | Integer | 部署进度，当状态是deploying时，返回。                                        |
| invocation_times | Number  | 服务的总调用次数。                                                      |
| failed_times     | Number  | 服务调用失败次数。                                                      |
| is_shared        | Boolean | 是否是订阅的服务。                                                      |
| shared_count     | Number  | 订阅的服务数。                                                        |
   
