Get Asset DI Data Duration¶
Get the duration of different status (DI) data of a specified device within a certain period.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Read |
Request Format¶
GET https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId={}&modelId={}&assetIds={}&measurepoints={}&startTime={}&endTime={}&status={}&ifWithUnknown={}
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Required or Not |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
true |
String |
Organization ID which the asset belongs to. How to get orgId>> |
modelId |
Query |
false |
String |
Model ID which the asset belongs to. How to get modelID>> |
assetIds |
Query |
true |
String |
Asset ID, which supports querying multiple assets; multiple asset IDs are separated by commas. How to get assetId>> |
measurepoints |
Query |
true |
String |
Asset measurement point. It is supported to query multiple measurement points, and all the measurement points are separated by commas; the upper limit for query is 10 (Number of devices * Number of measurement points). How to get pointId>> |
startTime |
Query |
true |
String |
Time of start sampling data, where UTC time format and local time format are supported. The local time format is YYYY-MM-DD HH:MM:SS. In case of local time format, the application queries the assets by the local time of the location where the device is. Timezone information is required for UTC time format, e.g. 2019-06-01T00:00:00+08:00; in case of UTC time format, the application queries all the assets by the unified start timestamp and end timestamp. |
endTime |
Query |
true |
String |
Time to stop sampling data. Its format must be consistent with the start time |
status |
Query |
false |
Boolean |
Filter results that include multiple status durations. For example, if only the results of status 0 are required, set the value as “0”. Multiple status are supported. Separate the status by commas. |
ifWithUnknown |
Query |
false |
Boolean |
When the status cannot be confirmed for a certain period of time, the default response status is “Unknown”. This parameter indicates whether this “Unknown” status will be included in the response. The default is “true”, which is included. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
items |
|
List of asset data. The data returned for a single point of a single device is sorted by time in ascending order. Parameters are stored in the Object struct. See items </docs/api/en/2.2.0/tsdb_service/get_asset_di_data_durations#items> |
items¶
Sample¶
{
"scanEndTimestamp": 1569859800000,
"measurepoint": "di_point1",
"assetId": "f4Bkwc5Q",
"durations":
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
]
}
Parameters¶
Name |
Data Type |
Description |
---|---|---|
scanEndTimestamp |
String |
The timestamp of the last data to be scanned. The total number of data for one time scan must not exceed 640000. When the data exceeds 640000, the scan is stopped. This parameter returns the timestamp of the last data scanned, indicating the data after this timestamp are not included. |
assetId |
String |
Asset ID |
measurepoint |
String |
Measurement point identifier |
durations |
|
Durations of different status |
status |
String |
The value of the measurement point of the device |
duration |
String |
The duration of the above |
Error Codes¶
For description of error codes, see Common Error Codes.
Sample 1¶
Request Sample¶
When ifWithUnknown
is true:
GET
https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=o15528761812351&assetIds=f4Bkwc5Q,SSbqxq88&measurepoints=di_point1&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&ifWithUnknown=true
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": `
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "di_point1",
"assetId": "f4Bkwc5Q",
"durations": `
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
},
{
"scanEndTimestamp": 1569859380000,
"measurepoint": "di_point1",
"assetId": "SSbqxq88",
"durations": `
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
},
{
"duration": 180000,
"status": "Unknown"
}
]
}
]
}
}
Sample 2¶
Request Sample¶
When ifWithUnknown
is false:
GET
https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=o15528761812351&assetIds=f4Bkwc5Q,SSbqxq88&measurepoints=di_point1&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&ifWithUnknown=false
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": `
{
"scanEndTimestamp": 1569859380000,
"durations": `
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "di_point1",
"assetId": "f4Bkwc5Q"
},
{
"scanEndTimestamp": 1569859380000,
"durations": `
{
"duration": 60000,
"status": 1
},
{
"duration": 60000,
"status": 2
}
],
"measurepoint": "di_point1",
"assetId": "SSbqxq88"
}
]
}
}
Sample 3¶
Request Sample¶
Filter the status
:
Note
After status filtering, the status “Unknown” will be not inluded in the response.
GET
https://{apigw-address}/tsdb-service/v2.0/di/duration?orgId=o15528761812351&assetIds=f4Bkwc5Q,SSbqxq88&measurepoints=di_point1&startTime=2019-06-01%2000:00:00&endTime=2019-06-11%2023:00:00&status=1
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": `
{
"scanEndTimestamp": 1569859380000,
"durations": `
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "di_point1",
"assetId": "f4Bkwc5Q"
},
{
"scanEndTimestamp": 1569859380000,
"durations": `
{
"duration": 60000,
"status": 1
}
],
"measurepoint": "di_point1",
"assetId": "SSbqxq88"
}
]
}
}
Java SDK Sample¶
private static class Request extends PoseidonRequest{
public void setQueryParam(String key, Object value){
queryEncodeParams().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;
}
}
@Test
public void getAssetsStatusDataTest(){
//1. Click Application Registration on the left navigation of EnOS Management Console
//2. Click the application that will call the API. In App Detail, accessKey and secretKey correspond to AccessKey and SecretKey in EnOS
String accessKey = "29b8d283-dddd-4c31f0e3a356-0f80-4fdf";
String secretKey = "f0e3a856-0fc0-4fdf-b1e5-b34da152879c";
// Create a new request and pass the required parameters into the Query map.
// The key is the parameter name and the value is the parameter value.
Request request = new Request();
request.setQueryParam("orgId", "o15504745674071");
request.setQueryParam("modelId", "opentsdb_model_xxx");
request.setQueryParam("assetIds","4DXYH7nS");
request.setQueryParam("measurepoints", "opentsdb_di_point_xxx");
request.setQueryParam("startTime", "2019-06-01 00:00:00"); //or in UTC format:2019-06-01T00:00:00%2B08:00
request.setQueryParam("endTime", "2019-06-11 23:00:00"); //or in UTC format:2019-06-11T00:00:00%2B08:00
request.setQueryParam("ifWithUnknown", "false");
request.setQueryParam("status", "1,2");
request.setMethod("GET");
try {
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("http://apim-gateway/tsdb-service/v2.0/di/duration")
.getResponse(request, JSONObject.class);
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
}