SolarUser Datum Expire API - SolarNetwork/solarnetwork GitHub Wiki
The SolarUser Datum Expire API provides methods to manage datum expiration policies and submit ad hoc datum delete tasks. Expiration policies are applied continuously by SolarNetwork, for all active configurations. Ad-hoc delete tasks are executed just once, after submitting one.
All dates and times are represented in the Gregorian calendar system. All requests must provide a valid user authentication token. See SolarNet API authentication for information on how to use authentication tokens.
Verb | Endpoint | Description |
---|---|---|
GET |
/user/expire/configs |
List previously submitted expire configurations. |
POST |
/user/expire/configs/data |
Store an expiration data configuration. |
DELETE |
/user/expire/configs/data/{id} |
Delete an expiration data configuration. |
GET |
/user/expire/configs/data/{id}/preview |
Preview the impact of applying an expiration data configuration. |
POST |
/user/expire/datum-delete |
Preview the impact of an ad hoc delete datum request. |
POST |
/user/expire/datum-delete/confirm |
Submit a delete datum request. |
POST |
/user/expire/datum-delete/ids |
Delete datum matching specific IDs. |
GET |
/user/expire/datum-delete/jobs |
List datum delete jobs. |
GET |
/user/expire/datum-delete/jobs/{id} |
View information about a specific datum delete job. |
GET |
/user/expire/services/aggregation |
List the available aggregation types. |
Many endpoints return localized messages. The locale of the response is determined by the
Accept-Language
HTTP header passed on the request. If not provided, the default locale of the
SolarNetwork service will be used.
A data configuration object represents the criteria for what data should be deleted. Each object contains the following properties:
Property | Type | Description |
---|---|---|
id |
number | A unique identifier assigned by SolarNetwork. |
created |
string | The date the configuration was submitted, in YYYY-MM-dd HH:mm:ss.SSS'Z' format, in the UTC time zone. |
serviceIdentifier |
string | A unique identifier for the type of data configuration. Will always be net.solarnetwork.central.user.expire.standard.DefaultUserExpireDataFilterService . |
userId |
number | The ID of the user that owns the configuration. |
name |
string | A user-assigned name for the configuration. |
active |
boolean |
true when this configuration is active. |
expireDays |
number | The minimum number of days old datum must be to be deleted. |
datumFilter |
object | An expiration datum filter object to select which datum to delete. |
An example expiration data object looks like the following:
{
"id": 6,
"created": "2018-07-11 04:01:41.859Z",
"userId": 1,
"name": "Raw power after 2y",
"serviceIdentifier": "net.solarnetwork.central.user.expire.standard.DefaultUserExpireDataFilterService",
"active": false,
"expireDays": 730,
"datumFilter": {
"aggregation": "None",
"nodeIds": 123,
"sourceIds": ["/power/*"]
}
}
This object represents the criteria to choose from which datum streams to delete. Each object contains the following properties:
Property | Type | Description |
---|---|---|
aggregationKey |
string | The largest aggregation to include in the delete task. Matching datum with lower aggregations, up to and including this aggregation, will be deleted. |
nodeIds |
array<number> | The list of node IDs to match. |
sourceIds |
array<string> | The list of source IDs to match. Wildcard patterns are supported. |
An example expiration data object looks like the following:
{
"aggregationKey": "0",
"nodeIds": 123,
"sourceIds": ["/power/*"]
}
List the available aggregation types for configuring in an expiration datum filter object.
GET | /solaruser/api/v1/sec/user/expire/services/aggregation |
---|
The response is a list of aggregation localized service objects. An example looks like this:
{
"success": true,
"data": [
{
"id": "0",
"locale": "en-NZ",
"localizedDescription": "None",
"localizedName": "None"
},
{
"id": "h",
"locale": "en-NZ",
"localizedDescription": "Hour",
"localizedName": "Hour"
},
{
"id": "d",
"locale": "en-NZ",
"localizedDescription": "Day",
"localizedName": "Day"
},
{
"id": "M",
"locale": "en-NZ",
"localizedDescription": "Month",
"localizedName": "Month"
}
]
}
List all available expire configurations.
GET | /solaruser/api/v1/sec/user/expire/configs |
---|
The response contains a list of expire configuration objects. Each configuration has the following properties:
Property | Type | Description |
---|---|---|
dataConfigs |
array<object> | The list of available expiration data configuration objects. |
An example response looks like:
{
"success": true,
"data": {
"dataConfigs": [
{
"id": 6,
"created": "2018-07-11 04:01:41.859Z",
"userId": 1,
"name": "All raw after 2y",
"serviceIdentifier": "net.solarnetwork.central.user.expire.standard.DefaultUserExpireDataFilterService",
"active": false,
"expireDays": 730,
"datumFilter": {
"aggregation": "None"
}
},
{
"id": 5,
"created": "2018-07-11 01:49:11.335Z",
"userId": 1,
"name": "Fleeting",
"serviceIdentifier": "net.solarnetwork.central.user.expire.standard.DefaultUserExpireDataFilterService",
"active": false,
"expireDays": 7,
"datumFilter": {
"sourceIds": [
"/power/switch/*"
],
"aggregation": "Month"
}
}
]
}
}
Create or update an expiration data configuration to define a datum expiration policy. The request body must be a full JSON expiration data configuration object.
POST | /solaruser/api/v1/sec/user/expire/configs/data |
---|
Delete an expiration data configuration.
DELETE | /solaruser/api/v1/sec/user/expire/configs/data/{id} |
---|---|
id |
The unique ID of the configuration to delete. |
Preview the effects of applying an expiration data configuration. This will show you a summary of how many datum would be deleted if the configuration were applied.
GET | /solaruser/api/v1/sec/user/expire/configs/data/{id}/preview |
---|---|
id |
The unique ID of the configuration to preview. |
The response is a summary object with the following properties:
Property | Type | Description |
---|---|---|
date |
string | The date the preview was executed, in YYYY-MM-dd HH:mm:ss.SSS'Z' format, in the UTC time zone. |
datumTotalCount |
number | The total number of datum, across all aggregation types, that would be deleted. |
datumCount |
number | The number of raw datum that would be deleted. |
datumHourlyCount |
number | The number of hourly aggregate datum that would be deleted. |
datumDailyCount |
number | The number of daily aggregate datum that would be deleted. |
datumCMonthlyount |
number | The number of monthly aggregate datum that would be deleted. |
An example response looks like:
{
"success": true,
"data": {
"date": "2022-03-21 11:00:00Z",
"datumTotalCount": 1071,
"datumCount": 819,
"datumHourlyCount": 188,
"datumDailyCount": 52,
"datumMonthlyCount": 12
}
}
This method allows you to find out how many datum would be deleted if datum matching the submitted criteria were deleted.
POST | /solaruser/api/v1/sec/user/expire/datum-delete |
---|---|
aggregationKey |
The largest aggregation to include in the delete task. Matching datum with lower aggregations, up to and including this aggregation, will be deleted. |
nodeIds |
The list of node IDs to match. |
sourceIds |
The list of source IDs to match. Wildcard patterns are supported. |
localStartDate |
An inclusive minimum date of datum to delete, in YYYY-MM-dd or YYYY-MM-ddTHH:mm patterns. The date will be interpreted in the time zone of the node associated with each datum. |
localEndDate |
An exclusive maximum date of datum to delete, in YYYY-MM-dd or YYYY-MM-ddTHH:mm patterns. The date will be interpreted in the time zone of the node associated with each datum. |
The response is the same as in the preview expire data response method. An example response looks like this:
{
"success": true,
"data": {
"date": "2022-03-21 11:00:00Z",
"datumTotalCount": 1071,
"datumCount": 819,
"datumHourlyCount": 188,
"datumDailyCount": 52,
"datumMonthlyCount": 12
}
}
This method allows you to deleted a range of datum matching the submitted criteria. The request takes the same parameters as the Delete datum preview method. The data is not deleted immediately. Instead, a delete job is scheduled and will be performed at some point in the future. You can view the status of jobs using the Delete datum jobs list method.
POST | /solaruser/api/v1/sec/user/expire/datum-delete/confirm |
---|
The response object is a delete datum job object, with the following properties:
Property | Type | Description |
---|---|---|
id |
string | The unique ID of the delete job. |
jobState |
string | The state of the job, one of Queued , Claimed , Executing , Completed . |
userId |
number | The ID of the user that submitted the job. |
configuration |
object | The delete filter criteria submitted with the job. |
percentComplete |
number | The percent complete the job is, from 0 - 1 . |
submitDate |
number | A millisecond epoch date when the delete job was created. |
startedDate |
number | A millisecond epoch date when the delete job started, or 0 if not started yet. |
completionDate |
number | A millisecond epoch date when the delete job completed, or 0 if not complete. |
resultCount |
number | A millisecond epoch date when the delete job completed, or 0 if not complete. |
success |
number |
true if the delete job completed successfully. |
jobDuration |
number | The number of milliseconds the job took to complete. |
An example response looks like this:
{
"success": true,
"data": {
"id": "7d8a3ad7-0c2c-44ab-b708-6555296f4af3"
"jobState": "Queued",
"userId": 147,
"configuration": {
"nodeIds": [1,2,3]
"sourceIds": ["/power/1","/power/2"],
"aggregation": "None",
"localStartDate": "2019-01-22 00:50:00",
"localEndDate": "2020-01-25 04:00:00"
},
"percentComplete": 0.0,
"submitDate": 1648002593507,
"startedDate": 0,
"completionDate": 0,
"resultCount": 0,
"success": false,
"jobDuration": 0,
}
}
This method allows you to deleted a range of datum matching the submitted criteria. The request takes the same parameters as the Delete datum preview method. The data is not deleted immediately. Instead, a delete job is scheduled and will be performed at some point in the future. You can view the status of jobs using the Delete datum jobs list method.
GET | /solaruser/api/v1/sec/user/expire/datum-delete/jobs |
---|---|
states |
Comma-delimited list of job states to limit the results to. Possible job states include: Queued , Claimed , Executing , Completed . |
The response contains a list of delete datum job objects. See the Delete datum response for more information.
This method allows you to view the status of a specific job.
GET | /solaruser/api/v1/sec/user/expire/datum-delete/jobs/{id} |
---|---|
id |
The ID of the job to view. |
The response will be a delete datum job object. See the Delete datum response for more information.
This method allows you to delete a small set of specific datum, based on unique identifiers.
POST | /solaruser/api/v1/sec/user/expire/datum-delete/ids |
---|
The request body must be a JSON array of identifier objects representing the specific datum you would like to delete.
⚠️ At most 100 identifiers can be submitted in a single request. In addition, only node datum may be deleted.
Each datum identifier must uniquely identify a single datum, using one of two styles: node and source ID or stream ID. These are detailed in the following sections.
💡 Note that the response will include identifiers with all identifying properties (node, source, and stream IDs).
This style uses node and source IDs to identify the datum. Each identifier object must include the following properties:
Property | Type | Description |
---|---|---|
objectId |
number | The node ID. |
sourceId |
string | The source ID. |
timestamp |
string | The timestamp of the datum, in YYYY-MM-DD HH:mm:ss.SSSZ format. |
An example request using node and source IDs as identifiers looks like this:
[
{
"objectId": 1,
"sourceId": "meter/1",
"timestamp": "2024-03-04 00:47:00Z"
},
{
"objectId": 1,
"sourceId": "meter/1",
"timestamp": "2024-03-03 23:47:00Z"
}
]
This style uses stream IDs to identify the datum. Each identifier object must include the following properties:
Property | Type | Description |
---|---|---|
streamId |
string | The stream ID. |
timestamp |
string | The timestamp of the datum, in YYYY-MM-DD HH:mm:ss.SSSZ format. |
⚠️ If an identifier object provides astreamId
then anyobjectId
andsourceId
property values will be ignored.
An example request using stream IDs as identifiers looks like this:
[
{
"streamId": "f59d583e-f5a9-48e4-9b00-f837ca87b5b7",
"timestamp": "2024-03-04 00:47:00Z"
},
{
"streamId": "f59d583e-f5a9-48e4-9b00-f837ca87b5b7",
"timestamp": "2024-03-03 23:47:00Z"
}
]
The response is a list of all datum IDs actually deleted. There could be fewer IDs in the response than were submitted if some ID did not match an actual datum.
An example response looks like this:
{
"success": true,
"data": [
{
"kind": "n",
"streamId": "f59d583e-f5a9-48e4-9b00-f837ca87b5b7",
"objectId": 1,
"sourceId": "meter/1",
"timestamp": "2024-03-04 00:47:00Z",
"aggregation": "None"
},
{
"kind": "n",
"streamId": "f59d583e-f5a9-48e4-9b00-f837ca87b5b7",
"objectId": 1,
"sourceId": "meter/1",
"timestamp": "2024-03-03 23:47:00Z",
"aggregation": "None"
}
]
}
☝️ Note that the identifier objects in the response will include all identifying properties (node, source, and stream IDs), regardles of which style was used in the request.