Skip to content

Instantly share code, notes, and snippets.

@rons4

rons4/README.md Secret

Created September 6, 2023 13:56
Show Gist options
  • Save rons4/e415bf052f2a60cae7235f63046046ca to your computer and use it in GitHub Desktop.
Save rons4/e415bf052f2a60cae7235f63046046ca to your computer and use it in GitHub Desktop.
SIGNL4 Category Management

SIGNL4 is a mobile alerting and incident response service.

This flow is using the REST API to manage categories, e.g. for automatically creating a standard set of categories for new teams.

[
{
"id": "e09a27d99f0ba5c3",
"type": "tab",
"label": "SIGNL4 Categories",
"disabled": false,
"info": "",
"env": []
},
{
"id": "a551763e.17b798",
"type": "debug",
"z": "e09a27d99f0ba5c3",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 140,
"wires": []
},
{
"id": "8a4daa77.db84c8",
"type": "inject",
"z": "e09a27d99f0ba5c3",
"name": "GetTeams",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 140,
"wires": [
[
"1459cff3.6e993"
]
]
},
{
"id": "67556a91.2bed74",
"type": "http request",
"z": "e09a27d99f0ba5c3",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "body",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 350,
"y": 140,
"wires": [
[
"8df4866e.e32e48"
]
]
},
{
"id": "1459cff3.6e993",
"type": "function",
"z": "e09a27d99f0ba5c3",
"name": "",
"func": "\nvar strAPIKey = 'your-signl4-api-key';\n\nmsg.url = 'https://connect.signl4.com/api/v2/teams'\nmsg.method = 'GET';\nmsg.headers = {};\nmsg.headers['X-S4-Api-Key'] = strAPIKey;\nmsg.payload = '';\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 220,
"y": 200,
"wires": [
[
"67556a91.2bed74"
]
]
},
{
"id": "ae9585bb.839d28",
"type": "function",
"z": "e09a27d99f0ba5c3",
"name": "",
"func": "\nvar result = \"\";\n\nfor (var i = 0; i < msg.payload.length; i++) {\n result += msg.payload[i].name + \": \" + msg.payload[i].id + \"\\r\\n\";\n}\n\nmsg.payload = result;\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 180,
"wires": [
[
"a551763e.17b798"
]
]
},
{
"id": "8df4866e.e32e48",
"type": "json",
"z": "e09a27d99f0ba5c3",
"name": "",
"property": "payload",
"action": "",
"pretty": true,
"x": 470,
"y": 80,
"wires": [
[
"ae9585bb.839d28"
]
]
},
{
"id": "6f2981f8.37844",
"type": "debug",
"z": "e09a27d99f0ba5c3",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 380,
"wires": []
},
{
"id": "352f272c.2a5268",
"type": "inject",
"z": "e09a27d99f0ba5c3",
"name": "AddCategory",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 380,
"wires": [
[
"f8639289.efe94"
]
]
},
{
"id": "89b8cda7.f2d41",
"type": "http request",
"z": "e09a27d99f0ba5c3",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "body",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 330,
"y": 380,
"wires": [
[
"6d070334.12bb2c"
]
]
},
{
"id": "f8639289.efe94",
"type": "function",
"z": "e09a27d99f0ba5c3",
"name": "",
"func": "\nvar strAPIKey = 'your-signl4-api-key';\nvar strTeamId = 'your-signl4-team-id';\n\nmsg.url = 'https://connect.signl4.com/api/v2/categories/' + strTeamId;\nmsg.method = 'POST';\nmsg.headers = {};\nmsg.headers['X-S4-Api-Key'] = strAPIKey;\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json';\nmsg.payload = {\n \"augmentations\": [\n {\n \"enabled\": false,\n \"name\": \"\",\n \"type\": \"Subject\",\n \"value\": \"\"\n },\n {\n \"enabled\": false,\n \"name\": \"\",\n \"type\": \"Location\",\n \"value\": \"\"\n },\n {\n \"enabled\": false,\n \"name\": \"\",\n \"type\": \"Text\",\n \"value\": \"\"\n }\n ],\n \"color\": \"#30AFE5\",\n \"imageName\": \"bug.svg\",\n \"keywordMatching\": \"Any\",\n \"keywords\": [\n \"keyword1\",\n \"keyword2\"\n ],\n \"name\": \"MyNewCategory\"\n };\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 200,
"y": 440,
"wires": [
[
"89b8cda7.f2d41"
]
]
},
{
"id": "cdb0afa.f3fef5",
"type": "function",
"z": "e09a27d99f0ba5c3",
"name": "",
"func": "\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 420,
"wires": [
[
"6f2981f8.37844"
]
]
},
{
"id": "6d070334.12bb2c",
"type": "json",
"z": "e09a27d99f0ba5c3",
"name": "",
"property": "payload",
"action": "",
"pretty": true,
"x": 450,
"y": 320,
"wires": [
[
"cdb0afa.f3fef5"
]
]
},
{
"id": "1f9caafcb214b8bc",
"type": "comment",
"z": "e09a27d99f0ba5c3",
"name": "Get all teams.",
"info": "Get all teams.\nSet your SIGNL4 API key and other values in the first function node.\n",
"x": 130,
"y": 80,
"wires": []
},
{
"id": "6f2df1bcd4d8de77",
"type": "comment",
"z": "e09a27d99f0ba5c3",
"name": "Add category.",
"info": "Add category.\nSet your SIGNL4 API key and other values in the first function node.\n",
"x": 130,
"y": 320,
"wires": []
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment