-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-operation.json
1 lines (1 loc) · 2.57 KB
/
api-operation.json
1
[{"id":"2ee68e1.dc25972","type":"subflow","name":"[API] Operation","info":"","category":"Tequ-API Client","in":[{"x":120,"y":80,"wires":[{"id":"5532e737.34a008"}]}],"out":[{"x":740,"y":80,"wires":[{"id":"dbf420e2.b016c","port":0}]}],"env":[{"name":"Operation","type":"str","value":"1","ui":{"type":"select","opts":{"opts":[{"l":{"en-US":"List images"},"v":"1"},{"l":{"en-US":"List datasources"},"v":"2"},{"l":{"en-US":"List galleries"},"v":"3"},{"l":{"en-US":"List video clips"},"v":"4"},{"l":{"en-US":"Get single image"},"v":"5"},{"l":{"en-US":"Get single datasource"},"v":"6"},{"l":{"en-US":"Get single video clip"},"v":"7"}]}}}],"meta":{"module":"node-red-contrib-tequ-api-operation","version":"0.0.1","author":"[email protected]","desc":"List metadata of single image.","license":"MIT"},"color":"#3FADB5","icon":"font-awesome/fa-globe","status":{"x":740,"y":140,"wires":[{"id":"c7b2ef38.b77d6","port":0}]}},{"id":"4c8c1cf3.8e5224","type":"http request","z":"2ee68e1.dc25972","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":80,"wires":[["dbf420e2.b016c"]]},{"id":"5532e737.34a008","type":"function","z":"2ee68e1.dc25972","name":"Create request","func":"if(msg.token){\n var token = msg.token;\n var id = msg.payload;\n \n msg.payload = {}\n msg.headers = {\n \"Content-Type\": \"application/json\",\n 'Authorization': \"Bearer \"+token \n };\n \n msg.url = \"https://tequ-api.eu-de.mybluemix.net/api/v1/image/id/\"+id;\n msg.method = \"GET\";\n \n return msg;\n}\nelse{\n node.status({fill:\"red\",shape:\"dot\",text:\"Token is missing from request.\"})\n node.error(\"Token is missing from request\", msg) \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":80,"wires":[["4c8c1cf3.8e5224"]]},{"id":"c7b2ef38.b77d6","type":"status","z":"2ee68e1.dc25972","name":"","scope":null,"x":460,"y":140,"wires":[[]]},{"id":"dbf420e2.b016c","type":"function","z":"2ee68e1.dc25972","name":"","func":"var statusCode = msg.statusCode;\n\nif(statusCode == 200){\n node.status({fill:\"green\",shape:\"dot\",text:statusCode+ \" Request OK.\"})\n return msg;\n}\nelse{\n node.status({fill:\"red\",shape:\"dot\",text:statusCode+ \" Request FAILED.\"})\n node.error(statusCode+\": Request FAILED.\", msg) \n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":80,"wires":[[]]},{"id":"f5988c1690dce79b","type":"subflow:2ee68e1.dc25972","z":"d994f01a5b816cf9","name":"","env":[],"x":740,"y":680,"wires":[[]]}]