{
  "servicename": "workflow",
  "definitions": {
    "deftaskjson": {
      "description": "This json object has one or more task objects. The name of the object can be any alphanumeric character plus hyphe and underscore",
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^[A-Za-z][A-Za-z0-9-_]*$": {
          "description": "Each task of specific structure",
          "type": "object",
          "anyOf": [
            {
              "required": [
                "service",
                "servicepath",
                "nextTasks"
              ]
            },
            {
              "required": [
                "service",
                "servicepath",
                "synch"
              ]
            },
            {
              "required": [
                "service",
                "servicepath",
                "switch"
              ]
            },
            {
              "required": [
                "service",
                "servicepath",
                "if"
              ]
            },
            {
              "required": [
                "service"
              ]
            },
            {
              "required": [
                "url",
                "nextTasks"
              ]
            },
            {
              "required": [
                "url",
                "synch"
              ]
            },
            {
              "required": [
                "url",
                "switch"
              ]
            },
            {
              "required": [
                "url",
                "if"
              ]
            },
            {
              "required": [
                "url"
              ]
            },
            {
              "required": [
                "shellcmd",
                "nextTasks"
              ]
            },
            {
              "required": [
                "shellcmd",
                "synch"
              ]
            },
            {
              "required": [
                "shellcmd",
                "switch"
              ]
            },
            {
              "required": [
                "shellcmd",
                "if"
              ]
            },
            {
              "required": [
                "noop"
              ]
            },
            {
              "required": [
                "shellcmd"
              ]
            }
          ],
          "properties": {
            "noop": {
              "type": "boolean",
              "description": "true for empty task that simply is used to launch next tasks or used as synch point for other tasks"
            },
            "shellcmd": {
              "description": "Shell command. payload has special parameter called args which defines the arg stucture",
              "type": "string"
            },
            "url": {
              "description": "fully qualified url",
              "type": "string"
            },
            "service": {
              "description": "cirrus installed service name",
              "type": "string"
            },
            "servicepath": {
              "description": "In the cirrus service, url of the specific route e.g. plan/task/add is this route path in workflow service",
              "type": "string"
            },
            "sysservice": {
              "description": "Indicates to the workflow that the service is to be located only in the system services. If false or not present, it will look in appservices first and then system services",
              "type": "boolean"
            },
            "wait": {
              "description": "How long to wait before the task is executied",
              "type": "number"
            },
            "maxnuminvoke": {
              "description": "maximum number of times this task is allowed to be invoked in one execution session",
              "type": "number"
            },
            "retry": {
              "description": "maximum number of the service will be retried in case of error",
              "type": "number"
            },
            "pipe": {
              "description": "if true the response from parent task will be added to the payload. Note if the same named field exists in the response of parent as payload, the response field will replace it",
              "type": "boolean"
            },
            "start": {
              "description": "Set this to be start task if set to true",
              "type": "boolean"
            },
            "security": {
              "description": "Applicable only in case of url based task. It can be accesskey which use hmac encryption or basic which is simply base64 encoding of the keys. If the url is secured by accesskey and secretkey, the type of security also needs to be specified",
              "type": {
                "enum": [
                  "appkey",
                  "accesskey",
                  "basic",
                  "jwt"
                ]
              }
            },
            "headers": {
              "description": "array of optional http header values that can be passed at the time of invoking the task",
              "type": "object",
              "patternProperties": {
                "^[A-Za-z][A-Za-z0-9-_]*$": {
                  "type": "string"
                }
              }
            },
            "appkey": {
              "description": "appkey needed to access the service if security is set to appkey",
              "type": "string"
            },
            "acckey": {
              "description": "access key portion of security credentials",
              "type": "string"
            },
            "secretna": {
              "description": "secret key portion of security credentials",
              "type": "string"
            },
            "jwttoken": {
              "description": "the jwt token value",
              "type": "string"
            },
            "nextTasks": {
              "$ref": "#/definitions/defnextTasks"
            },
            "switch": {
              "type": "array",
              "description": "Array of condition objects. The task fires or is activated if the conditional evaluates to true ",
              "items": {
                "type": "object",
                "anyOf": [
                  {
                    "required": [
                      "field",
                      "op",
                      "value",
                      "nextTasks"
                    ]
                  },
                  {
                    "required": [
                      "var",
                      "op",
                      "value"
                    ]
                  },
                  {
                    "required": [
                      "default",
                      "nextTasks"
                    ]
                  }
                ],
                "properties": {
                  "default": {
                    "description": "default case. if all the conditionals fail these tasks will be executed",
                    "type": "boolean"
                  },
                  "var": {
                    "description": "name of the variable in the outputvars",
                    "type": "string"
                  },
                  "field": {
                    "description": "name of the field in the payload",
                    "type": "string"
                  },
                  "op": {
                    "description": "can be ==, <, <=, >, >=",
                    "type": "string"
                  },
                  "value": {
                    "description": "can be any string value that the field will be compared to",
                    "type": "string"
                  },
                  "nextTasks": {
                    "$ref": "#/definitions/defnextTasks"
                  }
                }
              }
            },
            "if": {
              "description": "Array of condition objects. The task fires or is activated if the conditional evaluates to true ",
              "type": "object",
              "anyOf": [
                {
                  "required": [
                    "field",
                    "op",
                    "value",
                    "nextTasks"
                  ]
                },
                {
                  "required": [
                    "var",
                    "op",
                    "value"
                  ]
                }
              ],
              "properties": {
                "field": {
                  "description": "name of the field in the payload",
                  "type": "string"
                },
                "var": {
                  "description": "name of the variable in the outputvars",
                  "type": "string"
                },
                "op": {
                  "description": "can be ==, <, <=, >, >=",
                  "type": "string"
                },
                "value": {
                  "description": "can be any string value that the field will be compared to",
                  "type": "string"
                },
                "nextTasks": {
                  "$ref": "#/definitions/defnextTasks"
                }
              }
            },
            "else": {
              "description": "Array of condition objects. The task fires or is activated if the conditional evaluates to true ",
              "type": "object",
              "required": [
                "nextTasks"
              ],
              "properties": {
                "nextTasks": {
                  "$ref": "#/definitions/defnextTasks"
                }
              }
            },
            "synch": {
              "$ref": "#/definitions/defsyncharr"
            },
            "urlencodepayload": {
              "description": "only set to true if it's a url task and if payload is of application/x-www-form-urlencoded. This will cause the payload to be urlencoded",
              "type": "boolean"
            },
            "payload": {
              "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init. It can also be a string in non-REST scenario e.g. urlencoded form data",
              "oneOf": [
                {
                  "type": "object"
                },
                {
                  "type": "string"
                }
              ]
            },
            "payloads": {
              "oneOf": [
                {
                  "type": "array",
                  "description": "Array of payload objects.",
                  "items": {
                    "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init. It can also be a string in non-REST scenario e.g. urlencoded form data",
                    "oneOf": [
                      {
                        "type": "object"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  }
                },
                {
                  "type": "string",
                  "description": "should only be used as $vars string so that it can be replaced by an array at runtime."
                }
              ]
            },
            "outputvar": {
              "description": "output of this task will be available for subsequent tasks under this name in the payload json. Also if you put $vars (separated by space) in any string in payload it will substitute it with the stringified version of all the output vars thus far.",
              "type": "string"
            },
            "vars": {
              "description": "named variables with full json representation for values is supported. Access these variables just as you would access outputvar. Note these are global to teh plan and need to be unique",
              "type": "object"
            },
            "clearvars": {
              "description": "empties outputvar cache. All previous outputvar data will not be available in payload.",
              "type": "boolean"
            },
            "allowerrors": {
              "description": "Allow errors in case of payloads only.",
              "type": "boolean"
            }
          }
        }
      }
    },
    "defcondition": {
      "type": "object",
      "description": "conditional object which contains a task and the corresponding condition upon which the task becomes activated",
      "properties": {
        "task": {
          "type": "string"
        },
        "condition": {
          "type": "object",
          "additionalProperties": false,
          "anyOf": [
            {
              "required": [
                "field",
                "op",
                "value"
              ]
            },
            {
              "required": [
                "var",
                "op",
                "value"
              ]
            },
            {
              "required": [
                "default"
              ]
            }
          ],
          "description": "the task fires or is activated if the conditional evaluates to true ",
          "properties": {
            "field": {
              "description": "name of the field in the payload",
              "type": "string"
            },
            "var": {
              "description": "name of the variable in the outputvars",
              "type": "string"
            },
            "op": {
              "description": "can be ==, <, <=, >, >=",
              "type": "string"
            },
            "value": {
              "description": "can be any string value that the field will be compared to",
              "type": "string"
            }
          }
        }
      }
    },
    "defsyncharr": {
      "description": "Array of synch objects where each element is a task name or a conditaional or another syncharray in the taskjson",
      "type": "object",
      "required": [
        "op",
        "arr"
      ],
      "properties": {
        "op": {
          "description": "operator values are & means all task will have to complete and | means any one of the tasks needs to complete for the synch operation to fire",
          "type": "string"
        },
        "arr": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/definitions/defcondition"
              },
              {
                "$ref": "#/definitions/defsyncharr"
              }
            ]
          }
        }
      }
    },
    "defnextTasks": {
      "description": "Array of nextTasks where each element is a task name or an object with task name plus boolean indicating if the output of current task needs to be piped to the next task in the taskjson",
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "required": [
              "task"
            ],
            "properties": {
              "task": {
                "type": "string"
              },
              "pipe": {
                "type": "boolean"
              }
            }
          }
        ]
      }
    }
  },
  "routes": [
    {
      "route": "/plans",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetPlans",
      "description": "Get list of plans registered"
    },
    {
      "route": "/plans",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteCreatePlan",
      "description": "Add a new plan. You can either create an empty plan and add/insert/synch tasks or create a plan from task json which is passed as parameter",
      "bodyschema": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "planname",
              "priority",
              "interval",
              "start",
              "taskjson"
            ]
          },
          {
            "required": [
              "planname",
              "priority",
              "interval"
            ]
          },
          {
            "required": [
              "planname",
              "priority",
              "cron",
              "start",
              "taskjson"
            ]
          },
          {
            "required": [
              "file"
            ]
          },
          {
            "required": [
              "planname",
              "priority",
              "cron"
            ]
          }
        ],
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "priority": {
            "description": "priority of the plan a number between 0 and 1000. Lower the number higher the priority ",
            "type": "number",
            "minimum": 0,
            "maximum": 1000
          },
          "interval": {
            "description": "interval in ms that the job or plan will repeat. Note the plan will repeat only at the next interval opportunity after it completes execution",
            "type": "number",
            "minimum": 0
          },
          "cron": {
            "description": "cron like syntax",
            "type": "string",
            "pattern": "^(((\\d+,)+\\d+|(\\d+(\\/|-)\\d+)|\\d+|\\*|(\\*(\\/|-)\\d+)) ?){5,7}$"
          },
          "delwhendone": {
            "description": "Automatically delete the plan after execution is complete. This is not valid for plans that repeat aka jobs",
            "type": "boolean"
          },
          "file": {
            "description": "file with json description of the plan",
            "type": "string"
          },
          "start": {
            "description": "Task to start the execution from",
            "type": "string"
          },
          "errortask": {
            "description": "Task to catch errors. Can be used to notify the errors. Error is in $vars.err as $vars.err.message and $vars.err.status",
            "type": "string"
          },
          "taskjson": {
            "$ref": "#/definitions/deftaskjson"
          }
        }
      },
      "examples": [
        {
          "param": "/plans",
          "payload": {
            "planname": "planservice",
            "start": "task0",
            "priority": 100,
            "interval": 0,
            "taskjson": {
              "task0": {
                "service": "taskserver",
                "servicepath": "task0",
                "payload": {
                  "bar": "task0",
                  "f": 1
                },
                "pipe": true,
                "nextTasks": [
                  "task1",
                  "task2",
                  "task3"
                ]
              },
              "task1": {
                "service": "taskserver",
                "servicepath": "task1",
                "pipe": false,
                "nextTasks": [
                  {
                    "task": "task2",
                    "pipe": true
                  },
                  "task4",
                  "task7"
                ],
                "wait1": 300,
                "priority": 20,
                "maxnuminvoke": 3,
                "retry": 5,
                "synch": {
                  "op": "|",
                  "arr": [
                    "task0",
                    "task4"
                  ]
                }
              },
              "task2": {
                "service": "taskserver",
                "servicepath": "task2",
                "pipe": false,
                "wait1": 300,
                "maxnuminvoke": 2,
                "foo": "bar",
                "synch": {
                  "op": "|",
                  "arr": [
                    "task0",
                    "task1",
                    "task3"
                  ]
                }
              },
              "task3": {
                "service": "taskserver",
                "servicepath": "task3",
                "pipe": false,
                "method": "POST",
                "priority": 25,
                "switch": [
                  {
                    "field": "r",
                    "op": "==",
                    "value": "0",
                    "nextTasks": [
                      "task6"
                    ]
                  },
                  {
                    "default": true,
                    "nextTasks": [
                      "task7"
                    ]
                  }
                ],
                "synch": {
                  "op": "&",
                  "arr": [
                    "task0"
                  ]
                }
              },
              "task4": {
                "service": "taskserver",
                "servicepath": "task4",
                "pipe": false,
                "nextTasks": [
                  "task1",
                  "task5"
                ],
                "maxnuminvoke": 3,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task1"
                  ]
                }
              },
              "task5": {
                "service": "taskserver",
                "servicepath": "task5",
                "pipe": false,
                "maxnuminvoke": 1,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task4"
                  ]
                }
              },
              "task6": {
                "service": "taskserver",
                "servicepath": "task6",
                "pipe": false,
                "synch": {
                  "op": "&",
                  "arr": [
                    {
                      "task": "task3",
                      "condition": {
                        "field": "r",
                        "op": "==",
                        "value": "0"
                      }
                    }
                  ]
                }
              },
              "task7": {
                "service": "taskserver",
                "servicepath": "task6",
                "pipe": false,
                "maxnuminvoke": 1,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task1"
                  ]
                }
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "planname": "planurl",
            "start": "task0",
            "priority": 100,
            "interval": 0,
            "taskjson": {
              "task0": {
                "url": "https://localhost:9600/task0",
                "payload": {
                  "bar": "task0",
                  "f": 1
                },
                "pipe": true,
                "nextTasks": [
                  "task1",
                  "task2",
                  "task3"
                ]
              },
              "task1": {
                "url": "https://localhost:9600/task1",
                "pipe": false,
                "nextTasks": [
                  {
                    "task": "task2",
                    "pipe": true
                  },
                  "task4",
                  "task7"
                ],
                "wait1": 300,
                "priority": 20,
                "maxnuminvoke": 3,
                "retry": 5,
                "synch": {
                  "op": "|",
                  "arr": [
                    "task0",
                    "task4"
                  ]
                }
              },
              "task2": {
                "url": "https://localhost:9600/task2",
                "pipe": false,
                "wait1": 300,
                "maxnuminvoke": 2,
                "foo": "bar",
                "synch": {
                  "op": "|",
                  "arr": [
                    "task0",
                    "task1",
                    "task3"
                  ]
                }
              },
              "task3": {
                "url": "https://localhost:9600/task3",
                "pipe": false,
                "method": "POST",
                "priority": 25,
                "switch": [
                  {
                    "field": "r",
                    "op": "==",
                    "value": "0",
                    "nextTasks": [
                      "task6"
                    ]
                  },
                  {
                    "default": true,
                    "nextTasks": [
                      "task7"
                    ]
                  }
                ],
                "synch": {
                  "op": "&",
                  "arr": [
                    "task0"
                  ]
                }
              },
              "task4": {
                "url": "https://localhost:9600/task4",
                "pipe": false,
                "nextTasks": [
                  "task1",
                  "task5"
                ],
                "maxnuminvoke": 3,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task1"
                  ]
                }
              },
              "task5": {
                "url": "https://localhost:9600/task5",
                "pipe": false,
                "maxnuminvoke": 1,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task4"
                  ]
                }
              },
              "task6": {
                "url": "https://localhost:9600/task6",
                "pipe": false,
                "synch": {
                  "op": "&",
                  "arr": [
                    {
                      "task": "task3",
                      "condition": {
                        "field": "r",
                        "op": "==",
                        "value": "0"
                      }
                    }
                  ]
                }
              },
              "task7": {
                "url": "https://localhost:9600/task6",
                "pipe": false,
                "maxnuminvoke": 1,
                "synch": {
                  "op": "&",
                  "arr": [
                    "task1"
                  ]
                }
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "planname": "plan1",
            "start": "task0",
            "errortask": "notifyerror",
            "priority": 100,
            "interval": 0,
            "taskjson": {
              "task0": {
                "service": "taskserver",
                "servicepath": "task0",
                "payload": {
                  "bar": "task0",
                  "f": 1
                },
                "pipe": true,
                "vars": {
                  "def1": {
                    "var0": "value0",
                    "obj0": {
                      "objvar0": "value0",
                      "objobj0": {
                        "var0": "value02"
                      }
                    }
                  },
                  "sec1": {
                    "acckey": "c5009914c36000f2ea27dfd6000e076d",
                    "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                    "appkey": "faadae1e63233a9c51e5f99834670de5"
                  }
                },
                "switch": [
                  {
                    "field": "obj.value",
                    "op": "==",
                    "value": "objvalue1",
                    "nextTasks": [
                      "task00",
                      "task01",
                      "shelltask",
                      "securetask1",
                      "securetask2",
                      "securetask3"
                    ]
                  },
                  {
                    "default": true,
                    "nextTasks": [
                      "task1"
                    ]
                  }
                ]
              },
              "securetask1": {
                "service": "sampleservicebasic",
                "servicepath": "/sampleservice/something/foobasic/20",
                "method": "GET",
                "acckey": "$vars.sec.acckey",
                "secretna": "$vars.sec.secretkey",
                "pipe": false
              },
              "securetask2": {
                "service": "sampleserviceacckey",
                "servicepath": "/sampleservice/something/foohmac/40",
                "method": "GET",
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretna": "35a9ca16b3718568ea7d43172a0c29e9",
                "pipe": false
              },
              "securetask3": {
                "service": "sampleserviceappkey",
                "servicepath": "/sampleservice/something/fooapp/100",
                "method": "GET",
                "appkey": "$vars.sec.appkey",
                "pipe": false
              },
              "task00": {
                "service": "taskserver",
                "servicepath": "task00/$vars.init.value1",
                "method": "POST",
                "payload": {
                  "value": "$vars.init.obj.field1"
                },
                "vars": {
                  "abc": {
                    "var1": "value1",
                    "obj1": {
                      "objvar1": "value1",
                      "objobj1": {
                        "var1": "value2"
                      }
                    }
                  }
                },
                "pipe": false,
                "wait1": 300,
                "priority": 20
              },
              "task01": {
                "service": "taskserver",
                "servicepath": "task00/testingpayloads",
                "method": "POST",
                "payloads": [
                  {
                    "value": "$vars.init.obj.field1"
                  },
                  {
                    "value": "$vars.init.obj.field2"
                  },
                  {
                    "value": "$vars.init.obj.arr"
                  }
                ],
                "vars": {
                  "abc": {
                    "var1": "value1",
                    "obj1": {
                      "objvar1": "value1",
                      "objobj1": {
                        "var1": "value2"
                      }
                    }
                  }
                },
                "pipe": false,
                "wait1": 300,
                "priority": 2
              },
              "task1": {
                "service": "taskserver",
                "servicepath": "task1?$vars.init.obj.field2=foo",
                "method": "GET",
                "pipe": false,
                "wait1": 300,
                "priority": 20
              },
              "notifyerror": {
                "url": "https://hooks.slack.com/services/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",
                "payload": {
                  "text": "$vars.err.message",
                  "username": "phani"
                },
                "pipe": false,
                "priority": 20,
                "arrStatus": [
                  302
                ],
                "method": "POST"
              },
              "shelltask": {
                "shellcmd": "bash ~/test/test.sh",
                "payloads": [
                  {
                    "args": [
                      "helloworld1"
                    ]
                  },
                  {
                    "args": [
                      "helloworld2"
                    ]
                  },
                  {
                    "args": [
                      "helloworld3"
                    ]
                  }
                ],
                "priority": 20
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "file": "./plan1.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "file": "./synctest.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "file": "./synctestcond.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "file": "../demo/workflowdemo/synchtest.json"
          }
        }
      ]
    },
    {
      "route": "/plans/:planname",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetPlan",
      "description": "Get json description of named plan",
      "paramschema": {
        "type": "object",
        "required": [
          "planname"
        ],
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/plans/plan1"
        },
        {
          "param": "/plans/synctest"
        },
        {
          "param": "/plans/synctestcond"
        },
        {
          "param": "/plans/planurl"
        },
        {
          "param": "/plans/planservice"
        }
      ]
    },
    {
      "route": "/plans/:planname",
      "configured": true,
      "type": "delete",
      "routeclass": "./workflow.js",
      "routefunction": "RouteDeletePlan",
      "description": "Delete named plan",
      "paramschema": {
        "required": [
          "planname"
        ],
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        }
      },
      "examples": [
        {
          "param": "/plans/plan1"
        },
        {
          "param": "/plans/synctest"
        },
        {
          "param": "/plans/synctestcond"
        },
        {
          "param": "/plans/planurl"
        },
        {
          "param": "/plans/planservice"
        }
      ]
    },
    {
      "route": "/plans/:planname/status",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RoutePlanGetStatus",
      "description": "Get the status of the plan. Running or Stopped",
      "examples": [
        {
          "param": "/plans/plan1/status"
        },
        {
          "param": "/plans/synctest/status"
        },
        {
          "param": "/plans/synctestcond/status"
        },
        {
          "param": "/plans/planurl/status"
        },
        {
          "param": "/plans/planservice/status"
        }
      ]
    },
    {
      "route": "/plans/:planname/status",
      "configured": true,
      "type": "put",
      "routeclass": "./workflow.js",
      "routefunction": "RoutePlanPutStatus",
      "description": "Set the status of the plan to start or stop. Stop may not be immediate but requests stop at the next opportunity.",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        }
      },
      "bodyschema": {
        "required": [
          "status"
        ],
        "type": "object",
        "properties": {
          "status": {
            "description": "set status",
            "type": {
              "enum": [
                "start",
                "stop",
                "nudge"
              ]
            }
          },
          "name": {
            "description": "task name (applies only for nudge)",
            "type": "string"
          },
          "force": {
            "description": "sets the plan to stop state and another workflow can pick uup the plan. This needs to be carefully used and only in case the plan is stuck for some unknown reason and it's not really in running state",
            "type": "boolean"
          },
          "payload": {
            "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init",
            "type": "object"
          },
          "vars": {
            "description": "named variables with full json representation for values is supported. Access these variables just as you would access outputvar. Note these are global to the plan and need to be unique",
            "type": "object"
          }
        }
      },
      "examples": [
        {
          "param": "/plans/plan1/status",
          "payload": {
            "status": "start",
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            }
          }
        },
        {
          "param": "/plans/synctest/status",
          "payload": {
            "status": "start"
          }
        },
        {
          "param": "/plans/synctestcond/status",
          "payload": {
            "status": "start"
          }
        },
        {
          "param": "/plans/planurl/status",
          "payload": {
            "status": "start"
          }
        },
        {
          "param": "/plans/planurl/status",
          "payload": {
            "status": "stop"
          }
        },
        {
          "param": "/plans/planurl/status",
          "payload": {
            "status": "nudge",
            "name": "task4"
          }
        },
        {
          "param": "/plans/planservice/status",
          "payload": {
            "status": "start"
          }
        },
        {
          "param": "/plans/planservice/status",
          "payload": {
            "status": "stop",
            "force": true
          }
        },
        {
          "param": "/plans/planservice/status",
          "payload": {
            "status": "nudge"
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/interval",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetInterval",
      "description": "Get Periodicity of the jobs. non-zero value means it's a job that executes every so many milliseconds",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/plan1/interval"
        },
        {
          "param": "/plans/planurl/interval"
        },
        {
          "param": "/plans/planservice/interval"
        }
      ]
    },
    {
      "route": "/plans/:planname/interval",
      "configured": true,
      "type": "put",
      "routeclass": "./workflow.js",
      "routefunction": "RouteSetInterval",
      "description": "Make the plan periodic by setting how often to execute. Periodic jobs will execute to completion before it can restart. If the interval is less than the execution time, the job will execute at the next interval after the job is competed",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "required": [
          "interval"
        ],
        "properties": {
          "interval": {
            "description": "periodic interval to execute the plan specified in milliseconds",
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "examples": [
        {
          "param": "/plans/plan1/interval",
          "payload": {
            "interval": 100
          }
        },
        {
          "param": "/plans/planurl/interval",
          "payload": {
            "interval": 100
          }
        },
        {
          "param": "/plans/planservice/interval",
          "payload": {
            "interval": 100
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/interval",
      "configured": true,
      "type": "delete",
      "routeclass": "./workflow.js",
      "routefunction": "RouteDeleteInterval",
      "description": "Delete interval. This makes the job non-periodic.",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/plan1/interval"
        },
        {
          "param": "/plans/planurl/interval"
        },
        {
          "param": "/plans/planservice/interval"
        }
      ]
    },
    {
      "route": "/plans/:planname/cron",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetCron",
      "description": "Get the cron job settings for this plan",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/plan1/cron"
        },
        {
          "param": "/plans/planurl/cron"
        },
        {
          "param": "/plans/planservice/cron"
        }
      ]
    },
    {
      "route": "/plans/:planname/cron",
      "configured": true,
      "type": "put",
      "routeclass": "./workflow.js",
      "routefunction": "RouteSetCron",
      "description": "Set cron like settings for the plan to execute on periodic basis. Periodic jobs will execute to completion before it can restart. If the interval is less than the execution time, the job will execute at the next interval after the job is competed",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "required": [
          "cron"
        ],
        "properties": {
          "cron": {
            "description": "cron like syntax",
            "type": "string",
            "pattern": "^(((\\d+,)+\\d+|(\\d+(\\/|-)\\d+)|\\d+|\\*|(\\*(\\/|-)\\d+)) ?){5,7}$"
          }
        }
      },
      "examples": [
        {
          "param": "/plans/plan1/cron",
          "payload": {
            "cron": "2 * * * * *"
          }
        },
        {
          "param": "/plans/planservice/cron",
          "payload": {
            "cron": "2,32 * * * * *"
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/cron",
      "configured": true,
      "type": "delete",
      "routeclass": "./workflow.js",
      "routefunction": "RouteDeleteCron",
      "description": "Delete the cron job settings for this plan",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/plan1/cron"
        },
        {
          "param": "/plans/planurl/cron"
        },
        {
          "param": "/plans/planservice/cron"
        }
      ]
    },
    {
      "route": "/plans/:planname/loglevel",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetLogLevel",
      "description": "Get the current loglevel for tracking issues",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/loglevel"
        },
        {
          "param": "/plans/planservice/loglevel"
        }
      ]
    },
    {
      "route": "/plans/:planname/loglevel",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteSetLogLevel",
      "description": "Set the level from 0 to 3 purely for tracking issues. Default is 0",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "required": [
          "loglevel"
        ],
        "properties": {
          "loglevel": {
            "description": "log level for tracing value 0 is minimal logging and 3 is verbose",
            "type": {
              "enum": [
                0,
                1,
                2,
                3
              ]
            }
          }
        }
      },
      "examples": [
        {
          "param": "/plans/planurl/loglevel",
          "payload": {
            "loglevel": 2
          }
        },
        {
          "param": "/plans/planservice/loglevel",
          "payload": {
            "loglevel": 0
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetTasks",
      "description": "Add a task with given name to the plan. The task can be either a url or a cirrus service",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks"
        },
        {
          "param": "/plans/planservice/tasks"
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteAddTask",
      "description": "Add a task with given name to the plan. The task can be either a url or a cirrus service",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "properties": {
          "name": {
            "description": "name for the task",
            "type": "string"
          },
          "noop": {
            "type": "boolean",
            "description": "true for empty task that simply is used to launch next tasks or used as synch point for other tasks"
          },
          "shellcmd": {
            "description": "Shell command. payload has special parameter called args which defines the arg stucture",
            "type": "string"
          },
          "url": {
            "description": "fully qualified url",
            "type": "string"
          },
          "service": {
            "description": "cirrus installed service name",
            "type": "string"
          },
          "servicepath": {
            "description": "In the cirrus service, url of the specific route e.g. plan/task/add is this route path in workflow service",
            "type": "string"
          },
          "sysservice": {
            "description": "Indicates to the workflow that the service is to be located only in the system services. If false or not present, it will look in appservices first and then system services",
            "type": "boolean"
          },
          "start": {
            "description": "Set this to be start task if set to true",
            "type": "boolean"
          },
          "wait": {
            "description": "How long to wait before the task is executied",
            "type": "number"
          },
          "maxnuminvok": {
            "description": "maximum number of times this task is allowed to be invoked in one execution session",
            "type": "number"
          },
          "retry": {
            "description": "maximum number of the service will be retried in case of error",
            "type": "number"
          },
          "pipe": {
            "description": "if true the response from parent task will be added to the payload. Note if the same named field exists in the response of parent as payload, the response field will replace it",
            "type": "boolean"
          },
          "security": {
            "description": "Applicable only in case of url based task. It can be accesskey which use hmac encryption or basic which is simply base64 encoding of the keys. If the url is secured by accesskey and secretkey, the type of security also needs to be specified",
            "type": {
              "enum": [
                "appkey",
                "accesskey",
                "basic",
                "jwt"
              ]
            }
          },
          "headers": {
            "description": "array of optional http header values that can be passed at the time of invoking the task",
            "type": "object",
            "patternProperties": {
              "^[A-Za-z][A-Za-z0-9-_]*$": {
                "type": "string"
              }
            }
          },
          "appkey": {
            "description": "appkey needed to access the service if security is set to appkey",
            "type": "string"
          },
          "acckey": {
            "description": "access key portion of security credentials",
            "type": "string"
          },
          "secretna": {
            "description": "secret key portion of security credentials",
            "type": "string"
          },
          "jwttoken": {
            "description": "the jwt token value",
            "type": "string"
          },
          "outputvar": {
            "description": "output of this task will be available for subsequent tasks under this name in the payload json. Also if you put $vars (separated by space) in any string in payload it will substitute it with the stringified version of all the output vars thus far.",
            "type": "string"
          },
          "payload": {
            "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init",
            "type": "object"
          },
          "payloads": {
            "oneOf": [
              {
                "type": "array",
                "description": "Array of payload objects.",
                "items": {
                  "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init. It can also be a string in non-REST scenario e.g. urlencoded form data",
                  "oneOf": [
                    {
                      "type": "object"
                    },
                    {
                      "type": "string"
                    }
                  ]
                }
              },
              {
                "type": "string",
                "description": "should only be used as $vars string so that it can be replaced by an array at runtime."
              }
            ]
          },
          "vars": {
            "description": "named variables with full json representation for values is supported. Access these variables just as you would access outputvar. Note these are global to the plan and need to be unique",
            "type": "object"
          },
          "clearvars": {
            "description": "empties outputvar cache. All previous outputvar data will not be available in payload.",
            "type": "boolean"
          },
          "allowerrors": {
            "description": "Allow errors in case of payloads only.",
            "type": "boolean"
          }
        },
        "oneOf": [
          {
            "required": [
              "url",
              "name"
            ]
          },
          {
            "required": [
              "noop"
            ]
          },
          {
            "required": [
              "shellcmd"
            ]
          },
          {
            "required": [
              "name",
              "service",
              "path"
            ]
          }
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks",
          "payload": {
            "name": "task0",
            "url": "https://localhost:9600/task0",
            "method": "GET",
            "pipe": true,
            "payload": {
              "bar": "task0",
              "f": 1
            },
            "cvisit": 1,
            "cRetried": 0,
            "sysservice": false
          }
        },
        {
          "param": "/plans/planservice/tasks",
          "payload": {
            "name": "task0",
            "service": "taskserver",
            "servicepath": "task0",
            "method": "GET",
            "pipe": true,
            "payload": {
              "bar": "task0",
              "f": 1
            },
            "cvisit": 1,
            "cRetried": 0,
            "sysservice": false
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:taskname",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetTask",
      "description": "get information about a task",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "taskname": {
            "description": "name for the task",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "taskname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0"
        },
        {
          "param": "/plans/planservice/tasks/task0"
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:taskname",
      "configured": true,
      "type": "put",
      "routeclass": "./workflow.js",
      "routefunction": "RouteUpdateTask",
      "description": "Update a task in plan. The task can be either a url or a cirrus service",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "taskname": {
            "description": "name for the task",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "taskname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "properties": {
          "noop": {
            "type": "boolean",
            "description": "true for empty task that simply is used to launch next tasks or used as synch point for other tasks"
          },
          "shellcmd": {
            "description": "Shell command. payload has special parameter called args which defines the arg stucture",
            "type": "string"
          },
          "url": {
            "description": "fully qualified url",
            "type": "string"
          },
          "service": {
            "description": "cirrus installed service name",
            "type": "string"
          },
          "servicepath": {
            "description": "In the cirrus service, url of the specific route e.g. plan/task/add is this route path in workflow service",
            "type": "string"
          },
          "sysservice": {
            "description": "Indicates to the workflow that the service is to be located only in the system services. If false or not present, it will look in appservices first and then system services",
            "type": "boolean"
          },
          "start": {
            "description": "Set this to be start task if set to true",
            "type": "boolean"
          },
          "wait": {
            "description": "How long to wait before the task is executied",
            "type": "number"
          },
          "maxnuminvoke": {
            "description": "maximum number of times this task is allowed to be invoked in one execution session",
            "type": "number"
          },
          "retry": {
            "description": "maximum number of the service will be retried in case of error",
            "type": "number"
          },
          "pipe": {
            "description": "if true the response from parent task will be added to the payload. Note if the same named field exists in the response of parent as payload, the response field will replace it",
            "type": "boolean"
          },
          "security": {
            "description": "Applicable only in case of url based task. It can be accesskey which use hmac encryption or basic which is simply base64 encoding of the keys. If the url is secured by accesskey and secretkey, the type of security also needs to be specified",
            "type": {
              "enum": [
                "appkey",
                "accesskey",
                "basic",
                "jwt"
              ]
            }
          },
          "headers": {
            "description": "array of optional http header values that can be passed at the time of invoking the task",
            "type": "object",
            "patternProperties": {
              "^[A-Za-z][A-Za-z0-9-_]*$": {
                "type": "string"
              }
            }
          },
          "appkey": {
            "description": "appkey needed to access the service if security is set to appkey",
            "type": "string"
          },
          "acckey": {
            "description": "access key portion of security credentials",
            "type": "string"
          },
          "secretna": {
            "description": "secret key portion of security credentials",
            "type": "string"
          },
          "jwttoken": {
            "description": "the jwt token value",
            "type": "string"
          },
        "payload": {
            "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init",
            "type": "object"
          },
          "payloads": {
            "oneOf": [
              {
                "type": "array",
                "description": "Array of payload objects.",
                "items": {
                  "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init. It can also be a string in non-REST scenario e.g. urlencoded form data",
                  "oneOf": [
                    {
                      "type": "object"
                    },
                    {
                      "type": "string"
                    }
                  ]
                }
              },
              {
                "type": "string",
                "description": "should only be used as $vars string so that it can be replaced by an array at runtime."
              }
            ]
          },
          "outputvar": {
            "description": "output of this task will be available for subsequent tasks under this name in the payload json. Also if you put $vars (separated by space) in any string in payload it will substitute it with the stringified version of all the output vars thus far.",
            "type": "string"
          },
          "vars": {
            "description": "named variables with full json representation for values is supported. Access these variables just as you would access outputvar. Note these are global to teh plan and need to be unique",
            "type": "object"
          },
          "clearvars": {
            "description": "empties outputvar cache. All previous outputvar data will not be available in payload.",
            "type": "boolean"
          },
          "allowerrors": {
            "description": "Allow errors in case of payloads only.",
            "type": "boolean"
          }
        },
        "oneOf": [
          {
            "required": [
              "url"
            ]
          },
          {
            "required": [
              "noop"
            ]
          },
          {
            "required": [
              "shellcmd"
            ]
          },
          {
            "required": [
              "service",
              "path"
            ]
          }
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0",
          "payload": {
            "url": "https://localhost:9600/task0",
            "method": "GET",
            "pipe": true,
            "payload": {
              "bar": "task0",
              "f": 1
            },
            "cvisit": 1,
            "cRetried": 0,
            "sysservice": false
          }
        },
        {
          "param": "/plans/planservice/tasks/task0",
          "payload": {
            "service": "taskserver",
            "servicepath": "task0",
            "method": "GET",
            "pipe": true,
            "payload": {
              "bar": "task0",
              "f": 1
            },
            "cvisit": 1,
            "cRetried": 0,
            "sysservice": false
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:pname/nexttasks",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetNextTasks",
      "description": "Get the nextTasks for the parent task.",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "pname": {
            "description": "parent task name to insert into",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "pname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0/nexttasks"
        },
        {
          "param": "/plans/planservice/tasks/task0/nexttasks"
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:pname/nexttasks",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteInsertTask",
      "description": "Insert a task in the nextTasks for the parent task. This is one way to create the workflow",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "pname": {
            "description": "parent task name to insert into",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "pname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "properties": {
          "name": {
            "description": "name of the task to insert",
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0/nexttasks",
          "payload": {
            "name": "task1"
          }
        },
        {
          "param": "/plans/planservice/tasks/task0/nexttasks",
          "payload": {
            "name": "task1"
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:sname/synch",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetSynch",
      "description": "Get the nextTasks for the parent task.",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "pname": {
            "description": "parent task name to insert into",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "sname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task4/synch"
        },
        {
          "param": "/plans/planservice/tasks/task4/synch"
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:sname/synch",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteInsertSynchNew",
      "description": "Insert a task in synch mode. Execution of a task depends on the completion of tasks in the synch. This produces inverse relationship of what plan/add/insert would create between task and parent task",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "sname": {
            "description": "task that's synchronizing",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "sname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "properties": {
          "op": {
            "description": "synch operation it can be '&' for AND and '|' for OR",
            "type": "string"
          },
          "pname": {
            "description": "parent task to synch with. When parent task fires, the synch expression will determine if the sname task needs to fire",
            "type": "string"
          }
        },
        "required": [
          "op",
          "pname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task4/synch",
          "payload": {
            "op": "&",
            "pname": "task0"
          }
        },
        {
          "param": "/plans/planservice/tasks/task4/synch",
          "payload": {
            "op": "&",
            "pname": "task0"
          }
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:taskname/payload",
      "configured": true,
      "type": "get",
      "routeclass": "./workflow.js",
      "routefunction": "RouteGetPayload",
      "description": "Get payload for a task",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "taskname": {
            "description": "task that they payload belongs to",
            "type": "string"
          }
        },
        "required": [
          "planname",
          "taskname"
        ]
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0/payload"
        },
        {
          "param": "/plans/planservice/tasks/task0/payload"
        }
      ]
    },
    {
      "route": "/plans/:planname/tasks/:taskname/payload",
      "configured": true,
      "type": "post",
      "routeclass": "./workflow.js",
      "routefunction": "RouteSetPayload",
      "description": "Set payload for a task",
      "paramschema": {
        "type": "object",
        "properties": {
          "planname": {
            "description": "name of the plan",
            "type": "string"
          },
          "taskname": {
            "description": "task that they payload belongs to",
            "type": "string"
          }
        },
        "required": [
          "planname"
        ]
      },
      "bodyschema": {
        "type": "object",
        "properties": {}
      },
      "examples": [
        {
          "param": "/plans/planurl/tasks/task0/payload",
          "payload": {
            "payload": {
              "field": "foo"
            }
          }
        },
        {
          "param": "/plans/planservice/tasks/task0/payload",
          "payload": {
            "payload": {
              "field": "foo"
            }
          }
        }
      ]
    },
    {
      "route": "/plans/status",
      "configured": true,
      "type": "put",
      "routeclass": "./workflow.js",
      "routefunction": "RouteExecutePlan",
      "description": "create a new plan and execute without storing. Note this plan is not stored anywhere. It will be created, executed and deleted after it runs.",
      "bodyschema": {
        "type": "object",
        "oneOf": [
          {
            "required": [
              "plan"
            ]
          },
          {
            "required": [
              "file"
            ]
          }
        ],
        "properties": {
          "plan": {
            "type": "object",
            "anyOf": [
              {
                "required": [
                  "planname",
                  "priority",
                  "start",
                  "taskjson"
                ]
              },
              {
                "required": [
                  "file"
                ]
              }
            ],
            "properties": {
              "priority": {
                "description": "priority of the plan a number between 0 and 1000. Lower the number higher the priority ",
                "type": "number",
                "minimum": 0,
                "maximum": 1000
              },
              "file": {
                "description": "file with json description of the plan",
                "type": "string"
              },
              "start": {
                "description": "Task to start the execution from",
                "type": "string"
              },
              "errortask": {
                "description": "Task to catch errors. Can be used to notify the errors. Error is in $vars.err as $vars.err.message and $vars.err.status",
                "type": "string"
              },
              "taskjson": {
                "$ref": "#/definitions/deftaskjson"
              },
              "responsevar": {
                "description": "Responsne will be returned in this. This can contain $var convention for dynamic reponses.",
                "oneOf": [
                  {
                    "type": "object"
                  },
                  {
                    "type": "string"
                  }
                ]
              }
            }
          },
          "file": {
            "description": "file with json description of the plan",
            "type": "string"
          },
          "payload": {
            "description": "json that the task will receive as body in the request. Also this will be avilable as outputvar named init. Can be accessed as $vars.init",
            "type": "object"
          },
          "vars": {
            "description": "named variables with full json representation for values is supported. Access these variables just as you would access outputvar. Note these are global to the plan and need to be unique",
            "type": "object"
          }
        }
      },
      "examples": [
        {
          "param": "/plans/status",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "plan": {
              "planname": "",
              "start": "task0",
              "priority": 100,
              "taskjson": {
                "task0": {
                  "service": "taskserver",
                  "servicepath": "task0",
                  "payload": {
                    "bar": "task0",
                    "f": 1
                  },
                  "pipe": true,
                  "nextTasks": [
                    "task1",
                    "task2",
                    "task3"
                  ]
                },
                "task1": {
                  "service": "taskserver",
                  "servicepath": "task1",
                  "pipe": false,
                  "nextTasks": [
                    {
                      "task": "task2",
                      "pipe": true
                    },
                    "task4",
                    "task7"
                  ],
                  "wait1": 300,
                  "priority": 20,
                  "maxnuminvoke": 3,
                  "retry": 5,
                  "synch": {
                    "op": "|",
                    "arr": [
                      "task0",
                      "task4"
                    ]
                  }
                },
                "task2": {
                  "service": "taskserver",
                  "servicepath": "task2",
                  "pipe": false,
                  "wait1": 300,
                  "maxnuminvoke": 2,
                  "foo": "bar",
                  "synch": {
                    "op": "|",
                    "arr": [
                      "task0",
                      "task1",
                      "task3"
                    ]
                  }
                },
                "task3": {
                  "service": "taskserver",
                  "servicepath": "task3",
                  "pipe": false,
                  "method": "POST",
                  "priority": 25,
                  "switch": [
                    {
                      "field": "r",
                      "op": "==",
                      "value": "0",
                      "nextTasks": [
                        "task6"
                      ]
                    },
                    {
                      "default": true,
                      "nextTasks": [
                        "task7"
                      ]
                    }
                  ],
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task0"
                    ]
                  }
                },
                "task4": {
                  "service": "taskserver",
                  "servicepath": "task4",
                  "pipe": false,
                  "nextTasks": [
                    "task1",
                    "task5"
                  ],
                  "maxnuminvoke": 3,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task1"
                    ]
                  }
                },
                "task5": {
                  "service": "taskserver",
                  "servicepath": "task5",
                  "pipe": false,
                  "maxnuminvoke": 1,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task4"
                    ]
                  }
                },
                "task6": {
                  "service": "taskserver",
                  "servicepath": "task6",
                  "pipe": false,
                  "synch": {
                    "op": "&",
                    "arr": [
                      {
                        "task": "task3",
                        "condition": {
                          "field": "r",
                          "op": "==",
                          "value": "0"
                        }
                      }
                    ]
                  }
                },
                "task7": {
                  "service": "taskserver",
                  "servicepath": "task6",
                  "pipe": false,
                  "maxnuminvoke": 1,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task1"
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "param": "/plans/status",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "plan": {
              "planname": "",
              "start": "task0",
              "priority": 100,
              "interval": 0,
              "taskjson": {
                "task0": {
                  "url": "https://localhost:9600/task0",
                  "payload": {
                    "bar": "task0",
                    "f": 1
                  },
                  "pipe": true,
                  "nextTasks": [
                    "task1",
                    "task2",
                    "task3"
                  ]
                },
                "task1": {
                  "url": "https://localhost:9600/task1",
                  "pipe": false,
                  "nextTasks": [
                    {
                      "task": "task2",
                      "pipe": true
                    },
                    "task4",
                    "task7"
                  ],
                  "wait1": 300,
                  "priority": 20,
                  "maxnuminvoke": 3,
                  "retry": 5,
                  "synch": {
                    "op": "|",
                    "arr": [
                      "task0",
                      "task4"
                    ]
                  }
                },
                "task2": {
                  "url": "https://localhost:9600/task2",
                  "pipe": false,
                  "wait1": 300,
                  "maxnuminvoke": 2,
                  "foo": "bar",
                  "synch": {
                    "op": "|",
                    "arr": [
                      "task0",
                      "task1",
                      "task3"
                    ]
                  }
                },
                "task3": {
                  "url": "https://localhost:9600/task3",
                  "pipe": false,
                  "method": "POST",
                  "priority": 25,
                  "switch": [
                    {
                      "field": "r",
                      "op": "==",
                      "value": "0",
                      "nextTasks": [
                        "task6"
                      ]
                    },
                    {
                      "default": true,
                      "nextTasks": [
                        "task7"
                      ]
                    }
                  ],
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task0"
                    ]
                  }
                },
                "task4": {
                  "url": "https://localhost:9600/task4",
                  "pipe": false,
                  "nextTasks": [
                    "task1",
                    "task5"
                  ],
                  "maxnuminvoke": 3,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task1"
                    ]
                  }
                },
                "task5": {
                  "url": "https://localhost:9600/task5",
                  "pipe": false,
                  "maxnuminvoke": 1,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task4"
                    ]
                  }
                },
                "task6": {
                  "url": "https://localhost:9600/task6",
                  "pipe": false,
                  "synch": {
                    "op": "&",
                    "arr": [
                      {
                        "task": "task3",
                        "condition": {
                          "field": "r",
                          "op": "==",
                          "value": "0"
                        }
                      }
                    ]
                  }
                },
                "task7": {
                  "url": "https://localhost:9600/task6",
                  "pipe": false,
                  "maxnuminvoke": 1,
                  "synch": {
                    "op": "&",
                    "arr": [
                      "task1"
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "plan": {
              "planname": "",
              "responsevar": {
                "value": "$vars.init.value1",
                "str": "$vars.init.str"
              },
              "start": "task0",
              "errortask": "notifyerror",
              "priority": 100,
              "interval": 0,
              "taskjson": {
                "task0": {
                  "service": "taskserver",
                  "servicepath": "task0",
                  "payload": {
                    "bar": "task0",
                    "f": 1
                  },
                  "pipe": true,
                  "vars": {
                    "def1": {
                      "var0": "value0",
                      "obj0": {
                        "objvar0": "value0",
                        "objobj0": {
                          "var0": "value02"
                        }
                      }
                    },
                    "sec1": {
                      "acckey": "c5009914c36000f2ea27dfd6000e076d",
                      "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                      "appkey": "faadae1e63233a9c51e5f99834670de5"
                    }
                  },
                  "switch": [
                    {
                      "field": "obj.value",
                      "op": "==",
                      "value": "objvalue1",
                      "nextTasks": [
                        "task00",
                        "task01",
                        "shelltask",
                        "securetask1",
                        "securetask2",
                        "securetask3"
                      ]
                    },
                    {
                      "default": true,
                      "nextTasks": [
                        "task1"
                      ]
                    }
                  ]
                },
                "securetask1": {
                  "service": "sampleservicebasic",
                  "servicepath": "/sampleservice/something/foobasic/20",
                  "method": "GET",
                  "acckey": "$vars.sec.acckey",
                  "secretna": "$vars.sec.secretkey",
                  "pipe": false
                },
                "securetask2": {
                  "service": "sampleserviceacckey",
                  "servicepath": "/sampleservice/something/foohmac/40",
                  "method": "GET",
                  "acckey": "c5009914c36000f2ea27dfd6000e076d",
                  "secretna": "35a9ca16b3718568ea7d43172a0c29e9",
                  "pipe": false
                },
                "securetask3": {
                  "service": "sampleserviceappkey",
                  "servicepath": "/sampleservice/something/fooapp/100",
                  "method": "GET",
                  "appkey": "$vars.sec.appkey",
                  "pipe": false
                },
                "task00": {
                  "service": "taskserver",
                  "servicepath": "task00/$vars.init.value1",
                  "method": "POST",
                  "payload": {
                    "value": "$vars.init.obj.field1"
                  },
                  "vars": {
                    "abc": {
                      "var1": "value1",
                      "obj1": {
                        "objvar1": "value1",
                        "objobj1": {
                          "var1": "value2"
                        }
                      }
                    }
                  },
                  "pipe": false,
                  "wait1": 300,
                  "priority": 20
                },
                "task01": {
                  "service": "taskserver",
                  "servicepath": "task00/testingpayloads",
                  "method": "POST",
                  "payloads": [
                    {
                      "value": "$vars.init.obj.field1"
                    },
                    {
                      "value": "$vars.init.obj.field2"
                    },
                    {
                      "value": "$vars.init.obj.arr"
                    }
                  ],
                  "vars": {
                    "abc": {
                      "var1": "value1",
                      "obj1": {
                        "objvar1": "value1",
                        "objobj1": {
                          "var1": "value2"
                        }
                      }
                    }
                  },
                  "pipe": false,
                  "wait1": 300,
                  "priority": 2
                },
                "task1": {
                  "service": "taskserver",
                  "servicepath": "task1?$vars.init.obj.field2=foo",
                  "method": "GET",
                  "pipe": false,
                  "wait1": 300,
                  "priority": 20
                },
                "notifyerror": {
                  "url": "https://hooks.slack.com/services/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",
                  "payload": {
                    "text": "$vars.err.message",
                    "username": "phani"
                  },
                  "pipe": false,
                  "priority": 20,
                  "arrStatus": [
                    302
                  ],
                  "method": "POST"
                },
                "shelltask": {
                  "shellcmd": "bash ~/test/test.sh",
                  "payloads": [
                    {
                      "args": [
                        "helloworld1"
                      ]
                    },
                    {
                      "args": [
                        "helloworld2"
                      ]
                    },
                    {
                      "args": [
                        "helloworld3"
                      ]
                    }
                  ],
                  "priority": 20
                }
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "plan": {
              "planname": "",
              "responsevar": "$vars.init",
              "start": "task0",
              "errortask": "notifyerror",
              "priority": 100,
              "interval": 0,
              "taskjson": {
                "task0": {
                  "service": "taskserver",
                  "servicepath": "task0",
                  "payload": {
                    "bar": "task0",
                    "f": 1
                  },
                  "pipe": true,
                  "nextTasks": [
                    "securetask1"
                  ]
                },
                "securetask1": {
                  "service": "sampleservicebasic",
                  "servicepath": "/sampleservice/something/foobasic/20",
                  "method": "GET",
                  "acckey": "$vars.sec.acckey",
                  "secretna": "$vars.sec.secretkey",
                  "pipe": false
                }
              }
            }
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "file": "./plan1.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "file": "./synctest.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "file": "./synctestcond.json"
          }
        },
        {
          "param": "/plans",
          "payload": {
            "payload": {
              "value1": "value2",
              "str": "This is a string",
              "obj": {
                "field1": {
                  "f1": "value1",
                  "f2": "value2",
                  "f3": {
                    "f4": "value4"
                  }
                },
                "field2": "value2",
                "arr": [
                  "item1",
                  "item2",
                  "item3"
                ]
              }
            },
            "vars": {
              "def": {
                "var0": "value0",
                "obj0": {
                  "objvar0": "value0",
                  "objobj0": {
                    "var0": "value02"
                  }
                }
              },
              "sec": {
                "acckey": "c5009914c36000f2ea27dfd6000e076d",
                "secretkey": "35a9ca16b3718568ea7d43172a0c29e9",
                "appkey": "faadae1e63233a9c51e5f99834670de5"
              }
            },
            "file": "../demo/workflowdemo/synchtest.json"
          }
        }
      ]
    }
  ],
  "loglevel": "trace"
}