Export Flow

Export the workflow configuration.

Prerequisites

The user must belong to the OU which the target workflow belongs to.

Request Format

GET https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=export&flowId={}&userId={}&orgId={}

Request Parameters (URI)

Name Location (Path/Query) Required or Not Data Type Description
flowId Query true Integer Workflow ID
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>>

Response Parameters

Name Data Type Description
data Flow Struct Detailed information of the workflow. See Flow Struct

Flow Struct

Sample

{
    "name": "workflow1",
    "cycle": "D",
    "cron": "0 0 0 * * ? *",
    "parameters": "[]",
    "alert_mode": 3,
    "alert_to": "",
    "app_id": "",
    "submitter": "data_oxxxxxx",
    "owners": "xxxx",
    "visitors": "xxxx;",
    "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": []
}

Parameters

Name Data Type Description
name String Name of the workflow
cycle String Scheduling cycle (M: Month; W: Week; D: Day; H: Hour; mi: Minute)
cron String If CronTab syntax is used when specifying the time to start the workflow in a scheduling cycle, a 7-character CronTab expression is used. For more information about CronTab, see http://cron.qqe2.com/
parameters List<Map<key,value>> Global parameters that are configured for the workflow to dynamically adapt to the environment changes (in the format of key=value).
alert_mode Integer Alert mode (0: Not enabled; 1: Email; 2: SMS; 3: Email and SMS)
alert_to String Receiver of alerts
app_id String Null string
submitter String User who submitted the workflow
owners String Owner of the workflow
visitors String Users who can access the workflow (separated by semicolon)
type Integer Scheduling type of the workflow (0: Manual; 1: Periodic; 2: Temporary)
sync_type Integer Sync type of the workflow (0: File synchronization; 1: Data synchronization)
desc String Description of the workflow
start_time String Effective date of the workflow
tasks List<Task> Collection of task nodes in the workflow, with each element representing a task in the workflow. See Task Struct
flow_links List<FlowLink> Collection of workflow references, with each element representing a source workflow that the current workflow depends on (Using the link_id field in the FlowLink Struct, you can find the related link relation in the link_relations collection. The link relation represents the relationship between a specific task in the current workflow with the source workflow).
task_links List<TaskLink> Collection of task references, with each element representing a task in a source workflow that a task in the current workflow depends on (Using the link_id field in the TaskLink Struct, you can find the related link relation in the link_relations collection. The link relation represents the relationship between a specific task in the current workflow with the source workflow).
relations List<Relation> Collection of relations, with each element representing the upstream and downstream dependency between tasks. See Relation Struct
link_relations List<LinkRelation> Collection of link relations. See LinkRelation Struct

Task Struct

Sample

{
    "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
 }

Parameters

Name Data Type Description
name String Name of the task
resource String Task resource
type Integer Task type (0: Data Integration; 1: WORMHOLE; 2: CALCULATE; 3: SHELL: 4: CANAAN; 5: HIVE; 6: MR)
sync_type Integer Sync type of the task (0: File synchronization; 1: Data synchronization)
cmd String Command line
submitter String User who submitted the task
filePackage String File location
cron String Time for task scheduling
priorityLevel Integer Priority level of the task
timeout Integer Timeout value
retryLimit Integer Retry times
retryInterval Integer Interval for retry
successCode String Returned code for success
waitCode String Null string
asLink Boolean Whether the task has dependency relation with other tasks

Relation Struct

Sample

{
    "source_task_name": "tass",
    "target_task_name": "rf",
    "rerun": true
}

Parameters

Name Data Type Description
source_task_name String Name of the upstream task
target_task_name String Name of the downstream task
rerun Boolean Whether the downstream task will be started when rerunning (effective only for task-level rerunning)

LinkRelation Struct

Sample

{
    "link_id": "0",
    "target_task_name": "tass",
    "rerun": false
}

Parameters

Name Data Type Description
link_id String Link ID
target_task_name String Name of the downstream task
rerun Boolean Whether the downstream task will be started when rerunning

Error Code

Code Message Description
62102 Flow validation exception Format of the request body is invalid
62109 Server internal exception Server internal exception

Sample

Request Sample

url: https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=export&flowId={}&userId={}&orgId={}

method: GET

Return Sample

{
  "status": 0,
  "msg": "Success",
  "data": {
    "name": "nFlow",
    "cycle": "D",
    "cron": "0 0 0 * * ? *",
    "parameters": "[]",
    "alert_mode": 3,
    "alert_to": "",
    "app_id": "",
    "submitter": "xxxx",
    "owners": "xxxx",
    "visitors": ";xxxx;",
    "type": 1,
    "sync_type": 1,
    "desc": "ga",
    "start_time": "2019-07-24",
    "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": []
  }
}

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 exportFlowTest(){
        //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();
        request.setQueryParam("flowId","2924");
        request.setQueryParam("userId","your_userId");
        request.setQueryParam("orgId","your_orgId");
        request.setMethod("GET");

        try {
            JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                    .url("https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=export")
                    .getResponse(request, JSONObject.class);

            System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }