Save Flow

Save the information of the current workflow.

Prerequisites

The user must be the owner of the workflow.

Request Format

POST https://{apigw-address}/dataflow-batch-service/v2.0/flows?action=save&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

id

true

Integer

Workflow ID

type

true

Integer

Scheduling type of the workflow (0: Manual; 1: Periodic; 2: Temporary)

name

true

String

Name of the workflow

freq

true

String

Use the CronTab syntax to specify the time to start the workflow in a scheduling cycle (specify a 7-character CronTab expression). For more information about CronTab, see http://cron.qqe2.com/

cycle

true

String

Scheduling cycle (M: Month; W: Week; D: Day; H: Hour; mi: Minute)

alert_mode

true

Integer

Alert mode (0: Not enabled; 1: Email; 2: SMS; 3: Email and SMS)

do_as

true

String

OU account which the workflow belongs to

owners

true

String

Owner of the workflow

visitors

true

String

Users who can access the workflow (separated by semicolon)

start_time

true

String

Effective date of the workflow

active

true

Integer

Scheduling status of the workflow (0: Pause; 1: Start)

parameters

false

List<Map<key,value>>

Parameters that are configured for the workflow to dynamically adapt to the environment changes (by the format of key=value)

desc

false

String

Description of the workflow

queue

false

String

Computing queue

tasks

false

List<TaskSimpleInfo>

Collection of all task nodes in the workflow, with each element representing a TaskSimpleInfo struct, which contains basic information of a task node. See TaskSimpleInfo Struct

flows

false

List<FlowSimpleInfo>

Collection of workflows that have dependency relation with the workflow. See FlowSimpleInfo Struct

relations

false

List<Relation>

Collection of task relations, with each element representing the upstream and downstream dependency between tasks in the workflow. See Relation Struct

Response Parameters

Name

Data Type

Description

data

FlowID Struct

ID of the workflow that is saved

Error Code

Code

Message

Description

62102

graph not found

Format of the graph parameter is invalid

62105

Your account has been locked

User account is locked. Please contact the administrator.

Sample

Request Sample

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

method: POST

requestBody:
{
    "id":"2515",
    "type":1,
    "name":"fpostm",
    "freq":"0 0 0 * * ? *",
    "cycle":"D",
    "alert_mode":3,
    "do_as":"data_oxxxx",
    "parameters":"[]",
    "owners":";xxxxx;",
    "desc":"e",
    "start_time":"2019-07-23",
    "visitors":";xxxxx;",
    "active":0,
    "queue":"",
    "tasks":[
        {
            "task_name":"tass",
            "x":0.0132,
            "y":0.008100000381469727,
            "task_id":"104575",
            "node_id":"t_104575"
        },
        {
            "task_name":"gg",
            "x":0.0084,
            "y":0.014199999237060546,
            "task_id":"104590",
            "node_id":"t_104590"
        },
        {
            "task_name":"dff",
            "x":0.0352,"y":0.008300002288818359,
            "task_id":"104901","node_id":"t_104901"
        }
            ],
    "flows":
            [
        {
            "is_virtual":false,
            "flow_id":"2788",
            "x":0.0186,
            "flow_name":"jin",
            "y":0.0016999999046325683,
            "node_id":"f_2788"},
            {"flow_id":"2819",
            "flow_name":"104891(tass)",
            "node_id":"f_2819",
            "is_virtual":true,
            "x":0.0125,
            "y":0.023800001525878908}],
    "relations":
    [
        {
            "cycle_gap":"D0",
            "source":"t_104575",
            "rerun":true,
            "target":"t_104590"
            },
        {
            "cycle_gap":"D0",
            "source":"f_2788",
            "rerun":false,
            "target":"t_104575"
            }
    ]
}

Return Sample

{
  "status": 0,
  "msg": "Success",
  "data": {
    "flowId": 2841
  }
}

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 saveFlowTest(){
        //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>(2);
        hashMap.put("type",1);
        hashMap.put("name","testWorkflow");
        hashMap.put("cycle","D");
        hashMap.put("freq","0 0 0 * * ? *");
        hashMap.put("parameters","[]");
        hashMap.put("alert_mode",3);
        hashMap.put("alert_to","");
        hashMap.put("id","2515");
        hashMap.put("do_as","yourDoas");
        hashMap.put("visitors","yourVisitors");
        hashMap.put("owners","yourOwners");
        hashMap.put("active",0);
        hashMap.put("queue","");
        hashMap.put("start_time","2019-07-25");
        JSONArray jsonArrayTasks = new JSONArray();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("task_name","tass");
        jsonObject.put("x",0.0132);
        jsonObject.put("y",0.008100000381469727);
        jsonObject.put("task_id","104575");
        jsonObject.put("node_id","t_104575");
        jsonArrayTasks.add(jsonObject);
        hashMap.put("tasks",jsonArrayTasks);
        JSONArray jsonArray = new JSONArray();
        hashMap.put("relations",jsonArray);
        hashMap.put("flows",jsonArray);
        request.setQueryParam("userId","your_userId");
        request.setBodyParam(hashMap);
        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=save")
                    .getResponse(request, JSONObject.class);

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