Rest API
Flexter offers an option to run commands through Rest API. This option comes with Flexter-UI module and is disabled by default.
Enabling it
The change must be done at /usr/share/flexter/flexter-ui/conf/backend.properties
or ~/share/flexter/flexter-ui/conf/backend.properties
for non root installations.
Please set the cmd.enabled
value as below:
cmd.enabled = true
And after that, please restart the flexterui-backend
service:
systemctl restart flexterui-backend
Example job command:
Here an example of generating schema from xml, note that I use jq
at the end to format the output.
curl -H 'Content-Type: application/json' -XPOST -d '{
"executions":[
{
"app_name":"xml2er",
"source":{
"file":{
"command":"/usr/share/flexter/samples/donut.xml.gz",
"enabled":true
}
},
"target":{
"generation":[
{
"command":"-g",
"enabled":"true",
"value":"3"
}
]
}
}
]
}' http://<FLEXTER_UI_SERVER>:<PORT>/v2/run/cmd | jq
And the related output:
{
"error": false,
"logPath": null,
"cmds": [
"xml2er -j 7"
],
"jobs": [
7
]
}
Tracking the job status
You can also track status of the job calling:
curl http://<FLEXTER_UI_SERVER>:<PORT>/v2/executions/get/7
or
curl http://<FLEXTER_UI_SERVER>:<PORT>/v2/executions/get/7 | jq
And get as output:
{
"params": "/usr/share/flexter/samples/donut.xml.gz -g 3",
"status": "C",
"host": "<HOSTNAME>/<IP_ADDRESS>",
"parm_path_input": null,
"id_org": 1,
"base_path": "/",
"id_app": "local-1674054248306",
"id_lschma": 4,
"start_date": 1674054245996,
"os_user": "root",
"id_sch": 11,
"job_type": "Parse",
"parm_path_output": null,
"params_json": "{\"spark\": {\"master\": \"local[*]\"}, \"action\": {\"parsemode\": \"s\"}}",
"msg_proc_qty": 0,
"log_file": null,
"id_parent_job": null,
"end_date": 1674054257301,
"id_job": 7
}
Example of a more complex job command
curl -H 'Content-Type: application/json' -XPOST -d '{
"executions":[
{
"app_name":"xml2er",
"source":{
"file":{
"command":"/usr/share/flexter/samples/donut.xml.gz",
"enabled":true
},
"origin_id":{
"command":"-x",
"enabled":true,
"value":"11"
}
},
"target":{
"path":{
"command":"-o",
"enabled":true,
"value":"snowflake://<SNOWFLAKE_ADDRESS>?db=<DB>&schema=<SCHEMA>&warehouse=<WAREHOUSE>"
},
"format":[
{
"command":"-u",
"enabled":"true",
"value":"<USER>"
},
{
"command":"-p",
"enabled":"true",
"value":"<PASSWORD>"
}
],
"writing_mode":[
{
"command":"-S",
"enabled":"true",
"value":"o"
},
{
"command":"-e",
"enabled":"true",
"value":"D"
}
]
}
}
]
}' http://<FLEXTER_UI_SERVER>:<PORT>/v2/run/cmd | jq