Submit Data Deletion Job¶
Submit a data deletion job to delete the historical data of specified assets stored in TSDB.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Write |
For more information about resources and required permission, see Policies, Roles and Permissions>>
Request Format¶
POST https://{apigw-address}/tsdb-service/v2.1/data/tsdb-delete
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 organization ID>> |
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
modelId |
Mandatory |
String |
Specify the model to which the data belongs. How to get model Id>> |
pointId |
Optional |
String |
Specify the measurement point to which the data belongs. If no point is specified, all the measurement point data of the specified model and assets will be deleted. How to get measurement point ID>> |
assetIds |
Mandatory |
String |
The asset ID. Supports deleting the historical data of multiple assets, separated by commas. How to get asset ID>> |
startTime |
Mandatory |
String |
Specify the time range of the data to be deleted (start time), for example: 1615444301240 |
endTime |
Mandatory |
String |
Specify the time range of the data to be deleted (end time), for example: 1615530701240 |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Number |
Return the data deletion job ID. |
Error Code¶
For the description of error codes, see Common Error Codes.
Sample¶
Request Sample¶
url: https://{apigw-address}/tsdb-service/v2.1/data/tsdb-delete?orgId=yourOrgId
method: POST
requestBody:
{
"pointId": "yourPointId",
"modelId": "yourModelId",
"assetIds": "yourAssetIds",
"startTime": "1615444301240",
"endTime": "1615530701240"
}
Return Sample¶
{
"msg": "OK",
"code": 0,
"data": 302037106667073536,
"submsg": "success"
}
Java SDK Sample¶
import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;
public class SubmitDataDeletionJob {
private static final String API_GATEWAY_URL = "https://{apigw-address}";
private static class Request extends PoseidonRequest {
public void setBodyParams(String key, Object value) {
bodyParams().put(key, value);
}
public void setMethod(String method) {
this.method = method;
}
private String method;
@Override
public String baseUri() {
return "";
}
@Override
public String method() {
return method;
}
}
public static void main(String[] args) {
//1. Click Application Registration in the left navigation of the EnOS Management Console.
//2. Click the application that needs to call the API, and click Basic Information. accessKey and secretKey correspond to AccessKey and SecretKey in EnOS.
Poseidon poseidon = Poseidon.config(
PConfig.init()
.appKey("AccessKey of your APP")
.appSecret("SecretKey of your APP")
).method("POST").header("Content-Type", "application/json");
Request request = new Request();
request.setBodyParams("modelId", "yourModelId");
request.setBodyParams("pointId", "yourPointId");
request.setBodyParams("assetIds", "yourAssetId1,yourAssetId2");
request.setBodyParams("startTime", "1615444301240");
request.setBodyParams("endTime", "1615530701240");
JSONObject response = poseidon
.url(API_GATEWAY_URL + "/tsdb-service/v2.1/data/tsdb-delete")
.queryParam("orgId", "yourOrgId")
.getResponse(request, JSONObject.class);
System.out.println(response);
}
}