Retrieves list of notifications. DCM_API_DOMAIN will be provided by DCM.
Request
URL: <DCM_API_DOMAIN>/notifications
Method: POST
Format: application/json
Headers: The following headers must be included in the request
|
Parameter |
Type |
Mandatory |
Default Value |
Description |
|---|---|---|---|---|
|
content-type |
string |
Yes |
|
Indicates the media type of the resource. Use |
|
authorizationToken |
string |
Yes |
|
Token to be used when accessing the API. Value is Use token from Token. |
Parameters:
|
Parameter |
Type |
Mandatory |
Default Value |
Description |
|---|---|---|---|---|
|
query |
string |
Yes |
|
A structured string that allows calling application to specify the data that it wants to retrieve. |
Query structure:
query {
notifications(projectId: <project_id>, startTime: <start_time>, endTime: <end_time>) {
<data_fields_to_be_retrieved>
}
}
Query parameters:
|
Parameter |
Type |
Mandatory |
Default Value |
Description |
|---|---|---|---|---|
|
project_id |
string |
Yes |
|
The ID of the project from where the notifications will be retrieved from. |
|
start_time |
DateTime |
No |
Now - 1 hour |
The start of the period data is requested for. Time periods are in UTC format and can be a maximum of a 24 hour period. |
|
end_time |
DateTime |
No |
Now |
The end of the period data is requested for |
|
data_fields_to_be_retrieved |
string |
Yes |
|
The fields to be retrieved. Allowed values:
|
Notes:
-
If end_time is more than 1 day after start_time an error will occur and no data will be retrieved.
Response
Format: application/json
Parameters:
|
Name |
Type |
Description |
|---|---|---|
|
errors.message |
String |
Description of the error if one occurred. |
|
data.notifications |
List |
List of notifications. |
Examples
-
Retrieve all notification fields.
const getNotifications = async function(token, projectId, startTime, endTime) {
return new Promise(function(res, rej) {
const url = '<DCM_API_DOMAIN>/notifications';
const method = 'POST';
const headers = {
'content-type': 'application/json',
'authorizationToken': `Bearer ${token}`
};
const query = `query {
notifications(projectId: "${projectId}", startTime: "${startTime}", endTime: "${endTime}") {
notificationId
alertRuleId
projectId
message
startTimestamp
endTimestamp
dismissed
dismissedBy
read
readBy
}
}`;
const options = {
url: url,
method: method,
headers: headers,
body: JSON.stringify({ query })
};
const req = request(options, function callback(error, response, body) {
body = JSON.parse(body);
...
...
});
});
}
Response with all of the notification fields.
{
"data": {
"notifications": [
{
"notificationId": "<notification_id>",
"alertRuleId": null,
"projectId": "<project_id>",
"message": "Density >= 100",
"startTimestamp": "2021-12-08T06:02:50.476Z",
"endTimestamp": "2021-12-08T06:02:50.476Z",
"dismissed": false,
"dismissedBy": null,
"read": false,
"readBy": null
}
]
}
}
2. Retrieve some of the notification fields.
const getNotifications = async function(token, projectId, startTime, endTime) {
return new Promise(function(res, rej) {
const url = '<DCM_API_DOMAIN>/notifications';
const method = 'POST';
const headers = {
'content-type': 'application/json',
'authorizationToken': `Bearer ${token}`
};
const query = `query {
notifications(projectId: "${projectId}", startTime: "${startTime}", endTime: "${endTime}") {
message
startTimestamp
dismissed
read
}
}`;
const options = {
url: url,
method: method,
headers: headers,
body: JSON.stringify({ query })
};
const req = request(options, function callback(error, response, body) {
body = JSON.parse(body);
...
...
});
});
}
Response with some of the notification fields.
{
"data": {
"notifications": [
{
"message": "Density >= 100",
"startTimestamp": "2021-12-08T06:02:50.476Z",
"dismissed": false,
"read": false
}
]
}
}
3. Retrieve the “message” notification field only.
const getNotifications = async function(token, projectId, startTime, endTime) {
return new Promise(function(res, rej) {
const url = '<DCM_API_DOMAIN>/notifications';
const method = 'POST';
const headers = {
'content-type': 'application/json',
'authorizationToken': `Bearer ${token}`
};
const query = `query {
notifications(project_id: "${projectId}", start_time: "${startTime}", end_time: "${endTime}") {
message
}
}`;
const options = {
url: url,
method: method,
headers: headers,
body: JSON.stringify({ query })
};
const req = request(options, function callback(error, response, body) {
body = JSON.parse(body);
...
...
});
});
}
Response with the “message” notification field only.
{
"data": {
"notifications": [
{
"message": "Density >= 100"
}
]
}
}