Import Flow¶
Import workflow configuration to create a workflow with the specified name under the specified directory.
Prerequisites¶
The user must be the owner of the workflow.
Request Format¶
POST https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=import&userId={}&orgId={}
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Required or Not |
Data Type |
Description |
---|---|---|---|---|
userId |
Query |
true |
String |
User ID. How to get userId>> |
orgId |
Query |
true |
String |
Organization ID which the user belongs to. How to get orgId>> |
Request Parameters (Body)¶
Name |
Required or Not |
Data Type |
Description |
---|---|---|---|
flowId |
false |
Integer |
Workflow ID (If not specified, or the specified flowId already exists, the system will generate a flowId automatically) |
flowName |
true |
String |
Name of the workflow |
desc |
true |
String |
Description of the workflow |
dirId |
true |
String |
ID of the directory for the workflow |
flowJson |
true |
Flow Struct |
Detailed information of the workflow. See Flow Struct |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
FlowId Struct |
Workflow ID information. See FlowId Struct |
FlowId Struct¶
Sample¶
{
"flowId":2781
}
Parameters¶
Name |
Data Type |
Description |
---|---|---|
flowId |
String |
ID of the created workflow |
Error Code¶
Code |
Message |
Description |
---|---|---|
62102 |
One of the following messages can be returned:
|
Invalid parameter |
62109 |
Workflow creating failed: xx |
Failed to create the workflow because of server internal exception |
Sample¶
Request Sample¶
url: https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=import&userId={}&orgId={}
method: POST
requestBody:
{
"flowName": "modify",
"desc": "",
"dirId": "*************",
"flowJson":
{
"name": "workflow1",
"cycle": "D",
"cron": "0 0 0 * * ? *",
"parameters": "[]",
"alert_mode": 3,
"alert_to": "",
"app_id": "",
"submitter": " submitter",
"owners": " owners",
"visitors": " visitors",
"type": 1,
"sync_type": 1,
"desc": "",
"start_time": "2019-07-25",
"tasks": [
{
"name": "tass",
"resource": "default",
"type": "COMMAND",
"sync_type": 1,
"cmd": "echo "hello"",
"submitter": "",
"filePackage": "",
"cron": "",
"priorityLevel": 0,
"timeout": 300,
"retryLimit": 3,
"retryInterval": 0,
"successCode": "0",
"waitCode": "",
"asLink": false
}
],
"flow_links": [],
"task_links": [],
"relations": [],
"link_relations": []
}
}
Return Sample¶
{
"status": 0,
"msg": "Success",
"data": {
"flowId": 2839
}
}
Java SDK Sample¶
import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
public class Request extends PoseidonRequest {
public void setQueryParam(String key, Object value){
QueryParams().put(key, value);
}
public void setHeaderParam(String key, String value){
headerParams().put(key, value);
}
public void setBodyParam(Map<String, Object> bodyPara){
bodyParams().putAll(bodyPara);
}
public void setMethod(String method) {
this.method = method;
}
private String method;
public String baseUri() {
return "";
}
public String method() {
return method;
}
}
public void importFlowTest(){
//1. Select Application Registration from the left navigation bar of EnOS Console.
//2. Open the App Detail page to get the AccessKey and SecretKey of the application.
String accessKey = "******************";
String secretKey = "******************";
//Create a request and save the required parameters in the map of the Query.
Request request = new Request();
HashMap<String,Object> hashMap = new HashMap<String, Object>(20);
hashMap.put("name","testWorkflow");
hashMap.put("cycle","D");
hashMap.put("cron","0 0 0 * * ? *");
hashMap.put("parameters","[]");
hashMap.put("alert_mode",3);
hashMap.put("alert_to","");
hashMap.put("app_id","");
hashMap.put("submitter","yourSubmitter");
hashMap.put("owners","yourOwners");
hashMap.put("visitors",";yourVisitors;");
hashMap.put("type",1);
hashMap.put("sync_type",1);
hashMap.put("desc","");
hashMap.put("start_time","2019-07-25");
JSONArray jsonArrayTasks = new JSONArray();
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","tass");
jsonObject.put("resource","default");
jsonObject.put("type","COMMAND");
jsonObject.put("sync_type",1);
jsonObject.put("cmd","echo "hello"");
jsonObject.put("submitter","");
jsonObject.put("filePackage","");
jsonObject.put("cron","");
jsonObject.put("priorityLevel",0);
jsonObject.put("timeout",300);
jsonObject.put("retryLimit",3);
jsonObject.put("retryInterval",0);
jsonObject.put("successCode","0");
jsonObject.put("waitCode","");
jsonObject.put("asLink",false);
jsonArrayTasks.add(jsonObject);
hashMap.put("tasks",jsonArrayTasks);
JSONArray jsonArray = new JSONArray();
hashMap.put("flow_links",jsonArray);
hashMap.put("task_links",jsonArray);
hashMap.put("relations",jsonArray);
hashMap.put("link_relations",jsonArray);
HashMap<String,Object> bodyMap = new HashMap<String, Object>(4);
bodyMap.put("flowName","myFlow1");
bodyMap.put("desc","this is flow");
bodyMap.put("dirId","***************");
bodyMap.put("flowJson",hashMap );
request.setQueryParam("userId","your_userId");
request.setQueryParam("orgId","your_orgId");
request.setBodyParam(bodyMap);
request.setMethod("POST");
try {
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=import")
.getResponse(request, JSONObject.class);
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
}