Update Information About a Pre-provisioning Template with a Specified ID
Function
This API is used by an application to update a pre-provisioning template with a specified ID on the IoT platform.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
PUT /v5/iot/{project_id}/provisioning-templates/{template_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Parameter description: project ID. For details, see Obtaining a Project ID. |
template_id |
Yes |
String |
Pre-provisioning Template ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. In the returned response header, X-Subject-Token is the desired user token. For details about how to obtain the token, see Token Authentication. |
Instance-Id |
No |
String |
Parameter description: instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
description |
No |
String |
Parameter description: description of the pre-provisioning template. Value: The value can contain a maximum of 2,048 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
template_body |
No |
ProvisioningTemplateBody object |
Parameter description: detailed content of the pre-provisioning template in JSON format. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
parameters |
Yes |
Object |
Parameter description: pre-provisioning template parameters, which can be extracted from the user fields of pre-provisioning device certificates. The configuration format is {"parameter":{"type":"String"}}. Huawei Cloud IoT platform defines the parameters that can be declared and referenced in pre-provisioning templates. A device certificate must contain the parameters referenced in the template.
type indicates the parameter type. Currently, only String is supported. Configuration example: '{"iotda::certificate::country":{"type":"String"}, "iotda::certificate::organization":{"type":"String"}, "iotda::certificate::organizational_unit":{"type":"String"}, "iotda::certificate::distinguished_name_qualifier":{"type":"String"}, "iotda::certificate::state_name":{"type":"String"}, "iotda::certificate::common_name":{"type":"String"}, "iotda::certificate::serial_number":{"type":"String"}}' |
resources |
Yes |
TemplateResource object |
Structure of device resources of a pre-provisioning template. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
device |
Yes |
DeviceResource object |
Structure of device resource details of a pre-provisioning template. |
policy |
No |
PolicyResource object |
Structure of device policy resource details of a pre-provisioning template. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
device_name |
No |
ParameterRef object |
Device name. |
node_id |
Yes |
ParameterRef object |
Node ID. |
product_id |
Yes |
Object |
Parameter description: ID of the product to which the device belongs. The value can be a static string ID or dynamic parameters referenced from the template.
|
tags |
No |
Array of TagRef objects |
Parameter description: list of tags bound to a device. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tag_key |
No |
Object |
Parameter description: tag key name. The value can be a static string or dynamic parameters referenced from the template.
|
tag_value |
No |
Object |
Parameter description: tag value. The value can be a static string or dynamic parameters referenced from the template.
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
template_id |
String |
Parameter description: ID of the pre-provisioning template. |
template_name |
String |
Parameter description: name of the pre-provisioning template. Value: The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. |
description |
String |
Parameter description: description of the pre-provisioning template. Value: The value can contain a maximum of 2,048 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
template_body |
ProvisioningTemplateBody object |
Parameter description: detailed content of the pre-provisioning template in JSON format. |
create_time |
String |
Time when a pre-provisioning template is created on the IoT platform. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
update_time |
String |
Time when the pre-provisioning template is updated in the IoT platform. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
Parameter |
Type |
Description |
---|---|---|
parameters |
Object |
Parameter description: pre-provisioning template parameters, which can be extracted from the user fields of pre-provisioning device certificates. The configuration format is {"parameter":{"type":"String"}}. Huawei Cloud IoT platform defines the parameters that can be declared and referenced in pre-provisioning templates. A device certificate must contain the parameters referenced in the template.
type indicates the parameter type. Currently, only String is supported. Configuration example: '{"iotda::certificate::country":{"type":"String"}, "iotda::certificate::organization":{"type":"String"}, "iotda::certificate::organizational_unit":{"type":"String"}, "iotda::certificate::distinguished_name_qualifier":{"type":"String"}, "iotda::certificate::state_name":{"type":"String"}, "iotda::certificate::common_name":{"type":"String"}, "iotda::certificate::serial_number":{"type":"String"}}' |
resources |
TemplateResource object |
Structure of device resources of a pre-provisioning template. |
Parameter |
Type |
Description |
---|---|---|
device |
DeviceResource object |
Structure of device resource details of a pre-provisioning template. |
policy |
PolicyResource object |
Structure of device policy resource details of a pre-provisioning template. |
Parameter |
Type |
Description |
---|---|---|
device_name |
ParameterRef object |
Device name. |
node_id |
ParameterRef object |
Node ID. |
product_id |
Object |
Parameter description: ID of the product to which the device belongs. The value can be a static string ID or dynamic parameters referenced from the template.
|
tags |
Array of TagRef objects |
Parameter description: list of tags bound to a device. |
Parameter |
Type |
Description |
---|---|---|
tag_key |
Object |
Parameter description: tag key name. The value can be a static string or dynamic parameters referenced from the template.
|
tag_value |
Object |
Parameter description: tag value. The value can be a static string or dynamic parameters referenced from the template.
|
Example Requests
-
Updates a pre-provisioning template.
PUT https://{endpoint}/v5/iot/{project_id}/provisioning-templates/{template_id} { "description" : "myTemplate", "template_body" : { "parameters" : { "iotda::certificate::country" : { "type" : "String" }, "iotda::certificate::organization" : { "type" : "String" }, "iotda::certificate::organizational_unit" : { "type" : "String" }, "iotda::certificate::distinguished_name_qualifier" : { "type" : "String" }, "iotda::certificate::state_name" : { "type" : "String" }, "iotda::certificate::common_name" : { "type" : "String" }, "iotda::certificate::serial_number" : { "type" : "String" } }, "resources" : { "device" : { "device_name" : { "ref" : "iotda::certificate::organization" }, "node_id" : { "ref" : "iotda::certificate::common_name" }, "product_id" : { "ref" : "iotda::certificate::organization" }, "tags" : [ { "tag_key" : { "ref" : "iotda::certificate::organization" }, "tag_value" : { "ref" : "iotda::certificate::organizational_unit" } } ] }, "policy" : { "policy_ids" : [ "5c90fa7d3c4e4405e8525079" ] } } } }
-
Updates a pre-provisioning template with some custom parameters.
PUT https://{endpoint}/v5/iot/{project_id}/provisioning-templates/{template_id} { "description" : "myTemplate2", "template_body" : { "parameters" : { "iotda::certificate::country" : { "type" : "String" }, "iotda::certificate::organization" : { "type" : "String" }, "iotda::certificate::organizational_unit" : { "type" : "String" }, "iotda::certificate::distinguished_name_qualifier" : { "type" : "String" }, "iotda::certificate::state_name" : { "type" : "String" }, "iotda::certificate::common_name" : { "type" : "String" }, "iotda::certificate::serial_number" : { "type" : "String" } }, "resources" : { "device" : { "device_name" : { "ref" : "iotda::certificate::organization" }, "node_id" : { "ref" : "iotda::certificate::common_name" }, "product_id" : "642bf260f2f9030e44210d8d", "tags" : [ { "tag_key" : "myTagKey", "tag_value" : "myTagValue" } ] }, "policy" : { "policy_ids" : [ "5c90fa7d3c4e4405e8525079" ] } } } }
Example Responses
Status code: 200
OK
{ "template_id" : "5c90fa7d3c4e4405e8525079", "template_name" : "myTemplate", "description" : "myTemplate", "template_body" : { "parameters" : { "iotda::certificate::country" : { "type" : "String" }, "iotda::certificate::organization" : { "type" : "String" }, "iotda::certificate::organizational_unit" : { "type" : "String" }, "iotda::certificate::distinguished_name_qualifier" : { "type" : "String" }, "iotda::certificate::state_name" : { "type" : "String" }, "iotda::certificate::common_name" : { "type" : "String" }, "iotda::certificate::serial_number" : { "type" : "String" } }, "resources" : { "device" : { "device_name" : { "ref" : "iotda::certificate::organization" }, "node_id" : { "ref" : "iotda::certificate::common_name" }, "product_id" : { "ref" : "iotda::certificate::organization" } }, "policy" : { "policy_ids" : [ "5c90fa7d3c4e4405e8525079" ] } } }, "create_time" : "20230810T070547Z", "update_time" : "20230810T070547Z" }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot