
# 创建边缘节点
#### 功能介绍
创建边缘节点
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/IoTEdge/doc?api=CreateEdgeNode)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### URI
POST /v2/{project_id}/edge-nodes
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                        |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID。获取方法请参见 [获取项目ID](https://support.huaweicloud.com/api-iotedge/iotedge_api_0032.html)。 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。通过调用IAM服务 [获取IAM用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取，接口返回的响应消息头中"X-Subject-Token"就是需要获取的用户Token。简要的获取方法样例请参见 [Token认证](https://support.huaweicloud.com/api-iothub/iot_06_v5_0091.html#section0)。 |
   
表3请求Body参数 
| 参数                    | 是否必选 | 参数类型                                                                                                                          | 描述                                                                        |
|:---|:---|:---|:---|
| edge_node_id          | 否    | String                                                                                                                        | 边缘节点ID                                                                    |
| name                  | 是    | String                                                                                                                        | 边缘节点名称，只允许中、数字、英文大小写、中划线、下划线                                              |
| type                  | 是    | String                                                                                                                        | 边缘节点类型：lite\|advanced\|standard。lite表示基础版边缘节点，advanced或standard表示专业版边缘节点。 |
| verify_code           | 否    | String                                                                                                                        | 边缘节点注册使用的验证码，如果不输入则平台随机生成。                                                |
| time_out              | 否    | Integer                                                                                                                       | 验证码的有效时间单位秒，默认1800秒，范围为1\~864000，过期后平台会随机生成。                              |
| arch                  | 否    | String                                                                                                                        | 边缘节点系统架构。包括：arm64，arm32，x86_64。                                           |
| os_type               | 否    | String                                                                                                                        | 边缘节点系统类型。包括：generalLinux通用系统，openHarmony鸿蒙系统。                             |
| instance_id           | 否    | String                                                                                                                        | 实例ID。物理多租下各实例的唯一标识，一般华为云租户无需携带该参数，仅在物理多租场景下从管理面访问API时需要携带该参数。             |
| space_id              | 否    | String                                                                                                                        | 资源空间id，对应IOTDA云服务接口参数中的app_id。                                            |
| resource_ids          | 否    | Array of strings                                                                                                              | 资源id列表，创建节点时需绑定已购买的资源包，资源可叠加。                                             |
| security_level        | 否    | String                                                                                                                        | 节点的安全等级，MEDIUM表示本地明文存储，HIGH表示本地加密存储。                                      |
| reliability_level     | 否    | String                                                                                                                        | 节点的可靠性等级，LOW表示中级别，MEDIUM表示高级别。详细功能请参考"用户指南\>管理边缘节点\>注册节点"。                |
| storage_period        | 否    | Integer                                                                                                                       | 节点的存储周期，默认0天，取值范围0\~7天，0天则不存储。                                            |
| ai_card_type          | 否    | String                                                                                                                        | AI加速卡类型，如昇腾AI加速卡NPU、图像处理加速卡GPU。                                           |
| npu_library_path      | 否    | String                                                                                                                        | npu驱动动态库路径                                                                |
| base_path             | 否    | [BasePathDTO] object                         | 节点根目录。                                                                    |
| log_configs           | 否    | Array of [LogConfigDTO] objects             | 边缘节点在IEF日志配置参数，仅专业版支持。                                                    |
| apps                  | 否    | Array of [EdgeAppInstanceDTO] objects | 需要自动安装的边缘应用。此处可填写控制台"应用管理"页面中列出的业务应用与驱动应用。                                |
| network_access_point  | 否    | String                                                                                                                        | 网络接入方式类型                                                                  |
| hardware_model        | 否    | String                                                                                                                        | 网关型号                                                                      |
| offline_cache_configs | 否    | [OfflineCacheConfigsDTO] object   | 边缘节点离线缓存配置                                                                |
| device_auth_info      | 否    | [DeviceAuthInfoDTO] object             | 边缘节点设备认证方式                                                                |
| device_data_format    | 否    | String                                                                                                                        | 节点使用的数据格式，默认为iotda物模型1.0格式，可以选择属性平铺数据格式flat_json                          |
| automatic_upgrade     | 否    | String                                                                                                                        | 自动升级系统应用的节点开关，默认为关闭：OFF，IMMEDIATE表示节点开关打开                                 |
| device_data_record    | 否    | [DeviceDataRecord] object               | 边缘节点设备数据上报打印配置                                                            |
| metric_report         | 否    | String                                                                                                                        | omagent监控运维工具是否上报指标                                                       |
| iotda_south_access    | 否    | String                                                                                                                        | iotda的南向接入地址                                                              |
   
 表4BasePathDTO 
| 参数               | 是否必选 | 参数类型   | 描述        |
|:---|:---|:---|:---|
| log_base_path    | 否    | String | 节点日志根目录   |
| config_base_path | 否    | String | 节点配置根目录   |
| db_base_path     | 否    | String | 节点数据存储根目录 |
   
 表5LogConfigDTO 
| 参数            | 是否必选 | 参数类型    | 描述                                                                                               |
|:---|:---|:---|:---|
| size          | 否    | Integer | 应用日志文件大小限制，单位MB，默认50，取值范围10-1000                                                                 |
| level         | 否    | String  | 应用日志级别，可选项：on/off/trace/debug/info/warn/error/fatal，当type为LTS时有效。当选择非on/off的选项时，将只采集大于等于指定级别的日志。 |
| rotate_num    | 否    | Integer | 应用日志rotate个数，默认5，取值范围1-10                                                                        |
| rotate_period | 否    | String  | 应用日志rotate周期，可选项： daily/monthly/weekly/yearly                                                    |
| type          | 否    | String  | LTS:将日志发送到LTS, local 本地日志                                                                        |
| component     | 否    | String  | app:部署到边缘设备上的应用的日志, system 边缘设备上系统的日志                                                            |
   
 表6EdgeAppInstanceDTO 
| 参数          | 是否必选 | 参数类型   | 描述                                |
|:---|:---|:---|:---|
| edge_app_id | 是    | String | 边缘应用id，只允许数字、英文小写、中划线，且必须以字母或数字结尾 |
| app_version | 否    | String | 边缘应用版本，只允许数字、英文小写、中划线，且必须以字母或数字结尾 |
   
 表7OfflineCacheConfigsDTO 
| 参数                  | 是否必选 | 参数类型    | 描述                                                                |
|:---|:---|:---|:---|
| publish_order       | 否    | String  | 数据上报优先级，可选项：realtime_first实时数据优先 sequential按时序上报，默认realtime_first |
| period              | 否    | Integer | 节点离线缓存数据的储存天数，默认7，取值范围-1\~14，-1表示存储天数没有限制                         |
| capacity            | 否    | Integer | 节点离线缓存容量，单位MB，默认2048，取值范围500-1048576                              |
| channel_cache_state | 否    | String  | 路由转发开启离线缓存                                                        |
   
 表8DeviceAuthInfoDTO 
| 参数          | 是否必选 | 参数类型                                                                                                                          | 描述                                            |
|:---|:---|:---|:---|
| auth_type   | 是    | String                                                                                                                        | 边缘节点认证方式，不填默认为密钥认证接入方式(SECRET)。               |
| fingerprint | 否    | String                                                                                                                        | 证书指纹，认证类型使用证书认证接入(CERTIFICATES)需填写该字段。        |
| local_path  | 否    | [CertificateLocalPathDTO] object | 证书文件的本地存储路径，认证类型使用证书认证接入(CERTIFICATES)需填写该结构体 |
   
 表9CertificateLocalPathDTO 
| 参数        | 是否必选 | 参数类型   | 描述             |
|:---|:---|:---|:---|
| cert_path | 是    | String | 节点数字证书的本地存储路径。 |
| key_path  | 是    | String | 证书私钥的本地存储路径。   |
   
 表10DeviceDataRecord 
| 参数         | 是否必选 | 参数类型    | 描述                            |
|:---|:---|:---|:---|
| disk_quota | 是    | Integer | 磁盘配额，单位MB，参考值，只能保证在这个值左右      |
| age        | 是    | Integer | 老化时间，日志压缩文件名时间戳老于这个时间就会发生老化删除 |
| state      | 是    | String  | 配置开关，true启用数据打印，false不启用数据打印  |
   
#### 响应参数
**状态码：201**
表11响应Body参数 
| 参数                 | 参数类型                                                                                                             | 描述                                                                        |
|:---|:---|:---|
| edge_node_id       | String                                                                                                           | 边缘节点ID                                                                    |
| name               | String                                                                                                           | 边缘节点名称                                                                    |
| instance_id        | String                                                                                                           | 实例ID。物理多租下各实例的唯一标识，一般华为云租户无需携带该参数，仅在物理多租场景下从管理面访问API时需要携带该参数。             |
| space_id           | String                                                                                                           | 资源空间id，对应IOTDA云服务接口参数中的app_id。                                            |
| product_id         | String                                                                                                           | 边缘节点关联的产品ID，用于唯一标识一个产品模型。                                                 |
| product_name       | String                                                                                                           | 边缘节点关联的产品名称。                                                              |
| state              | String                                                                                                           | 边缘节点状态UNINSTALLED\|INSTALLED\|OFFLINE\|ONLINE\|DELETING\|FROZEN           |
| type               | String                                                                                                           | 边缘节点类型：lite\|advanced\|standard。lite表示基础版边缘节点，advanced或standard表示专业版边缘节点。 |
| installer_version  | String                                                                                                           | 安装文件版本                                                                    |
| base_path          | [BasePathDTO] object           | 节点根目录配置                                                                   |
| resource_ids       | Array of strings                                                                                                 | 资源id列表，创建节点时需绑定已购买的资源包，可以叠加节点功能。                                          |
| ips                | Array of strings                                                                                                 | 边缘节点ip列表                                                                  |
| create_time        | String                                                                                                           | 边缘节点创建时间                                                                  |
| hardware_model     | String                                                                                                           | 注册节点网关配置                                                                  |
| device_data_format | String                                                                                                           | 节点使用的数据格式，默认为iotda物模型1.0格式，可以选择属性平铺数据格式flat_json                          |
| automatic_upgrade  | String                                                                                                           | 自动升级系统应用的节点开关，默认为关闭：OFF，IMMEDIATE表示节点开关打开                                 |
| device_data_record | [DeviceDataRecord] object | 边缘节点设备数据上报打印配置                                                            |
| metric_report      | String                                                                                                           | omagent监控运维工具是否上报指标                                                       |
| iotda_south_access | String                                                                                                           | iotda南向接入地址                                                               |
| os_type            | String                                                                                                           | 边缘节点系统类型。包括：generalLinux通用系统，openHarmony鸿蒙系统。                             |
   
 表12BasePathDTO 
| 参数               | 参数类型   | 描述        |
|:---|:---|:---|
| log_base_path    | String | 节点日志根目录   |
| config_base_path | String | 节点配置根目录   |
| db_base_path     | String | 节点数据存储根目录 |
   
 表13DeviceDataRecord 
| 参数         | 参数类型    | 描述                            |
|:---|:---|:---|
| disk_quota | Integer | 磁盘配额，单位MB，参考值，只能保证在这个值左右      |
| age        | Integer | 老化时间，日志压缩文件名时间戳老于这个时间就会发生老化删除 |
| state      | String  | 配置开关，true启用数据打印，false不启用数据打印  |
   
#### 请求示例
```
{
  "edge_node_id" : "string",
  "name" : "test-node",
  "type" : "string",
  "verify_code" : "string",
  "time_out" : 1800,
  "arch" : "string",
  "instance_id" : "string",
  "space_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
  "resource_ids" : [ "jeQDJQZltU8iKgFFoW060F5SGZka" ],
  "security_level" : "HIGH",
  "reliability_level" : "LOW",
  "storage_period" : 0,
  "ai_card_type" : "UNEQUIPPED",
  "npu_library_path" : "/usr/local/Ascend/driver/lib64/",
  "base_path" : {
    "log_base_path" : "string",
    "config_base_path" : "string",
    "db_base_path" : "string"
  },
  "log_configs" : [ {
    "size" : 1000,
    "level" : "string",
    "rotate_num" : 10,
    "rotate_period" : "string",
    "type" : "LTS",
    "component" : "string"
  } ],
  "apps" : [ {
    "edge_app_id" : "string",
    "app_version" : "string"
  } ],
  "hardware_model" : "string",
  "offline_cache_configs" : {
    "publish_order" : "realtime_first",
    "period" : 7,
    "capacity" : 2048
  },
  "device_auth_info" : {
    "auth_type" : "CERTIFICATES",
    "fingerprint" : "8D903AC66E0ECA7843B6EEFB50F770537C051EC3C976FD3ED3AFBECC1CC92A29",
    "local_path" : {
      "cert_path" : "/opt/device-cert/cert.pem",
      "key_path" : "/opt/device-cert/key.pem"
    }
  },
  "automatic_upgrade" : "OFF"
}
```
#### 响应示例
**状态码：201**
Created
```
{
  "edge_node_id" : "string",
  "name" : "string",
  "instance_id" : "string",
  "space_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
  "product_id" : "string",
  "product_name" : "jeQDJQZltU8iKgFFoW060F5SGZka",
  "state" : "string",
  "type" : "string",
  "installer_version" : "string",
  "base_path" : {
    "log_base_path" : "string",
    "config_base_path" : "string",
    "db_base_path" : "string"
  },
  "resource_ids" : [ "jeQDJQZltU8iKgFFoW060F5SGZka" ],
  "ips" : [ "string" ],
  "create_time" : "2020-05-28T11:31:29.740Z",
  "hardware_model" : "string",
  "device_data_format" : "iotda_1.0",
  "automatic_upgrade" : "OFF",
  "iotda_south_access" : "100.94.18.123:8883",
  "os_type" : "generalLinux"
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 201 | Created               |
| 401 | Bad Request           |
| 500 | Internal Server Error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-iotedge/ErrorCode.html)。
