-
Notifications
You must be signed in to change notification settings - Fork 0
/
component.json
47 lines (47 loc) · 2.17 KB
/
component.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
"title": "Node.js Code with Credentials",
"version": "1.0.0",
"description": "You can write your own code and deploy it as part of integration process. With the use of credentials.",
"docsUrl": "https://docs.elastic.io/components/code-with-credentials/index.html",
"authClientTypes": [
"oauth2",
"basic",
"api_key",
"noauth"
],
"credentials": {
"fields": {
"auth": {
"required": false,
"viewClass": "HTTPAuthView"
}
}
},
"fields": {
"code": {
"viewClass": "CodeFieldView",
"label": "Code",
"required": true,
"default": "// Please note only Node.js code is supported here\nasync function run(msg, cfg, snapshot) {\n\tthis.logger.info('\"Execute custom code\" Action started');\n\t/* Please feel free to choose and utilize one of the following credential usage samples.\n\tThe sample you choose should correspond to the type of credentials you have created.\n\tTo use a sample, simply uncomment the relevant code:\n\t1. 'Basic' auth:\n\tconst { username } = cfg.credentials;\n\tconst { password } = cfg.credentials;\n\t2. 'API Key' auth:\n\tconst { headerName } = cfg.credentials;\n\tconst { headerValue } = cfg.credentials;\n\t3. 'OAuth2' auth:\n\tconst { access_token } = cfg.credentials;\n\n\tThe incoming message can be retrieved in the following way:\n\tconst { body } = msg;\n\n\tThe message emitted from any of the previous steps in the flow can be retrieved by it's fully qualified path:\n\tconst message = msg.passthrough.step_1.body;\n\tWhere step_1 - is the number of the step in the flow*/\n\tconst url = 'https://restcountries.com/v3.1/name/germany';\n\tconst { data } = await axios.get(url);\n\t// You can emit as many data messages as required\n\tawait this.emit('data', { body: data });\n\tthis.logger.info('Execution finished');\n}"
}
},
"actions": {
"execute": {
"main": "./actions/code.js",
"title": "Execute custom code",
"metadata": {
"out": {}
}
}
},
"triggers": {
"executeTrigger": {
"main": "./actions/code.js",
"title": "Executes custom code",
"type": "polling",
"metadata": {
"out": {}
}
}
}
}