Skip to content

Instantly share code, notes, and snippets.

@mapero
Last active April 6, 2021 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapero/91f8147e8b72daf7d459b8f626e31090 to your computer and use it in GitHub Desktop.
Save mapero/91f8147e8b72daf7d459b8f626e31090 to your computer and use it in GitHub Desktop.
Enable and disable apps in ctrlX CORE

This flow is an example how to enable and disable an app using node-RED and the ctrlX CORE api

[
{
"id": "131fa555.c8c5bb",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "38de6817.f510c8",
"type": "inject",
"z": "131fa555.c8c5bb",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"name\":\"boschrexroth\",\"password\":\"boschrexroth\"}",
"payloadType": "json",
"x": 260,
"y": 160,
"wires": [
[
"4e809144.df3f7"
]
]
},
{
"id": "4e809144.df3f7",
"type": "http request",
"z": "131fa555.c8c5bb",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://localhost/identity-manager/api/v1/auth/token",
"tls": "e716e0c0.ba889",
"persist": false,
"proxy": "",
"authType": "",
"x": 490,
"y": 160,
"wires": [
[
"6ac1d37d.6fc48c"
]
]
},
{
"id": "84a5d8d6.d19328",
"type": "inject",
"z": "131fa555.c8c5bb",
"name": "enable",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"action\":\"enable\",\"parameters\":{\"id\":\"my-snap\"}}",
"payloadType": "json",
"x": 250,
"y": 280,
"wires": [
[
"e31d799b.4f37e8"
]
]
},
{
"id": "c2288148.7d2aa",
"type": "http request",
"z": "131fa555.c8c5bb",
"name": "POST /package-manager/api/v1/tasks",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://localhost/package-manager/api/v1/tasks",
"tls": "e716e0c0.ba889",
"persist": false,
"proxy": "",
"authType": "",
"x": 690,
"y": 280,
"wires": [
[
"e2e7ff3.997cd"
]
]
},
{
"id": "e31d799b.4f37e8",
"type": "function",
"z": "131fa555.c8c5bb",
"name": "Inject token",
"func": "msg[\"headers\"] = {\n \"Authorization\": \"Bearer \"+flow.get(\"token\")\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 440,
"y": 280,
"wires": [
[
"c2288148.7d2aa"
]
]
},
{
"id": "8ed00cfa.25872",
"type": "debug",
"z": "131fa555.c8c5bb",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1170,
"y": 280,
"wires": []
},
{
"id": "6ac1d37d.6fc48c",
"type": "change",
"z": "131fa555.c8c5bb",
"name": "",
"rules": [
{
"t": "set",
"p": "token",
"pt": "flow",
"to": "payload.access_token",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 160,
"wires": [
[
"6858a2cb.a7a9ac"
]
]
},
{
"id": "6858a2cb.a7a9ac",
"type": "debug",
"z": "131fa555.c8c5bb",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 160,
"wires": []
},
{
"id": "3872dbe8.d2b5f4",
"type": "inject",
"z": "131fa555.c8c5bb",
"name": "disable",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"action\":\"disable\",\"parameters\":{\"id\":\"my-snap\"}}",
"payloadType": "json",
"x": 250,
"y": 340,
"wires": [
[
"e31d799b.4f37e8"
]
]
},
{
"id": "b2f76309.cd4a6",
"type": "inject",
"z": "131fa555.c8c5bb",
"name": "status",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 400,
"wires": [
[
"90937e45.6147d"
]
]
},
{
"id": "1ca992.9d29666e",
"type": "http request",
"z": "131fa555.c8c5bb",
"name": "GET /package-manager/api/v1/tasks/{id}",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "e716e0c0.ba889",
"persist": false,
"proxy": "",
"authType": "",
"x": 700,
"y": 400,
"wires": [
[
"2ceb9379.9b2dfc"
]
]
},
{
"id": "90937e45.6147d",
"type": "function",
"z": "131fa555.c8c5bb",
"name": "Inject token",
"func": "msg[\"headers\"] = {\n \"Authorization\": \"Bearer \"+flow.get(\"token\")\n}\nmsg[\"url\"] = \"https://localhost/package-manager/api/v1/tasks/\"+flow.get(\"last_task\")\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 440,
"y": 400,
"wires": [
[
"1ca992.9d29666e"
]
]
},
{
"id": "2ceb9379.9b2dfc",
"type": "debug",
"z": "131fa555.c8c5bb",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload.state",
"statusType": "msg",
"x": 970,
"y": 400,
"wires": []
},
{
"id": "e2e7ff3.997cd",
"type": "change",
"z": "131fa555.c8c5bb",
"name": "",
"rules": [
{
"t": "set",
"p": "last_task",
"pt": "flow",
"to": "payload.id",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 970,
"y": 280,
"wires": [
[
"8ed00cfa.25872"
]
]
},
{
"id": "ffb2a8a8.7e4858",
"type": "comment",
"z": "131fa555.c8c5bb",
"name": "app id needs to be configured in inject node",
"info": "",
"x": 330,
"y": 240,
"wires": []
},
{
"id": "89780673.dfa7b8",
"type": "comment",
"z": "131fa555.c8c5bb",
"name": "credentials need to be configured in inject node",
"info": "",
"x": 340,
"y": 120,
"wires": []
},
{
"id": "e716e0c0.ba889",
"type": "tls-config",
"name": "",
"cert": "",
"key": "",
"ca": "",
"certname": "",
"keyname": "",
"caname": "",
"servername": "",
"verifyservercert": false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment