Cancel Command

取消缓存命令的接口。如果有commandId,则取消单个命令,如果无commandId,则取消该设备的所有缓存命令。

操作权限

需授权的资源

所需操作权限

资产

Control

请求格式

POST https://{apigw-address}/connect-service/v2.1/commands?action=cancel

请求参数(URI)

备注

以下非必须字段中,必须提供 assetIdproductKey + deviceKey 的组合,用于指定设备。

名称

位置(Path/Query)

必需/可选

数据类型

描述

orgId

Query

必需

String

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

assetId

Query

可选

String

资产ID。如何获取Asset ID信息>>

productKey

Query

可选

String

Product Key.

deviceKey

Query

可选

String

Device Key.

commandId

Query

可选

String

命令ID。

响应参数

名称

数据类型

描述

data

Command结构体数组

被取消的命令列表。参见 Command结构体>>

示例

请求示例

url:https://{apigw-address}/connect-service/v2.1/commands?action=cancel&deviceKey=yourDeviceKey&productKey=yourProductKey&orgId=yourOrgId
method: POST

返回示例

{
    "code": 0,
    "msg": "OK",
    "requestId": "7d863d517eae4f18a2776452eb1305bb",
    "data": [{
        "commandId": "2278935391225618432",
        "orgId": "yourOrgId",
        "productKey": "yourProductKey",
        "deviceKey": "yourDeviceKey",
        "assetId": "yourAssetId",
        "createTime": "1560505243577",
        "createLocalTime": "2019-06-14 17:40:23",
        "commandType": 1,
        "commandName": {
            "defaultValue": "Int_value",
            "i18nValue": {
                "en_US": "Int_value"
            }
        },
        "timeout": 1,
        "pendingTtl": 6000,
        "state": 1,
        "tslIdentifier": "Int_value",
        "inputData": 222,
        "outputData": null
    }]
}

Java SDK调用示例

package com.envisioniot.enos.api.sample.connect_service.command;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.service.CancelCommandRequest;
import com.envisioniot.enos.connect_service.v2_1.service.CancelCommandResponse;

public class CancelCommand {

    public static void main(String[] args) {
        String appKey = "yourAppKey";
        String appSecret = "yourAppSecret";
        String serverUrl = "yourServerUrl";

        String orgId = "yourOrgId";
        String productKey = "yourProductKey";
        String deviceKey = "yourDeviceKey";
        String commandId = "yourCommandId";

        CancelCommandRequest request = new CancelCommandRequest();
        request.setOrgId(orgId);
        request.setProductKey(productKey);
        request.setDeviceKey(deviceKey);
        request.setCommandId(commandId);
        CancelCommandResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(serverUrl)
                .getResponse(request, CancelCommandResponse.class);
    }
}