{
  "$comment": "Based on https://github.wdf.sap.corp/mta/spec/blob/master/schemas/v3/v3.3/mta-schema.yaml",
  "$id": "https://json.schemastore.org/mta.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "generic-memory": {
      "type": "string",
      "pattern": "^[1-9][0-9]*(M|MB|G|GB|m|mb|g|gb)$"
    },
    "properties": {
      "type": "object"
    },
    "properties-metadata": {
      "type": "object",
      "properties": {
        "overwritable": {
          "type": "boolean",
          "default": true
        },
        "optional": {
          "type": "boolean",
          "default": false
        },
        "datatype": {
          "enum": ["str", "int", "float", "bool"],
          "type": "string",
          "default": "str"
        }
      }
    },
    "parameters": {
      "type": "object"
    },
    "parameters-metadata": {
      "type": "object",
      "properties": {
        "overwritable": {
          "type": "boolean",
          "default": true
        },
        "optional": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "includes": {
      "type": "array",
      "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
      "items": {
        "type": "object",
        "required": ["name", "path"],
        "properties": {
          "name": {
            "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
            "type": "string"
          },
          "path": {
            "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
            "type": "string"
          }
        }
      }
    },
    "hooks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "description": "An internal name which can be used for documentation purposes and shown by the deployer.",
            "type": "string",
            "pattern": "^[A-Za-z0-9_\\-\\.]+$"
          },
          "type": {
            "description": "Defines the type of action that should be executed by the deployer.",
            "type": "string",
            "enum": ["task"]
          },
          "phases": {
            "description": "A list of strings that define the points at which the hook must be executed.",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "application.before-stop.live",
                "application.before-stop.idle",
                "application.after-stop.live",
                "application.after-stop.idle"
              ]
            }
          },
          "parameters": {
            "description": "Configuration parameters that are used when executing the hook to the target runtime environment.",
            "$ref": "#/definitions/hooks-parameters"
          },
          "parameters-metadata": {
            "description": "Additional information about the hook's parameters.",
            "$ref": "#/definitions/properties-metadata"
          },
          "requires": {
            "description": "List of names either matching a resource name or a provided dependency name provided within the same MTA that are required by this hook.",
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": {
                  "description": "An MTA internal name which must match either a provided name, or a resource name within the same MTA.",
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_\\-\\.]+$"
                },
                "parameters": {
                  "description": "Parameters can be used to influence the behavior of tools which interpret this descriptor. Parameters are not made available to the hook at runtime. Provided property values can be accessed by \"~{<provided-property-name>}\". Such expressions can be part of an arbitrary string",
                  "type": "object"
                },
                "parameters-metadata": {
                  "description": "Additional information about the hook's parameters.",
                  "$ref": "#/definitions/properties-metadata"
                }
              }
            }
          }
        }
      }
    },
    "hooks-parameters": {
      "type": "object",
      "required": ["command"],
      "properties": {
        "name": {
          "description": "Defines the name of the Cloud Foundry task that should be executed.",
          "type": "string"
        },
        "command": {
          "description": "Defines the actual command that is executed as a Cloud Foundry task.",
          "type": "string"
        },
        "memory": {
          "description": "Defines the memory that is available to the Cloud Foundry task.",
          "$ref": "#/definitions/generic-memory"
        },
        "disk-quota": {
          "description": "Defines the disk space that is available to the Cloud Foundry task.",
          "$ref": "#/definitions/generic-memory"
        }
      }
    }
  },
  "description": "MTA DESCRIPTOR SCHEMA",
  "properties": {
    "_schema-version": {
      "description": "The schema version that is being used for authoring a descriptor. The schema version should comply with the semantic versioning standard.",
      "type": "string"
    },
    "ID": {
      "description": "An application ID, that may contain any number of unicode characters and should be unique in the target runtime environment.",
      "type": "string",
      "pattern": "^[A-Za-z0-9_\\-\\.]+$"
    },
    "description": {
      "description": "A free text describing this application.",
      "type": "string"
    },
    "version": {
      "description": "The application version that should comply with the semantic versioning standard.",
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$"
    },
    "provider": {
      "description": "The provider or vendor of this application.",
      "type": "string"
    },
    "copyright": {
      "description": "A copyright statement from the provider.",
      "type": "string"
    },
    "modules": {
      "description": "A list of modules.",
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "type"],
        "properties": {
          "name": {
            "description": "The MTA module name which must be unique and cannot be the same as any provided property set or resource name.",
            "type": "string",
            "pattern": "^[A-Za-z0-9_\\-\\.]+$"
          },
          "type": {
            "description": "The module type that defines the design-time tools for the module.",
            "type": "string"
          },
          "description": {
            "description": "A free text describing this module.",
            "type": "string"
          },
          "path": {
            "description": "The path to a folder that contains the module artifacts.",
            "type": "string"
          },
          "deployed-after": {
            "description": "A list of modules that must be deployed before deploying the current module.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "properties": {
            "description": "A collection of key-value pairs that are available to the module at runtime.",
            "$ref": "#/definitions/properties"
          },
          "properties-metadata": {
            "description": "Additional information about the module's properties.",
            "$ref": "#/definitions/properties-metadata"
          },
          "parameters": {
            "description": "Configuration parameters that are used when deploying the module to the target runtime environment.",
            "$ref": "#/definitions/parameters"
          },
          "parameters-metadata": {
            "description": "Additional information about the module's parameters.",
            "$ref": "#/definitions/parameters-metadata"
          },
          "hooks": {
            "description": "A list of hooks that will be executed for the module.",
            "$ref": "#/definitions/hooks"
          },
          "build-parameters": {
            "description": "The build parameters define how the module is built by the corresponding tool.",
            "type": "object"
          },
          "includes": {
            "type": "array",
            "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
            "items": {
              "type": "object",
              "required": ["name", "path"],
              "properties": {
                "name": {
                  "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
                  "type": "string"
                },
                "path": {
                  "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
                  "type": "string"
                }
              }
            }
          },
          "provides": {
            "description": "Used to define the named property sets that other modules and resources can require.",
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": {
                  "description": "The name of the property set that the module provides. The provided name must be unique and cannot be the same as any resource or module name.",
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_\\-\\.]+$"
                },
                "public": {
                  "description": "Configures the accessibility of the provided property set; if set to \"true\", it is publicly accessible and can be consumed by other MTA projects.",
                  "type": "boolean",
                  "default": false
                },
                "properties": {
                  "description": "A list of properties that are included in this property set.",
                  "$ref": "#/definitions/properties"
                },
                "properties-metadata": {
                  "description": "Additional information about the provided set's properties.",
                  "$ref": "#/definitions/properties-metadata"
                }
              }
            }
          },
          "requires": {
            "description": "A list of property sets provided by other modules and/or resources (providers) that this module requires.",
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": {
                  "description": "The name of a provided property set or resource (provider) that this module requires.",
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_\\-\\.]+$"
                },
                "group": {
                  "description": "A \"group\" can be used to combine properties from multiple providers into one runtime lookup object, such as an environment variable. As of schema version 2.1, this property is DEPRECATED.",
                  "type": "string"
                },
                "list": {
                  "description": "Defines a name for a runtime lookup object, such as an environment variable, if the required property set contains multiple values; for example, if used to consume configuration data from outside this MTA project.",
                  "type": "string"
                },
                "properties": {
                  "description": "Module properties whose values are determined by the provided properties. These properties can be referenced by the tilde notation: \"~{<provided-property-name>}\" ",
                  "$ref": "#/definitions/properties"
                },
                "properties-metadata": {
                  "description": "Additional information about the modules' properties.",
                  "$ref": "#/definitions/properties-metadata"
                },
                "parameters": {
                  "description": "Configuration parameters that are used when deploying the module to the target runtime environment.",
                  "$ref": "#/definitions/parameters"
                },
                "parameters-metadata": {
                  "description": "Additional information about the modules' parameters.",
                  "$ref": "#/definitions/parameters-metadata"
                },
                "includes": {
                  "type": "array",
                  "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
                  "items": {
                    "type": "object",
                    "required": ["name", "path"],
                    "properties": {
                      "name": {
                        "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
                        "type": "string"
                      },
                      "path": {
                        "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "resources": {
      "description": "A list of resources that are required by the modules of this MTA project.",
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "description": "The resource name which must be unique and cannot be the same as any provided property set or module name.",
            "type": "string",
            "pattern": "^[A-Za-z0-9_\\-\\.]+$"
          },
          "type": {
            "description": "A type of resource supported by deployment tools in the target environment.",
            "type": "string"
          },
          "description": {
            "description": "A free text describing this resource.",
            "type": "string"
          },
          "properties": {
            "description": "A collection of key-value pairs that can be required by modules and/or other resources as configuration data at runtime.",
            "$ref": "#/definitions/properties"
          },
          "properties-metadata": {
            "description": "Additional information about the resource's properties.",
            "$ref": "#/definitions/properties-metadata"
          },
          "parameters": {
            "description": "Configuration parameters that are used when provisioning the resource in the target runtime environment.",
            "$ref": "#/definitions/parameters"
          },
          "parameters-metadata": {
            "description": "Additional information about the resource's parameters.",
            "$ref": "#/definitions/parameters-metadata"
          },
          "includes": {
            "type": "array",
            "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
            "items": {
              "type": "object",
              "required": ["name", "path"],
              "properties": {
                "name": {
                  "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
                  "type": "string"
                },
                "path": {
                  "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
                  "type": "string"
                }
              }
            }
          },
          "optional": {
            "description": "If the resource is set to optional and the deployment tools are unable to allocate it, then the tools will issue a warning and continue the deployment process.",
            "type": "boolean",
            "default": false
          },
          "processed-after": {
            "description": "A list containing the names of the resources that must be processed prior to this one.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "active": {
            "description": "If a resource is declared to be inactive, the resource will not be allocated during the deployment process.",
            "type": "boolean",
            "default": true
          },
          "requires": {
            "description": "A list of property sets provided by other modules and/or resources (providers) that this resource requires.",
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name"],
              "properties": {
                "name": {
                  "description": "The name of a provided property set or resource (provider) that this resource requires.",
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_\\-\\.]+$"
                },
                "properties": {
                  "description": "Resource properties whose values are determined by the provided properties. These properties can be referenced by the tilde notation: \"~{<provided-property-name>}\" ",
                  "$ref": "#/definitions/properties"
                },
                "properties-metadata": {
                  "description": "Additional information about the required properties.",
                  "$ref": "#/definitions/properties-metadata"
                },
                "parameters": {
                  "description": "Configuration parameters that are used when provisioning the resource in the target runtime environment.",
                  "$ref": "#/definitions/parameters"
                },
                "parameters-metadata": {
                  "description": "Additional information about the required parameters.",
                  "$ref": "#/definitions/parameters-metadata"
                },
                "includes": {
                  "type": "array",
                  "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
                  "items": {
                    "type": "object",
                    "required": ["name", "path"],
                    "properties": {
                      "name": {
                        "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
                        "type": "string"
                      },
                      "path": {
                        "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "description": "Global parameters that are used when building or deploying the application",
      "$ref": "#/definitions/parameters"
    },
    "parameters-metadata": {
      "description": "Additional information about the global parameters.",
      "$ref": "#/definitions/parameters-metadata"
    },
    "includes": {
      "type": "array",
      "description": "It is possible to define parameters in external files. The \"includes\" section is used to point to those files.",
      "items": {
        "type": "object",
        "required": ["name", "path"],
        "properties": {
          "name": {
            "description": "The name of an \"includes\" section. This name is used by a builder to generate a parameter section in the deployment descriptor.",
            "type": "string"
          },
          "path": {
            "description": "A path pointing to a file that contains a map of parameters, either in JSON or in YAML format.",
            "type": "string"
          }
        }
      }
    }
  },
  "required": ["_schema-version", "ID", "version"],
  "title": "com.sap.mta.mta-schema_3.3",
  "type": "object"
}
