1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 21:17:50 +03:00

🔀 Merge branch 'master' of github.com:n8n-io/n8n

This commit is contained in:
Jan Oberhauser 2020-08-19 09:59:42 +02:00
commit b4e6f240f2

View File

@ -4,11 +4,11 @@ import {
} from 'n8n-core';
import {
IBinaryKeyData,
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
IBinaryKeyData,
} from 'n8n-workflow';
import {
@ -65,7 +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',
},
],
default: 'send',
@ -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 <br/>
the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4,<br/>
which is great for correlation/synchronization of that record with the alert.`,
which is great for correlation/synchronization of that record with the alert.<br/>
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 <br/>
the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4,<br/>
which is great for correlation/synchronization of that record with the alert.<br/>
If you resolve / close an alert you must use the same External ID as in the original alert.`,
},
],
};
@ -233,6 +261,7 @@ 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;
@ -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,33 @@ 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,
{},
);
}
}