This section briefly describes the various concepts of a serverless workflow.

For more information on the severless workflow specifications, see Serverless Workflow Specifications.

The following is a sample workflow.
id: greet
version: "1.0"
specVersion: "0.7"
name: Greet
description: Greets by name
start: Greet
functions:
  - name: greetingFunction
    operation: http://sample-api:8888/api/oa3/docs/openapi.json#greet
states:
  - name: Greet
    type: operation
    actions:
      - functionRef:
          refName: greetingFunction
          arguments:
            name: "${ .name }"
        actionDataFilter:
          toStateData: "${ .results }"
    stateDataFilter:
      output: "${ {message: .results.greeting} }"
    end: true
Parameter Description
name Name of the workflow.
id Unique ID of the workflow specific to a tenant.
description Describes the purpose of the workflow.
states

Building blocks of the workflow execution instructions. Defines the control flow logic of the tasks that the workflow should execute.

The execution flow of a workflow is defined by the transition/end fields in the states

  • end: This indicates that the workflow execution stops after this state. There may be one or more terminal states in a workflow.
  • transition: This indicates the next state in the workflow execution

For various state types available in Workflow Hub, see Workflow States section below.

start Indicates the name of the state from which the workflow execution begins

Workflow States

The following workflow states are available in Workflow Hub.
Note: Serverless Workflow defines several workflow states. However, only the following states are supported in Workflow Hub.
Name Description Sample Code
Operation Executes one or more of the following actions:
  • A REST API call - Uses OpenAPI-compliant schema and invokes the corresponding function
  • Publishes messages over Kafka Bus - Uses Async-API definitions and invokes the corresponding function
  • Custom functions
Note: A workflow function is a reusable definition for service invocations and can be referenced by its domain-specific name within the workflow states.
- name: Get_TCA_Session
  type: operation
  actions:
    - functionRef:
        refName: CreateTCASession
        arguments:
          tca: "${ .tca }"
          username: "${ .username }"
          password: "${ .password }"
          Content-Type: application/json
      actionDataFilter:
        results: '${ {"x-hm-authorization"} }'
  transition: Get_Vim_Tenant_By_Name

Obtains the TCA session authorization code by invoking the CreateTCASession function.

Sleep Pauses the workflow execution for a specific time duration
- name: Sleep_20S_and_Check_Rollback_Status_again
  type: sleep
  duration: PT20S
  transition: Get_Rollback_Status

Sleeps for 20 seconds and then fetches the rollback status.

Switch Defines the data-based workflow transitions.
- name: Check_CNF_Descriptor
   type: switch
   dataConditions:
     - name: check_CNFD
       condition: "${ .vnfdId | length > 5 }"
       transition: Get_CNF_Instance
   defaultCondition:
     transition: ERROR_CNF_DESCRIPTOR_NOT_FOUND
Checks if the CNF descriptor is valid or not:
  • If valid, it proceeds to fetch the CNF instance
  • If invalid, it transitions to ' ERROR_CNF_DESCRIPTOR_NOT_FOUND ' which terminates the workflow
Parallel Causes parallel execution of branches (set of actions)
- name: ParallelExec
   type: parallel
   completionType: allOf
   branches:
     - name: ShortDelayBranch
       actions:
         - subFlowRef: short-delay
     - name: LongDelayBranch
       actions:
         - subFlowRef: long-delay
   end: true

Executes all the branches of the parallel state.

ForEach Allows looping through an array of inputs and executes the same action on each of the inputs
- name: Process_Hosts_For_Provision_And_Resync
   type: foreach
   inputCollection: ${ .hosts }
   iterationParam: "host"
   outputCollection: "${ .processResult }"
   actions:
     - subFlowRef:
        workflowId: process_hosts_for_provision_and_resync
        version: 0.1.0
        actionDataFilter:
         fromStateData: '${.host }'
   transition: S1_SETUP_SUCCESSFUL

Loops through the array defined by hosts and with each value in the array defined by the variable hosts as input, and executes a child workflow ' process_hosts_for_provision_and_resync' with version 0.1.0.

Inject Injects static data into state data.
- name: SessionFailed
   type: inject
   data:
     error: 'error message'