Create Asset Tree


Create an asset tree as well as its root node.

Operation Permissions

Required Authorization Required Operation Permission
Asset Tree Full Access

Request Format

POST https://{apigw-address}/asset-tree-service/v2.1/asset-trees?action=create

Request Parameters (URI)

Name Location (Path/Query) Mandatory/Optional Data Type Description
orgId Query Mandatory String The organization ID which the Asset belongs to. How to get orgId>>

Request Parameters (Body)

Name Mandatory/Optional Data Type Description
asset Mandatory Asset Struct The required data when creating a root node asset. For more details, see Asset Struct.
tree Optional TreeCreateVo Struct The details of the asset tree to be created. For more details, see TreeCreateVo Struct.

Asset Struct

Name Mandatory/Optional Data Type Description
modelID Mandatory String The model ID. How to get modelID>>
name Mandatory StringI18n Specify the asset’s name in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct.
timezone Mandatory String
  • The timezone where the asset is located.
  • Use the “+08:00” format for time zones that do not support Daylight Saving Time (DST).
  • Use the “Asia/Shanghai” format for time zones that support DST.

For details, see Timezone representation.

description Optional String The asset description.
attributes Optional Map Attributes of the model which the asset belongs to. The Key is the attribute ID, which is of String type. The Value type depends on the attribute defined in the Model. For details, see attributes representation.
tags Optional Map User-defined tags. (The Key and Value are of String type.) For details, see How to use tag.

TreeCreateVo Struct

Name Mandatory/Optional Data Type Description
name Mandatory StringI18n Specify the asset tree’s name in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct.
tags Optional Map User-defined tags. The Key and Value are of String type. How to use tags>>

Response Parameters

Name Data Type Description
data String The created asset tree ID.

Error Codes

Code Message Description
17772 The quota of tree reaches ceiling Number of trees already reaches maximum of the OU.
99400 Invalid arguments The request parameter is invalid. Check the request parameters.
99500 System error Internal server error. Contact EnOS support.

Samples

Request Sample

url: https://{apigw-address}/asset-tree-service/v2.1/asset-trees?action=create&orgId=yourOrgId
method: POST
requestBody:
{
    "asset":{
        "modelId":"yourModelId",
        "name":{
            "defaultValue":"Name"
        },
        "timezone":"+12:00",
        "description":"Example of description"
    },
    "tree":{
        "name":{
            "defaultValue":"Name"
        }
    }
}

Return Sample

{
  "msg": "OK",
  "code": 0,
  "data": "yourAssetTreeId",
  "requestId": "bb4f8c40-604a-451e-83bd-99cfba6bd53e"
}

SDK Samples


You can access the SDK samples for Asset Tree Service on GitHub: