Skip to content

Latest commit

 

History

History
253 lines (230 loc) · 9.95 KB

create_task.md

File metadata and controls

253 lines (230 loc) · 9.95 KB

Functional description

Create a task with a flow template

Request Parameters

General Parameters

Field Type Required Description
bk_app_code string YES APP ID
bk_app_secret string YES APP Secret(APP TOKEN), which can be got via BlueKing Developer Center -> Click APP ID -> Basic Info
bk_token string NO Current user login token, bk_token or bk_username must be valid, bk_token can be got by Cookie
bk_username string NO Current user username, APP in the white list, can use this field to specify the current user

Interface Parameters

Field Type Required Description
bk_biz_id string YES the business ID
template_id string YES the flow template ID
template_source string NO source of flow,default value is business. business: from business, common: from common flow
name string YES Task name
flow_type string NO flow type,common: common flow,common_func:functional flow
constants dict NO global variables,details are described below
exclude_task_nodes_id list NO nodes id not be executed, which are set ignore in flow

constants.KEY

constant KEY, the format is like ${key}

constants.VALUE

constant value, the type of value should be same with data from API[get_template_info]

Request Parameters Example

{
    "bk_app_code": "esb_test",
    "bk_app_secret": "xxx",
    "bk_token": "xxx",
    "name": "tasktest",
    "flow_type": "common",
    "constants": {
        "${content}: "echo 1",
        "${params}": "",
        "${script_timeout}": 20
    }
}

Return Result Example

{
    "result": true,
    "data": {
        "task_id": 10,
        "task_url": "http://bk_sops_host/taskflow/execute/3/?instance_id=15364",
        "pipeline_tree": {
            "activities": {
                "node9b5ae13799d63e179f0ce3088b62": {
                    "outgoing": "line27bc7b4ccbcf37ddb9d1f6572a04",
                    "incoming": "line490caa49d2a03e64829693281032",
                    "name": "timing",
                    "error_ignorable": false,
                    "component": {
                        "code": "sleep_timer",
                        "data": {
                            "bk_timing": {
                                "hook": false,
                                "value": "2"
                            }
                        }
                    },
                    "stage_name": "步骤1",
                    "can_retry": true,
                    "isSkipped": true,
                    "type": "ServiceActivity",
                    "optional": false,
                    "id": "node9b5ae13799d63e179f0ce3088b62",
                    "loop": null
                },
                "node880ded556c6c3c269be3cedc64b6": {
                    "outgoing": "line490caa49d2a03e64829693281032",
                    "incoming": "lineb83161d6e0593ad68d9ec73a961b",
                    "name": "暂停",
                    "error_ignorable": false,
                    "component": {
                        "code": "pause_node",
                        "data": {}
                    },
                    "stage_name": "步骤1",
                    "can_retry": true,
                    "isSkipped": true,
                    "type": "ServiceActivity",
                    "optional": true,
                    "id": "node880ded556c6c3c269be3cedc64b6",
                    "loop": null
                }
            },
            "end_event": {
                "type": "EmptyEndEvent",
                "outgoing": "",
                "incoming": "line27bc7b4ccbcf37ddb9d1f6572a04",
                "id": "node5c48f37aa9f0351e8b43ab6a2295",
                "name": ""
            },
            "outputs": [],
            "flows": {
                "line490caa49d2a03e64829693281032": {
                    "is_default": false,
                    "source": "node880ded556c6c3c269be3cedc64b6",
                    "id": "line490caa49d2a03e64829693281032",
                    "target": "node9b5ae13799d63e179f0ce3088b62"
                },
                "lineb83161d6e0593ad68d9ec73a961b": {
                    "is_default": false,
                    "source": "noded383bc1d7387391f889c6bab18b8",
                    "id": "lineb83161d6e0593ad68d9ec73a961b",
                    "target": "node880ded556c6c3c269be3cedc64b6"
                },
                "line27bc7b4ccbcf37ddb9d1f6572a04": {
                    "is_default": false,
                    "source": "node9b5ae13799d63e179f0ce3088b62",
                    "id": "line27bc7b4ccbcf37ddb9d1f6572a04",
                    "target": "node5c48f37aa9f0351e8b43ab6a2295"
                }
            },
            "gateways": {},
            "line": [
                {
                    "source": {
                        "id": "node9b5ae13799d63e179f0ce3088b62",
                        "arrow": "Right"
                    },
                    "target": {
                        "id": "node5c48f37aa9f0351e8b43ab6a2295",
                        "arrow": "Left"
                    },
                    "id": "line27bc7b4ccbcf37ddb9d1f6572a04"
                },
                {
                    "source": {
                        "id": "node880ded556c6c3c269be3cedc64b6",
                        "arrow": "Right"
                    },
                    "target": {
                        "id": "node9b5ae13799d63e179f0ce3088b62",
                        "arrow": "Left"
                    },
                    "id": "line490caa49d2a03e64829693281032"
                },
                {
                    "source": {
                        "id": "noded383bc1d7387391f889c6bab18b8",
                        "arrow": "Right"
                    },
                    "id": "lineb83161d6e0593ad68d9ec73a961b",
                    "target": {
                        "id": "node880ded556c6c3c269be3cedc64b6",
                        "arrow": "Left"
                    }
                }
            ],
            "start_event": {
                "type": "EmptyStartEvent",
                "outgoing": "lineb83161d6e0593ad68d9ec73a961b",
                "incoming": "",
                "id": "noded383bc1d7387391f889c6bab18b8",
                "name": ""
            },
            "id": "node7ef6970d06ad3bc092594cb5ec5f",
            "constants": {},
            "location": [
                {
                    "stage_name": "步骤1",
                    "name": "暂停",
                    "y": 135,
                    "x": 300,
                    "type": "tasknode",
                    "id": "node880ded556c6c3c269be3cedc64b6"
                },
                {
                    "y": 150,
                    "x": 1000,
                    "type": "endpoint",
                    "id": "node5c48f37aa9f0351e8b43ab6a2295"
                },
                {
                    "stage_name": "步骤1",
                    "name": "timing",
                    "y": 135,
                    "x": 595,
                    "type": "tasknode",
                    "id": "node9b5ae13799d63e179f0ce3088b62"
                },
                {
                    "y": 150,
                    "x": 80,
                    "type": "startpoint",
                    "id": "noded383bc1d7387391f889c6bab18b8"
                }
            ]
        }
    }
}

Return Result Description

Field Type Description
result bool true/false, indicate success or failure
data dict data returned when result is true, details are described below
message string error message returned when result is false

data

Field Type Description
task_id int the task instance ID
task_url str task instance url
pipeline_tree dict task pipeline tree

data.pipeline_tree

Field Type Description
start_event dict start node
end_event dict end node
activities dict task node(standard plugins or subprocess)info
gateways dict gateways(parallel gateway、exclusive gateway、exclusive gateway)info
flows dict sequenceFlow(the line between nodes)info
constants dict global variables, details are described below
outputs list outputs info, indicate outputs field of global

data.pipeline_tree.constants.KEY

KEY, the format is like ${key}

data.pipeline_tree.constants.VALUE

Field Type Description
key string same with KEY
name string name
index int display order at the front end
desc string description
source_type string source of variable, custom mean manual variable, component_inputs means variables comes from task node inputs parameters, component_outputs means variables comes from task node outputs parameters
custom_type string custom type, which is not empty when source_type is custom, the value is input ,or textarea, or datetime, or int
source_tag string source tag and standard plugin info, which is not empty when source_type is component_inputs or component_outputs
source_info dict source info about task node ID