{
  "$id": "https://json.schemastore.org/workflows.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "subworkflow": {
      "type": "object",
      "description": "A subworkflow.",
      "additionalProperties": false,
      "properties": {
        "params": {
          "description": "The name of the parameter variable.",
          "type": "array",
          "minItems": 0,
          "maxItems": 10,
          "uniqueItems": true
        },
        "steps": {
          "description": "An array of objects with a single step.",
          "$ref": "#/definitions/stepArray"
        }
      }
    },
    "stepArray": {
      "type": "array",
      "description": "An array of objects with a single step.",
      "minItems": 1,
      "maxItems": 100000,
      "items": {
        "type": "object",
        "description": "An object with a single step.",
        "minProperties": 1,
        "maxProperties": 1,
        "additionalProperties": false,
        "patternProperties": {
          "^.*$": {
            "description": "A single workflow step.",
            "$ref": "#/definitions/step"
          }
        }
      }
    },
    "step": {
      "type": "object",
      "description": "A single workflow step.",
      "additionalProperties": false,
      "dependencies": {
        "args": ["call"],
        "result": ["call"],
        "except": ["try"],
        "retry": ["try"]
      },
      "properties": {
        "assign": {
          "$ref": "#/definitions/assign"
        },
        "call": {
          "$ref": "#/definitions/call"
        },
        "args": {
          "$ref": "#/definitions/args"
        },
        "result": {
          "$ref": "#/definitions/result"
        },
        "next": {
          "$ref": "#/definitions/next"
        },
        "switch": {
          "$ref": "#/definitions/switch"
        },
        "for": {
          "$ref": "#/definitions/for"
        },
        "parallel": {
          "$ref": "#/definitions/parallel"
        },
        "raise": {
          "$ref": "#/definitions/raise"
        },
        "try": {
          "$ref": "#/definitions/try"
        },
        "retry": {
          "$ref": "#/definitions/retry"
        },
        "except": {
          "$ref": "#/definitions/except"
        },
        "return": {
          "$ref": "#/definitions/return"
        },
        "steps": {
          "$ref": "#/definitions/stepArray"
        }
      }
    },
    "assign": {
      "description": "A list of variable assignment maps.",
      "type": "array",
      "items": {
        "type": "object",
        "description": "A single variable assignment.",
        "minProperties": 1,
        "maxProperties": 1
      },
      "minItems": 1,
      "maxItems": 50
    },
    "call": {
      "description": "Run a function and return a result.",
      "anyOf": [
        {
          "description": "Standard library module for HTTP/S request support.",
          "type": "string",
          "enum": [
            "http.get",
            "http.post",
            "http.put",
            "http.patch",
            "http.delete",
            "http.request"
          ]
        },
        {
          "description": "Standard library module for common system interface.",
          "type": "string",
          "enum": ["sys.sleep", "sys.sleep_until", "sys.log"]
        },
        {
          "description": "Standard library module for event support.",
          "type": "string",
          "enum": ["events.await_callback", "events.create_callback_endpoint"]
        },
        {
          "description": "A subworkflow.",
          "type": "string"
        },
        {
          "description": "A Google Cloud API connector.",
          "type": "string",
          "pattern": "^googleapis(\\.[a-zA-Z1-9]+)+"
        }
      ]
    },
    "args": {
      "type": "object",
      "description": "Pass arguments and their values when calling a function that accepts parameters.",
      "additionalProperties": true,
      "properties": {
        "url": {
          "anyOf": [
            {
              "description": "URL where the request is sent. Required if using call type http.request.",
              "type": "string",
              "format": "uri"
            },
            {
              "description": "An expression that results to a URL where the request is sent. Required if using call type http.request.",
              "type": "string",
              "pattern": "^\\$\\{.+\\}$"
            }
          ]
        },
        "method": {
          "description": "The type of HTTP request method to use. Required if using call type http.request.",
          "type": "string",
          "enum": [
            "GET",
            "HEAD",
            "POST",
            "PUT",
            "DELETE",
            "CONNECT",
            "OPTIONS",
            "TRACE",
            "PATCH"
          ]
        },
        "headers": {
          "description": "Header fields to supply input to the API.",
          "type": "object",
          "minProperties": 1
        },
        "body": {
          "description": "Body fields to supply input to the API.",
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            },
            {
              "type": "string"
            },
            {
              "type": "string",
              "pattern": "^\\$\\{.+\\}$"
            }
          ]
        },
        "query": {
          "description": "Query fields to supply input to the API.",
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "string",
              "pattern": "^\\$\\{.+\\}$"
            }
          ]
        },
        "auth": {
          "description": "Required if the API being called requires authentication.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "description": "The type of authentication.",
              "enum": ["OIDC", "OAuth2"]
            },
            "scope": {
              "description": "Specify token scope to limit an application's access to a user's account.",
              "anyOf": [
                {
                  "description": "List of scope strings.",
                  "type": "array",
                  "contains": {
                    "type": "string"
                  }
                },
                {
                  "description": "Scope string.",
                  "type": "string"
                }
              ]
            },
            "scopes": {
              "description": "Specify token scope to limit an application's access to a user's account.",
              "$ref": "#/definitions/scopes"
            },
            "audience": {
              "description": "Specifies the audience for the OIDC token. By default, it's set to the same value as url; however, it should be set to your service's root URL.",
              "anyOf": [
                {
                  "type": "string",
                  "format": "uri"
                },
                {
                  "type": "string",
                  "pattern": "^\\$\\{.+\\}$"
                }
              ]
            }
          }
        },
        "timeout": {
          "description": "Time in seconds. How long a request is allowed to run before throwing an exception. Default and maximum values vary by call.",
          "type": "number"
        },
        "connector_params": {
          "description": "Connector-specific parameters.",
          "type": "object",
          "properties": {
            "timeout": {
              "description": "Time in seconds. The end-to-end duration the connector call is allowed to run for before throwing a timeout exception.",
              "type": "integer",
              "default": 1800,
              "maximum": 31536000
            },
            "polling_policy": {
              "description": "Polling policy.",
              "type": "object",
              "properties": {
                "initial_delay": {
                  "description": "Time in seconds. Only applies to long-running operation calls.",
                  "type": "number",
                  "default": 1.0
                },
                "multiplier": {
                  "description": "Time in seconds. Only applies to long-running operation calls.",
                  "type": "number",
                  "default": 1.25
                },
                "max_delay": {
                  "description": "Time in seconds. Only applies to long-running operation calls.",
                  "type": "number",
                  "default": 60.0
                }
              }
            },
            "skip_polling": {
              "description": "If set to True, the connector invocation call is non-blocking if the initial request to manage or update the resource succeeds",
              "type": "boolean",
              "default": false
            },
            "scopes": {
              "description": "OAuth2 scopes to pass to the Google API.",
              "$ref": "#/definitions/scopes"
            }
          }
        }
      }
    },
    "result": {
      "description": "Assign the result from a call to this variable."
    },
    "next": {
      "description": "Define what step Workflows should execute next.",
      "anyOf": [
        {
          "description": "The step name.",
          "type": "string"
        },
        {
          "description": "Stop a workflow's execution without returning a value.",
          "type": "string",
          "const": "end"
        },
        {
          "description": "Terminate the current iteration of a for loop and continue with the next iteration.",
          "type": "string",
          "const": "continue"
        },
        {
          "description": "Terminate iteration of a for loop.",
          "type": "string",
          "const": "break"
        }
      ]
    },
    "return": {
      "description": "Stop a workflow's execution and return a value, variable, or expression."
    },
    "for": {
      "description": "Iterates over a sequence of numbers or through a collection of data, such as a list or map.",
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "steps"],
      "properties": {
        "value": {
          "description": "A loop variable name. Contains the value of the currently iterated element.",
          "type": "string"
        },
        "index": {
          "description": "An index variable name. Contains the value to the current offset of the iteration. ",
          "type": "string"
        },
        "in": {
          "description": "An expression that evaluates into a list or a list definition. Required, if not using 'range'.",
          "anyOf": [
            {
              "description": "A list.",
              "type": "array"
            },
            {
              "description": "An expression that evaluates into a list.",
              "type": "string",
              "pattern": "^\\$\\{.+\\}$"
            }
          ]
        },
        "range": {
          "description": "A list of two expressions, specifying the beginning and end of the range, both inclusive. Required, if not using 'in'.",
          "anyOf": [
            {
              "description": "Array specifying the beginning and end of the range, both inclusive.",
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 2,
              "maxItems": 2
            },
            {
              "description": "The expressions must evaluate into incrementable values; that is, integer or double. Make sure that you do not use multiple expressions inside a list like this: [${rangeStart}, ${rangeEnd}]).",
              "type": "string",
              "pattern": "^\\$\\{\\[.+\\]\\}$"
            }
          ]
        },
        "steps": {
          "description": "Each iteration the steps will be executed.",
          "$ref": "#/definitions/stepArray"
        }
      },
      "oneOf": [
        {
          "required": ["in"]
        },
        {
          "required": ["range"]
        }
      ]
    },
    "parallel": {
      "type": "object",
      "description": "Define a part of your workflow where two or more steps can execute concurrently. A 'parallel' step waits until all the steps defined within it have completed or are interrupted by an unhandled exception; execution then continues.",
      "additionalProperties": false,
      "properties": {
        "exception_policy": {
          "description": "The action for other branches when an exception occurs. Optional. The default policy, 'continueAll', results in no further action, and all other branches will attempt to run.",
          "type": "string",
          "const": "continueAll"
        },
        "shared": {
          "description": "A list of writable variables with parent scope that allow assignments within the 'parallel' step.",
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        },
        "concurrency_limit": {
          "description": "The maximum number of branches and iterations that can concurrently execute within a single workflow execution before further branches and iterations are queued to wait. This applies to a single 'parallel' step only and does not cascade. Must be a positive integer and can be either a literal value or an expression.",
          "type": "integer"
        },
        "branches": {
          "description": "Branches that can run concurrently. Required, if not using 'for'.",
          "$ref": "#/definitions/branches"
        },
        "for": {
          "description": "A loop where iterations can run concurrently. Required, if not using 'branches'.",
          "$ref": "#/definitions/for"
        }
      },
      "oneOf": [
        {
          "required": ["for"]
        },
        {
          "required": ["branches"]
        }
      ]
    },
    "branches": {
      "description": "Execute parallel branches concurrently and the steps in each branch sequentially.",
      "type": "array",
      "minItems": 2,
      "maxItems": 10,
      "$ref": "#/definitions/stepArray"
    },
    "switch": {
      "description": "A switch block. A selection mechanism that allows the value of an expression to control the flow of a workflow's execution. If a value matches, that condition's statement is executed.",
      "type": "array",
      "minItems": 1,
      "maxItems": 50,
      "items": {
        "$ref": "#/definitions/condition"
      }
    },
    "condition": {
      "type": "object",
      "description": "Define conditional expressions for a switch block.",
      "required": ["condition"],
      "properties": {
        "condition": {
          "description": "An expression to switch on.",
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\$\\{.+\\}$"
            },
            {
              "type": "boolean"
            }
          ]
        },
        "steps": {
          "$ref": "#/definitions/stepArray"
        },
        "assign": {
          "$ref": "#/definitions/assign"
        },
        "call": {
          "$ref": "#/definitions/call"
        },
        "args": {
          "$ref": "#/definitions/args"
        },
        "result": {
          "$ref": "#/definitions/result"
        },
        "next": {
          "$ref": "#/definitions/next"
        },
        "switch": {
          "$ref": "#/definitions/switch"
        },
        "for": {
          "$ref": "#/definitions/for"
        },
        "parallel": {
          "$ref": "#/definitions/parallel"
        },
        "raise": {
          "$ref": "#/definitions/raise"
        },
        "try": {
          "$ref": "#/definitions/try"
        },
        "retry": {
          "$ref": "#/definitions/retry"
        },
        "except": {
          "$ref": "#/definitions/except"
        },
        "return": {
          "$ref": "#/definitions/return"
        }
      }
    },
    "raise": {
      "description": "Raise an exception.",
      "anyOf": [
        {
          "description": "Error message string.",
          "type": "string"
        },
        {
          "description": "Error message map.",
          "type": "object",
          "properties": {
            "code": {
              "description": "Error code.",
              "type": "integer"
            },
            "message": {
              "description": "Error message string.",
              "type": "string"
            }
          }
        }
      ]
    },
    "try": {
      "description": "A try/except structure for error handling.",
      "anyOf": [
        {
          "description": "A step.",
          "$ref": "#/definitions/step"
        },
        {
          "description": "A list of steps.",
          "$ref": "#/definitions/stepArray"
        }
      ]
    },
    "except": {
      "description": "A try/except structure for error handling.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "as": {
          "description": "The name of a map variable that contains the error message.",
          "type": "string"
        },
        "steps": {
          "description": "A list of steps.",
          "$ref": "#/definitions/stepArray"
        }
      }
    },
    "retry": {
      "description": "Define a retry policy to retry steps that return a specific error code.",
      "oneOf": [
        {
          "type": "object",
          "description": "Retry block. Optional, if using a default retry policy.",
          "additionalProperties": false,
          "properties": {
            "predicate": {
              "type": "string",
              "description": "Defines which error codes will be retried. Options include ${http.default_retry_predicate}, ${http.default_retry_predicate_non_idempotent}, or a custom predicate defined as a subworkflow."
            },
            "max_retries": {
              "type": "integer",
              "description": "Maximum number of times a step will be retried, not counting the initial step execution attempt."
            },
            "backoff": {
              "type": "object",
              "description": "Block that controls how retries occur.",
              "additionalProperties": false,
              "properties": {
                "initial_delay": {
                  "type": "integer",
                  "description": "Delay in seconds between the initial failure and the first retry."
                },
                "max_delay": {
                  "type": "integer",
                  "description": "Maximum delay in seconds between retries."
                },
                "multiplier": {
                  "type": "integer",
                  "description": "Multiplier applied to the previous delay to calculate the delay for the subsequent retry."
                }
              }
            }
          }
        },
        {
          "description": "Default retry policy. Optional, if using retry block. Options include ${http.default_retry} and ${http.default_retry_non_idempotent}.",
          "type": "string",
          "pattern": "^\\$\\{.+\\}$"
        }
      ]
    },
    "scopes": {
      "description": "Specify token scope to limit an application's access to a user's account.",
      "anyOf": [
        {
          "description": "List of scope strings.",
          "type": "array",
          "contains": {
            "type": "string"
          }
        },
        {
          "description": "Scope string.",
          "type": "string"
        },
        {
          "description": "Space and comma-separated strings",
          "type": "string"
        }
      ]
    }
  },
  "description": "Orchestrate Workflows consisting of Google Cloud APIs, SaaS APIs or private API endpoints.",
  "oneOf": [
    {
      "type": "object",
      "description": "The main workflow.",
      "required": ["main"],
      "properties": {
        "main": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "params": {
              "description": "The name of the parameter variable.",
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 0,
              "maxItems": 1,
              "uniqueItems": true
            },
            "steps": {
              "description": "An array of objects with a single step.",
              "$ref": "#/definitions/stepArray"
            }
          }
        }
      },
      "additionalProperties": {
        "$ref": "#/definitions/subworkflow"
      }
    },
    {
      "description": "A list of steps.",
      "$ref": "#/definitions/stepArray"
    }
  ],
  "title": "Google Cloud Workflows"
}
