
# 查询设备列表
#### 功能介绍
专业版HiLens控制台设备管理，根据用户请求条件筛选，查询用户注册的设备信息，以列表形式返回。
#### URI
GET /v3/{project_id}/ai-mgr/nodes
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                   |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID。获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-hilens/hilens_07_0020.html) |
表2Query参数 
| 参数              | 是否必选 | 参数类型    | 描述                                                              |
|:---|:---|:---|:---|
| offset          | 否    | Integer | 查询的起始位置，取值范围为非负整数，默认为0                                          |
| limit           | 否    | Integer | 每页显示的条目数量，取值范围1\~100，默认为100                                     |
| name            | 否    | String  | 设备名称，模糊匹配，只允许中文字符、英文字母、数字、下划线、中划线，最大长度64                        |
| workspace_id    | 否    | String  | 工作空间ID，默认为注册账号/子账号的default工作空间，可通过专业版HiLens控制台展开工作空间列表获取到工作空间ID |
| app_name        | 否    | String  | 应用名称，模糊匹配，只允许英文小写字母、数字、中划线，最大长度32, 英文小写字母或数字开头和结尾               |
| tags            | 否    | String  | 标签的key和value通过点连接，多个标签通过逗号连接，如：tags=key1.value1,key2.value2     |
| provider        | 否    | String  | 服务提供者：ief或hilens。不传会查询全部服务类型的设备列表                               |
| cluster_id      | 否    | String  | 集群ID，若值为0会过滤出不隶属任何集群的设备                                         |
| status          | 否    | String  | 状态                                                              |
| active_status   | 否    | String  | 设备激活状态，分别是未激活（INACTIVE）、已激活（ACTIVATED）、已到期（EXPIRED）             |
| is_cluster_node | 否    | String  | 不包含#\~\^$%\&\*\<\>{}\[\]'等特殊字符                                  |
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                 |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 租户Token。获取方法请参见[获取Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html) |
   
#### 响应参数
**状态码： 200**
表4响应Body参数 
| 参数    | 参数类型                                                                      | 描述        |
|:---|:---|:---|
| count | Integer                                                                   | 满足条件的设备总数 |
| nodes | Array of [NodeResponse] objects | 设备详情      |
   
 表5NodeResponse 
| 参数                       | 参数类型                                                                                      | 描述                                                                                                                                                     |
|:---|:---|:---|
| id                       | String                                                                                    | 设备ID                                                                                                                                                   |
| name                     | String                                                                                    | 设备名称，只允许中文字符、英文字母、数字、下划线、中划线，最大长度64                                                                                                                    |
| description              | String                                                                                    | 设备描述，最大长度255，不允许\^, \~, ＃, $, %, \&, \*, \<, \>, (, ), \[, \], {, }, ', ", \\                                                                          |
| created_at               | String                                                                                    | 产生时间，如2021-10-15 14:45:22 GMT+08:00                                                                                                                    |
| cluster_id               | String                                                                                    | 当该设备处于集群时，显示设备所属的集群ID                                                                                                                                  |
| cluster_node_state       | String                                                                                    | 设备所处集群状态，集群创建（cluster_create）、集群删除（cluster_delete）、添加集群工作节点设备（cluster_add_nodes）、删除集群工作节点设备（cluster_delete_node）、集群节点设备状态更新（cluster_node_state_update） |
| cluster_node_type        | String                                                                                    | 当该设备处于集群时，显示所属的集群设备类型。 - cluster_controller 控制设备 - cluster_worker 工作设备                                                                                 |
| firmware_name            | String                                                                                    | 固件名称。可包含大小写字母、数字、下划线、中划线,长度不超过60字符。必须以字母开头,字母或数字结尾                                                                                                     |
| upgrade_firmware_version | String                                                                                    | 固件正在升级的版本                                                                                                                                              |
| firmware_status          | Integer                                                                                   | 固件升级状态，1、2、3分别代表升级中，升级失败，升级成功                                                                                                                          |
| firmware_upgrade_record  | Array of [FirmwareUpdateRecord] objects | 该设备上升级过的固件记录                                                                                                                                           |
| state                    | String                                                                                    | 设备状态：UNCONNECTED(未注册)、RUNNING(运行中)、FAIL(故障)、STOPPED(停用)、UPGRADING(升级中)、FREEZE(冻结)                                                                      |
| type                     | String                                                                                    | 设备类型                                                                                                                                                   |
| active_status            | String                                                                                    | 设备激活状态，未激活（INACTIVE）和已激活（ACTIVATED）                                                                                                                    |
| cpu                      | Integer                                                                                   | 设备CPU个数                                                                                                                                                |
| gpu_num                  | Integer                                                                                   | 设备GPU个数                                                                                                                                                |
| npu_num                  | Integer                                                                                   | 设备NPU个数                                                                                                                                                |
| host_ips                 | Array of strings                                                                          | 主机IP列表                                                                                                                                                 |
| tags                     | Object                                                                                    | 设备标签对列表                                                                                                                                                |
| deployment_num           | Integer                                                                                   | 节点中部署的数量                                                                                                                                               |
   
 表6FirmwareUpdateRecord 
| 参数                    | 参数类型    | 描述     |
|:---|:---|:---|
| firmware_name         | String  | 固件名称   |
| firmware_version      | String  | 固件版本   |
| firmware_size         | Integer | 固件大小   |
| firmware_upgrade_time | String  | 固件升级时间 |
| status                | Integer | 固件升级状态 |
   
#### 请求示例
分页查询HiLens控制台专业版设备列表
```
GET https://{endpoint}/v3/{project_id}/ai-mgr/nodes?offset=0&limit=10&provider=hilens
Request Header:  Content-Type: application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
```
#### 响应示例
**状态码： 200**
请求成功
```
{
  "count" : 26,
  "nodes" : [ {
    "firmware_status" : null,
    "cluster_node_type" : "cluster_controller",
    "cpu" : 16,
    "created_at" : "2022-02-16 11:01:23 GMT+08:00",
    "type" : "General ARM Device",
    "gpu_num" : 0,
    "firmware_upgrade_record" : null,
    "host_ips" : [ "10.90.47.209" ],
    "tags" : { },
    "firmware_name" : "HiLens_Device_Agent",
    "cluster_id" : "hilens-cf7d36a328334a7599f4004fe917adcb",
    "active_status" : "ACTIVATED",
    "npu_num" : 1,
    "name" : "hilens-209",
    "id" : "hilens-989c34eeaeda4a5380b7d9f2b101f7f1",
    "state" : "RUNNING",
    "upgrade_firmware_version" : null,
    "cluster_node_state" : "RUNNING"
  }, {
    "firmware_status" : null,
    "cluster_node_type" : null,
    "cpu" : 0,
    "created_at" : "2022-02-16 10:33:05 GMT+08:00",
    "type" : "General ARM Device",
    "gpu_num" : 0,
    "firmware_upgrade_record" : null,
    "host_ips" : [ ],
    "tags" : { },
    "firmware_name" : null,
    "cluster_id" : null,
    "active_status" : "INACTIVE",
    "npu_num" : 0,
    "name" : "ddp-test111",
    "id" : "hilens-1027a354fd1c4f2b81fba6d6081ce19f",
    "state" : "UNCONNECTED",
    "upgrade_firmware_version" : null,
    "cluster_node_state" : null
  }, {
    "firmware_status" : null,
    "cluster_node_type" : null,
    "cpu" : 0,
    "created_at" : "2022-02-13 21:25:32 GMT+08:00",
    "type" : "General x86 Device",
    "gpu_num" : 0,
    "firmware_upgrade_record" : null,
    "host_ips" : [ ],
    "tags" : { },
    "firmware_name" : null,
    "cluster_id" : null,
    "active_status" : "INACTIVE",
    "npu_num" : 0,
    "name" : "my-test-device",
    "id" : "hilens-3f665c35ea3b471880c1499e05a3c630",
    "state" : "UNCONNECTED",
    "upgrade_firmware_version" : null,
    "cluster_node_state" : null
  }, {
    "firmware_status" : null,
    "cluster_node_type" : "cluster_controller",
    "cpu" : 16,
    "created_at" : "2022-02-11 17:07:32 GMT+08:00",
    "type" : "General ARM Device",
    "gpu_num" : 0,
    "firmware_upgrade_record" : null,
    "host_ips" : [ "10.90.47.208" ],
    "tags" : { },
    "firmware_name" : "HiLens_Device_Agent",
    "cluster_id" : "hilens-cf7d36a328334a7599f4004fe917adcb",
    "active_status" : "ACTIVATED",
    "npu_num" : 1,
    "name" : "hilens-208",
    "id" : "hilens-4f7ff1e5da1c4051861e50b336efde0b",
    "state" : "RUNNING",
    "upgrade_firmware_version" : null,
    "cluster_node_state" : "FAIL"
  }, {
    "firmware_status" : null,
    "cluster_node_type" : null,
    "cpu" : 48,
    "created_at" : "2022-02-10 20:44:43 GMT+08:00",
    "type" : "General x86 Device",
    "gpu_num" : 3,
    "firmware_upgrade_record" : null,
    "host_ips" : [ "10.216.139.114" ],
    "tags" : { },
    "firmware_name" : "HiLens_Device_Agent_x86",
    "cluster_id" : null,
    "active_status" : "ACTIVATED",
    "npu_num" : 0,
    "name" : "egypt-x86-test-114",
    "id" : "hilens-e2423376a61e4265a2ffd253a3493b35",
    "state" : "FAIL",
    "upgrade_firmware_version" : null,
    "cluster_node_state" : null
  } ]
}
```
#### 状态码
| 状态码 | 描述       |
|:---|:---|
| 200 | 请求成功     |
| 401 | 认证不通过    |
| 403 | 拒绝执行请求   |
| 404 | 请求的资源不存在 |
| 500 | 服务器内部错误  |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-hilens/ErrorCode.html)。
