What does a workflow look like?
Workflow structure
The following example workflow, createNSPUser, is available in the Create Workflow form for use as a workflow template. For detailed information about workflow design, see the Workflows tutorial on the Network Developer Portal.
The YAML definition of the workflow includes the following:
-
-
Tags are used to filter and group objects.
If a workflow is compliant with a set of format requirements, such as Service Fulfillment or Kafka triggers, a tag must be used to indicate what the workflow is configured for. For example, for a Kafka trigger to launch a workflow, the workflow must have a KafkaTrigger tag.
-
Metadata includes the workflow version number and dependencies
-
Input is the input parameters of a workflow or task, if required. The value of each parameter is a JSON-compliant type (number, string, etc), a dictionary, or a list.
It can also be an expression to retrieve a value from a task context, or any of the mentioned types containing inline expressions.
-
output (optional, not shown in the sample)
Output is a data structure containing expressions that define workflow output.
-
A task is a logical step that can perform a Mistral action, for example, performing a REST request.
Tasks can call other workflows. A task can also be iterated over a list of items performing bulk operations.
Tasks can be chained together based on success or failure of the previous task, or on completion of the previous task (always run). On-success and on-error chaining run subsequent tasks at the same time. On-complete chaining runs subsequent tasks in sequence.
-
The actions performed by the task take input data and produce output data, as defined by the action. NSP is packaged with a set of system actions. For example, std.http sends an HTTP request.
You can create ad-hoc actions to customize system actions. See What is an action? for more information.
-
Example workflow
version: '2.0'
createNSPUser:
description: creates a NSP user with the given Group Name. Creates a Group if the Group does not exist.
type: direct
tags:
- NSP USER
workflow_meta:
title: Create NSP user
author: WFM
version: '2.0.0'
dependencies:
platform:
nspOS: ['23.11']
input:
- username
- password
# password should contain at least one capital letter and one special character
- group
- passwordUpdateRequired: false
- accountEnabled: true
tasks:
getUserGroup:
action: nsp.https
input:
url: 'https://rest-gateway/access-control-api/rest/api/v3/nspuac/group/<% $.group %>'
method: GET
contentType: 'application/json'
accept: 'application/json'
publish:
status: <% task().result.status %>
publish-on-error:
status: <% task().result.status %>
on-error:
- createUserGroup
on-success:
- createUser
createUserGroup:
action: nsp.https
input:
url: 'https://rest-gateway/access-control-api/rest/api/v3/nspuac/group/'
method: POST
body:
userGroupName: <% $.username %>
roles: []
publish:
status: <% task().result.status %>
on-success:
- createUser
createUser:
action: nsp.https
input:
url: 'https://<% locate_nsp() %>/nsp-keycloak-api/rest/api/v2/user-management/realm/Nokia/users/'
method: POST
body:
userName: <% $.username %>
password: <% $.password %>
group: <% $.group %>
accountEnabled: <% $.accountEnabled %>
passwordUpdateRequired: <% $.passwordUpdateRequired %>
publish:
result: <% task().result.status %>