Delete Logical Asset(Preview)


删除指定的逻辑资产。

操作权限

需授权的资源

所需操作权限

资产树管理

Full Access

请求格式

POST https://{apigw-address}/asset-service/v2.1/logical-assets?action=delete

请求参数(URI)

名称

位置(Path/Query)

必需/可选

数据类型

描述

orgId

Query

必需

String

资产所属的组织 ID。如何获取 orgId 信息>>

请求参数(Body)

名称

必需/可选

数据类型

描述

assetId

必需

String

需要删除的逻辑资产 ID。如何获取 assetId 信息>>

错误码

代码

错误信息

描述

17404

Logical asset does not exist

assetId 未找到或不存在。

示例

请求示例

url: https://{apigw-address}/asset-service/v2.1/logical-assets?action=delete&orgId=yourOrgId
method: POST
requestBody:
{
  "assetId":"yourAssetId"
}

返回示例

{
  "code": 0,
  "msg": "OK",
  "requestId": "01b5477a-374e-49a0-8b68-7dbfe8f0b74f"
}

Java SDK 调用示例

package com.envisioniot.enos.asset_tree_service;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.api.common.constant.request.Pagination;
import com.envisioniot.enos.api.common.constant.request.Projection;
import com.envisioniot.enos.asset_tree_service.v2_1.*;
import com.envisioniot.enos.asset_tree_service.vo.*;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;

public class DeleteLogicAssetTest {

    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() {
        DeleteLogicAssetRequest request = new DeleteLogicAssetRequest();
        request.setOrgId(orgId);
        request.setAssetId("yourAssetId"); //删除的逻辑资产 ID,填设备资产 ID 则删除失败
        DeleteLogicAssetResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(serverUrl).getResponse(request, DeleteLogicAssetResponse.class);

    }
}