New: build custom CDF applications with Cognite Flows. Documentation · What's new.
from cognite.client.data_classes import (
WorkflowVersionUpsert, WorkflowDefinitionUpsert,
WorkflowTask, FunctionTaskParameters,
)
function_task = WorkflowTask(
external_id="my_workflow-task1",
parameters=FunctionTaskParameters(
external_id="my_fn_xid",
data={"a": 1, "b": 2},
),
)
new_version = WorkflowVersionUpsert(
workflow_external_id="my_workflow",
version="1",
workflow_definition=WorkflowDefinitionUpsert(
tasks=[function_task],
description="This workflow has one step",
),
)
res = client.workflows.versions.upsert(new_version){
"items": [
{
"workflowExternalId": "<string>",
"version": "<string>",
"workflowDefinition": {
"hash": "<string>",
"tasks": [
{
"externalId": "<string>",
"type": "function",
"parameters": {
"function": {
"externalId": "my.known.id",
"data": {
"key1": "value1",
"key2": "value2"
}
},
"isAsyncComplete": false
},
"name": "<string>",
"description": "<string>",
"retries": 3,
"timeout": 3600,
"onFailure": "abortWorkflow",
"dependsOn": [
{
"externalId": "my.known.id"
}
],
"lineageAnnotation": {
"sources": [
{
"uri": "cdf://westeurope-1/my-project/domain/my-domain/raw/sensors/readings"
}
],
"targets": [
{
"uri": "cdf://westeurope-1/my-project/domain/my-domain/raw/sensors/readings"
}
]
}
}
],
"description": "<string>"
},
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000
}
]
}Required capabilities:
workflowOrchestrationACL:WRITE
Create or update a workflow version. Limited to a single workflow version per request.
from cognite.client.data_classes import (
WorkflowVersionUpsert, WorkflowDefinitionUpsert,
WorkflowTask, FunctionTaskParameters,
)
function_task = WorkflowTask(
external_id="my_workflow-task1",
parameters=FunctionTaskParameters(
external_id="my_fn_xid",
data={"a": 1, "b": 2},
),
)
new_version = WorkflowVersionUpsert(
workflow_external_id="my_workflow",
version="1",
workflow_definition=WorkflowDefinitionUpsert(
tasks=[function_task],
description="This workflow has one step",
),
)
res = client.workflows.versions.upsert(new_version){
"items": [
{
"workflowExternalId": "<string>",
"version": "<string>",
"workflowDefinition": {
"hash": "<string>",
"tasks": [
{
"externalId": "<string>",
"type": "function",
"parameters": {
"function": {
"externalId": "my.known.id",
"data": {
"key1": "value1",
"key2": "value2"
}
},
"isAsyncComplete": false
},
"name": "<string>",
"description": "<string>",
"retries": 3,
"timeout": 3600,
"onFailure": "abortWorkflow",
"dependsOn": [
{
"externalId": "my.known.id"
}
],
"lineageAnnotation": {
"sources": [
{
"uri": "cdf://westeurope-1/my-project/domain/my-domain/raw/sensors/readings"
}
],
"targets": [
{
"uri": "cdf://westeurope-1/my-project/domain/my-domain/raw/sensors/readings"
}
]
}
}
],
"description": "<string>"
},
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000
}
]
}Documentation Index
Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
Use this file to discover all available pages before exploring further.
Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
1 elementShow child attributes
Workflow version created/updated
1 elementShow child attributes
Was this page helpful?