{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "OpsChain actions.yaml",
  "type": "object",
  "properties": {
    "include": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {
              "file": {
                "type": "string"
              },
              "namespace": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false,
            "required": [
              "file"
            ]
          }
        ]
      }
    },
    "require": {
      "type": [
        "string",
        "array"
      ],
      "items": {
        "type": "string"
      }
    },
    "resources": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "properties": {
            "type": "object"
          }
        },
        "additionalProperties": false,
        "required": [
          "type"
        ]
      }
    },
    "actions": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/action"
      }
    }
  },
  "additionalProperties": false,
  "definitions": {
    "action": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string"
        },
        "step_name": {
          "type": "string"
        },
        "steps": {
          "$ref": "#/definitions/steps"
        },
        "run_as": {
          "enum": [
            "sequential",
            "parallel"
          ]
        },
        "ignore_failure": {
          "type": "boolean"
        },
        "reload_actions": {
          "type": "boolean"
        },
        "input_arguments": {
          "type": [
            "array",
            "object"
          ]
        },
        "requires_approval_from": {
          "type": [
            "array",
            "object"
          ]
        },
        "prerequisites": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": "string"
          }
        },
        "run": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "dangerously_allow_script_interpolation": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/step"
      }
    },
    "step": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "properties": {
            "action": {
              "type": "string"
            },
            "ignore_failure": {
              "type": "boolean"
            },
            "wait": {
              "type": "boolean"
            },
            "input_arguments": {
              "type": [
                "array",
                "object"
              ]
            },
            "requires_approval_from": {
              "type": [
                "array",
                "object"
              ]
            },
            "step_name": {
              "type": "string"
            },
            "wait_step_name": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "action"
          ]
        },
        {
          "type": "object",
          "properties": {
            "wait": {
              "oneOf": [
                {
                  "enum": [
                    true
                  ]
                },
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "object",
                  "properties": {
                    "seconds": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "step_name": {
                      "type": "string"
                    },
                    "steps": {
                      "$ref": "#/definitions/steps"
                    },
                    "ignore_failure": {
                      "type": "boolean"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "seconds": {
              "type": "integer",
              "minimum": 0
            },
            "step_name": {
              "type": "string"
            },
            "steps": {
              "$ref": "#/definitions/steps"
            },
            "ignore_failure": {
              "type": "boolean"
            }
          },
          "additionalProperties": false,
          "required": [
            "wait"
          ]
        },
        {
          "type": "object",
          "properties": {
            "approval": {
              "type": "object",
              "properties": {
                "requires_approval_from": {
                  "type": [
                    "array",
                    "object"
                  ]
                },
                "step_name": {
                  "type": "string"
                },
                "steps": {
                  "$ref": "#/definitions/steps"
                },
                "ignore_failure": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            },
            "requires_approval_from": {
              "type": [
                "array",
                "object"
              ]
            },
            "step_name": {
              "type": "string"
            },
            "steps": {
              "$ref": "#/definitions/steps"
            },
            "ignore_failure": {
              "type": "boolean"
            }
          },
          "additionalProperties": false,
          "required": [
            "approval"
          ]
        },
        {
          "type": "object",
          "properties": {
            "input": {
              "type": "object",
              "properties": {
                "input_arguments": {
                  "type": [
                    "array",
                    "object"
                  ]
                },
                "step_name": {
                  "type": "string"
                },
                "steps": {
                  "$ref": "#/definitions/steps"
                },
                "ignore_failure": {
                  "type": "boolean"
                },
                "run_as": {
                  "enum": [
                    "sequential",
                    "parallel"
                  ]
                }
              },
              "additionalProperties": false
            },
            "input_arguments": {
              "type": [
                "array",
                "object"
              ]
            },
            "step_name": {
              "type": "string"
            },
            "steps": {
              "$ref": "#/definitions/steps"
            },
            "ignore_failure": {
              "type": "boolean"
            },
            "run_as": {
              "enum": [
                "sequential",
                "parallel"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "input"
          ]
        },
        {
          "type": "object",
          "properties": {
            "parallel": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/step"
              }
            },
            "step_name": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "parallel"
          ]
        },
        {
          "type": "object",
          "properties": {
            "sequential": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/step"
              }
            },
            "step_name": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "sequential"
          ]
        },
        {
          "$ref": "#/definitions/inlineStep"
        }
      ]
    },
    "inlineStep": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "step_name": {
          "type": "string"
        },
        "steps": {
          "$ref": "#/definitions/steps"
        },
        "run_as": {
          "enum": [
            "sequential",
            "parallel"
          ]
        },
        "ignore_failure": {
          "type": "boolean"
        },
        "reload_actions": {
          "type": "boolean"
        },
        "input_arguments": {
          "type": [
            "array",
            "object"
          ]
        },
        "requires_approval_from": {
          "type": [
            "array",
            "object"
          ]
        },
        "prerequisites": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": "string"
          }
        },
        "run": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "dangerously_allow_script_interpolation": {
          "type": "boolean"
        }
      },
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "anyOf": [
        {
          "required": [
            "run"
          ]
        },
        {
          "required": [
            "steps"
          ]
        }
      ]
    }
  }
}
