ImportWorkflowDefinition

Updated at:

Imports a workflow node defined by FlowSpec and its internal child nodes into Data Studio.

Operation description

Important
  • This operation does not support importing multiple workflows. If more than one workflow is defined in the FlowSpec, all workflows after the first one are ignored.

  • This is an asynchronous operation. Calling this operation returns an asynchronous task object. To query the execution status of the task, call GetJobStatus.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dataworks:*

update

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

ProjectId

integer

Yes

The ID of the DataWorks workspace. You can log on to the DataWorks console and go to the workspace management page to obtain the ID.

This parameter specifies the DataWorks workspace used for this API invoke.

123456

Spec

string

Yes

The FlowSpec information that describes the workflow. For the specification details, see FlowSpec.

Note

How to quickly obtain a FlowSpec template?

  • Open a workflow in Data Studio, and then click "Show Spec" in the upper-right corner to obtain the FlowSpec description of the current workflow. You can use this FlowSpec description to quickly build a template that meets your requirements.

Note

<notice>This operation supports creating a workflow and its internal nodes at the same time. Pay attention to the IDs specified in the FlowSpec. If a specified ID already exists, the operation becomes an update. Only when no ID is specified or the ID does not exist does the operation become a create.></notice>

{ "version": "1.1.0", "kind": "CycleWorkflow", "spec": { "name": "Asynchronous_Workflow_Creation_Test", "id": "632647691239009XXXX", "type": "CycleWorkflow", "workflows": [ { "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test", "runtime": { "command": "WORKFLOW" } }, "id": "632647691239009XXXX", "trigger": { "type": "Scheduler", "cron": "00 03 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "strategy": { "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "failureStrategy": "Break" }, "name": "Asynchronous_Workflow_Creation_Test", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "632647691239009XXXX", "artifactType": "NodeOutput", "refTableName": "Asynchronous_Workflow_Creation_Test" } ] }, "nodes": [ { "recurrence": "Normal", "id": "742981001612325XXXX", "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test/111", "runtime": { "command": "ODPS_SQL" }, "content": "select now();\n" }, "trigger": { "type": "Scheduler", "cron": "00 24 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "name": "111", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "742981001612325XXXX", "artifactType": "NodeOutput", "refTableName": "111" } ] } }, { "recurrence": "Normal", "id": "595182137303408XXXX", "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test/222", "runtime": { "command": "ODPS_SQL" }, "content": "select now();\n select 1;" }, "trigger": { "type": "Scheduler", "cron": "00 00 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "name": "222", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "595182137303408XXXX", "artifactType": "NodeOutput", "refTableName": "222" } ] } } ], "dependencies": [ { "nodeId": "595182137303408XXXX", "depends": [ { "type": "Normal", "output": "742981001612325XXXX", "refTableName": "111" } ] } ] } ] } }

DryRun

boolean

No

Specifies whether to call this operation in validation mode. If this parameter is set to true, only the legality of the input workflow spec is validated. The same preprocessing and validation logic as the actual import is reused (with identical rules), but no data is persisted and no write operations are performed. The validation result is returned through an asynchronous task. If validation fails, the asynchronous task fails, and the error details include the error code, error message, and a JSONPath that locates the specific node (such as $.spec.workflows[0].nodes[1]).

Default value: false. In this case, the workflow is imported normally.

false

Response elements

Element

Type

Description

Example

object

Schema of Response

RequestId

string

The request ID. You can use this ID to troubleshoot issues.

7C352CB7-CD88-50CF-9D0D-E81BDF020E7F

AsyncJob

object

The asynchronous task status information.

Completed

boolean

Indicates whether the asynchronous task is complete.

false

CreateTime

integer

The timestamp when the asynchronous task was created.

1706581425000

Error

string

The error message when the asynchronous task fails.

target folder already exists: XXXX

Id

string

The ID of the asynchronous task.

1234567691239009XXXX

Progress

integer

The progress of the asynchronous task. Valid values: 0 to 100.

0

Response

string

The content that the asynchronous task is expected to return.

Note

This field currently stores the ID of the workflow created in the asynchronous task.

632647691239009XXXX

Status

string

The status of the asynchronous task.

Valid values:

  • Running: The task is running.

  • Success: The task succeeded.

  • Fail: The task failed.

  • Cancel: The task was canceled.

Running

Type

string

The operation type of the asynchronous task.

Valid values:

  • Create: creates a resource.

  • Cancel: cancels a creation task.

Create

Examples

Success response

JSON format

{
  "RequestId": "7C352CB7-CD88-50CF-9D0D-E81BDF020E7F",
  "AsyncJob": {
    "Completed": false,
    "CreateTime": 1706581425000,
    "Error": "target folder already exists: XXXX",
    "Id": "1234567691239009XXXX",
    "Progress": 0,
    "Response": "632647691239009XXXX",
    "Status": "Running",
    "Type": "Create"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.