From e64f56a30ec53811d0c39b7474e17674bac8e74d Mon Sep 17 00:00:00 2001
From: Ron <43244104+rons4@users.noreply.github.com>
Date: Tue, 11 Aug 2020 10:07:52 +0200
Subject: [PATCH 1/2] Added feature to resolve alerts
---
.../nodes-base/nodes/Signl4/Signl4.node.ts | 64 ++++++++++++++++---
1 file changed, 56 insertions(+), 8 deletions(-)
diff --git a/packages/nodes-base/nodes/Signl4/Signl4.node.ts b/packages/nodes-base/nodes/Signl4/Signl4.node.ts
index 29d3917cf..057080d4d 100644
--- a/packages/nodes-base/nodes/Signl4/Signl4.node.ts
+++ b/packages/nodes-base/nodes/Signl4/Signl4.node.ts
@@ -67,6 +67,11 @@ export class Signl4 implements INodeType {
value: 'send',
description: 'Send an alert.',
},
+ {
+ name: 'Resolve',
+ value: 'resolve',
+ description: 'Resolve an alert.',
+ },
],
default: 'send',
description: 'The operation to perform.',
@@ -161,7 +166,8 @@ export class Signl4 implements INodeType {
default: '',
description: `If the event originates from a record in a 3rd party system, use this parameter to pass
the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4,
- which is great for correlation/synchronization of that record with the alert.`,
+ which is great for correlation/synchronization of that record with the alert.
+ If you resolve / close an alert you must use the same External ID as in the original alert.`,
},
{
displayName: 'Filtering',
@@ -216,9 +222,31 @@ export class Signl4 implements INodeType {
name: 'title',
type: 'string',
default: '',
+ description: 'The title or subject of this alert.',
},
],
},
+ {
+ displayName: 'External ID',
+ name: 'externalId',
+ type: 'string',
+ default: '',
+ required: false,
+ displayOptions: {
+ show: {
+ operation: [
+ 'resolve',
+ ],
+ resource: [
+ 'alert',
+ ],
+ },
+ },
+ description: `If the event originates from a record in a 3rd party system, use this parameter to pass
+ the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4,
+ which is great for correlation/synchronization of that record with the alert.
+ If you resolve / close an alert you must use the same External ID as in the original alert.`,
+ },
],
};
@@ -233,12 +261,13 @@ export class Signl4 implements INodeType {
for (let i = 0; i < length; i++) {
if (resource === 'alert') {
//https://connect.signl4.com/webhook/docs/index.html
+ // Send alert
if (operation === 'send') {
const message = this.getNodeParameter('message', i) as string;
const additionalFields = this.getNodeParameter('additionalFields',i) as IDataObject;
const data: IDataObject = {
- message,
+ 'message': message
};
if (additionalFields.alertingScenario) {
@@ -259,6 +288,7 @@ export class Signl4 implements INodeType {
if (additionalFields.service) {
data['X-S4-Service'] = additionalFields.service as string;
}
+ data['X-S4-Status'] = 'new';
if (additionalFields.title) {
data['title'] = additionalFields.title as string;
}
@@ -303,14 +333,32 @@ export class Signl4 implements INodeType {
this,
'POST',
'',
- {},
+ data,
{},
endpoint,
- {
- formData: {
- ...data,
- },
- },
+ {},
+ );
+ }
+ // Resolve alert
+ if (operation === 'resolve') {
+
+ const data: IDataObject = {};
+
+ data['X-S4-ExternalID'] = this.getNodeParameter('externalId', i) as string;
+ data['X-S4-Status'] = 'resolved';
+
+ const credentials = this.getCredentials('signl4Api');
+
+ const endpoint = `https://connect.signl4.com/webhook/${credentials?.teamSecret}`;
+
+ responseData = await SIGNL4ApiRequest.call(
+ this,
+ 'POST',
+ '',
+ data,
+ {},
+ endpoint,
+ {},
);
}
}
From 9f527230b94887769f0fa12380205355ff75ddfc Mon Sep 17 00:00:00 2001
From: ricardo
Date: Tue, 18 Aug 2020 20:55:36 -0400
Subject: [PATCH 2/2] :zap: Small improvements
---
packages/nodes-base/nodes/Signl4/Signl4.node.ts | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/packages/nodes-base/nodes/Signl4/Signl4.node.ts b/packages/nodes-base/nodes/Signl4/Signl4.node.ts
index 057080d4d..b4022ff0e 100644
--- a/packages/nodes-base/nodes/Signl4/Signl4.node.ts
+++ b/packages/nodes-base/nodes/Signl4/Signl4.node.ts
@@ -4,11 +4,11 @@ import {
} from 'n8n-core';
import {
+ IBinaryKeyData,
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
- IBinaryKeyData,
} from 'n8n-workflow';
import {
@@ -65,12 +65,12 @@ export class Signl4 implements INodeType {
{
name: 'Send',
value: 'send',
- description: 'Send an alert.',
+ description: 'Send an alert',
},
{
name: 'Resolve',
value: 'resolve',
- description: 'Resolve an alert.',
+ description: 'Resolve an alert',
},
],
default: 'send',
@@ -267,7 +267,7 @@ export class Signl4 implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields',i) as IDataObject;
const data: IDataObject = {
- 'message': message
+ message,
};
if (additionalFields.alertingScenario) {
@@ -345,6 +345,7 @@ export class Signl4 implements INodeType {
const data: IDataObject = {};
data['X-S4-ExternalID'] = this.getNodeParameter('externalId', i) as string;
+
data['X-S4-Status'] = 'resolved';
const credentials = this.getCredentials('signl4Api');