Create Logical Asset (Preview)


Create a logical asset.

Operation Permissions

Required Authorization

Required Operation Permission

Asset Tree Management

Full Access

Request Format

POST https://{apigw-address}/asset-service/v2.1/logical-assets?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

assetInstance

Mandatory

AssetCreateVo Struct

The details needed to create the logical asset. For more information, see below.

AssetCreateVo Struct

Name

Mandatory/Optional

Data Type

Description

modelId

Mandatory

String

The model ID which the asset belongs to. How to get modelID>>

name

Mandatory

StringI18n

The asset name. For more details on the structure and locales supported, see Internationalized name struct.

timezone

Mandatory

String

Timezone of the asset’s location. For details, see timezone representation.

description

Optional

String

The asset description.

attributes

Depends on the model feature definition

Map (Key is of String type, and Value depends on the attribute defined in the model)

Attributes of the model which the asset belongs to. Key is the attribute ID. For more information, see attributes representation.

tags

Optional

Map (Key and Value are of String type)

User-defined tags. For more information, see How to use tag.

Response Parameters

Name

Data Type

Description

data

String

The ID of the created logical asset.

Error Codes

Code

Message

Description

17946

Quota limit error

The assets under this OU have exceeded the upper limit.

17986

TSL instance validation failed

The verification of the asset using the model failed.

Samples

Request Sample

url: https://{apigw-address}/asset-service/v2.1/logical-assets?action=create&orgId=yourOrgId
method: POST
requestBody:
{
  "assetInstance": {
       "modelId": "model_001",
       "name": {
           "defaultValue": "instanceName",
           "i18nValue": {
                    "en_US": "English name ",
                    "zh_CN": "Chinese name"
                        }
               },
       "description": "description",
       "attributes": {
         "color": "blue",
         "number": 135
       },
       "timezone": "+08:00",
       "tags": {
           "year": "2000",
           "author": "authorName"
               }
           }
}

Return Sample

{
  "code": 0,
  "msg": "OK",
  "data": "HfzFPn1H",
  "requestId": "fa11232e-7e45-4176-a382-963c1240a27f"
}

Java SDK Sample

public class CreateLogicAssetTest {

    private static String accessKey = "yourAccessKey";
    private static String secretKey = "yourSecretKey";
    private static String orgId = "yourOrgId";
    private static String serverUrl = "https://{apigw-address}";

    @Test
    public void testCreateAssetNode() {
        CreateLogicAssetRequest request = new CreateLogicAssetRequest();
        request.setOrgId(orgId);
        String modelId = "model_001";//enter the model ID
        Map < String, String > i18nValue = new HashMap();
        I18nVo name = new I18nVo();
        name.setDefaultValue("instanceName");
        name.setI18nValue(i18nValue);
        AssetCreateVo asset = new AssetCreateVo();
        asset.setModelId(modelId);
        asset.setName(name);
        asset.setTimezone("+08:00");
        asset.setDescription("description");
        request.setAsset(asset);
        CreateLogicAssetResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(serverUrl).getResponse(request, CreateLogicAssetResponse.class);
    }
}