{
  "namespace": "com.pacbio.common.models.contracts",
  "type": "record",
  "name": "ToolContract",
  "fields": [
    {
      "doc": "Version of the ToolContract",
      "name": "version",
      "type": "string"
    },
     {
      "doc": "Schema Version of the ToolContract",
      "name": "schema_version",
      "type": ["string", "null"]
    },
    {
      "_comment": "(this is duplicated in the Task?)",
      "doc": "Fully qualified id of the tool contract (in the legacy model this is also the task type id)",
      "name": "tool_contract_id",
      "type": "string"
    },
    {
      "name": "tool_contract",
      "type": {
        "type": "record",
        "name": "ToolContractTask",
        "doc": "Task for defining metadata of the task interface such as Input and Output file types, task options and other metadata",
        "fields": [
          {
            "name": "input_types",
            "type": {
              "type": "array",
              "items": {
                "type": "record",
                "name": "ToolInputFile",
                "fields": [
                  {
                    "doc": "Id of input file",
                    "name": "id",
                    "type": "string"
                  },
                  {
                    "doc": "PacBio File Type identifier, PacBio.DataSet.SubreadSet",
                    "name": "file_type_id",
                    "type": "string"
                  },
                  {
                    "doc": "Display Name of input file type",
                    "name": "title",
                    "type": "string"
                  },
                  {
                    "doc": "Description of input file type",
                    "name": "description",
                    "type": "string"
                  }
                ]
              }
            }
          },
          {
            "name": "output_types",
            "doc": "Output file types of Task",
            "type": {
              "type": "array",
              "items": {
                "type": "record",
                "name": "ToolOutputFile",
                "doc": "",
                "fields": [
                  {
                    "_comment": "FIXME(mpkocher) This needs to be clearly defined",
                    "doc": "Unique id for referencing the output file",
                    "name": "id",
                    "type": "string"
                  },
                  {
                    "doc": "PacBio FileType identifier, e.g., PacBio.DataSets.SubreadSet",
                    "name": "file_type_id",
                    "type": "string"
                  },
                  {
                    "doc": "Display Name of the output file name",
                    "name": "title",
                    "type": "string"
                  },
                  {
                    "doc": "Default base name of the file name. This must be provided without the extension. The extension is determined by the `file_type_id`",
                    "name": "default_name",
                    "type": "string"
                  },
                  {
                    "doc": "Description of Output file",
                    "name": "description",
                    "type": "string"
                  }
                ]
              }
            }
          },
          {
            "name": "schema_options",
            "type": {
              "type": "array",
              "items": {
                "type": "record",
                "name": "PacBioOptions",
               "fields": [
                        {
                          "doc": "Default value for the task option. Every task *must* have default value",
                          "name": "default",
                          "type": [
                            "int",
                            "string",
                            "boolean",
                            "float"
                          ]
                        },
                        {
                          "doc": "Globally unique id of the form {namespace}.task_options.{key}. Example (pbtacos.task_options.max_records)",
                          "name": "id",
                          "type": "string"
                        },
                        {
                          "doc": "Display name of task option",
                          "name": "name",
                          "type": "string"
                        },
                        {
                          "doc": "Description of Task Option",
                          "name": "description",
                          "type": "string"
                        },
                        {
                          "doc": "PacBio task option type",
                          "name": "optionTypeId",
                          "type": {
                            "doc": "This needs to be considerably improved and clarified. The option type must be consistent with the value defined. The naming is using camelcase because the same data model is used in the pipeline template.",
                            "type": "enum",
                            "name": "PacBioOptionType",
                            "aliases": ["com.pacbio.common.models.contracts.PacBioOptionType"],
                            "symbols": [
                              "integer",
                              "boolean",
                              "string",
                              "float",
                              "choice_float",
                              "choice_string",
                              "choice_integer"
                            ]
                          }
                        }
                      ]
              }
            }
          },
          {
            "doc": "Description of Tool/Task",
            "name": "description",
            "type": "string"
          },
          {
            "doc": "Display Name of Tool/Task",
            "name": "name",
            "type": "string"
          },
          {
            "_comment": "FIXME(mpkocher) This can be given as a Symbol `$max_nproc`",
            "doc": "Number of processors to use. This can be given as a Symbol `$max_nproc` See pbsmrtpipe docs for more details",
            "name": "nproc",
            "type": "int"
          },
          {
            "doc": "Globally unique Tool Contract identifier",
            "name": "tool_contract_id",
            "type": "string"
          },
          {
            "doc": "Task class type, Standard, Scatter, Gather",
            "name": "task_type",
            "type": "string",
            "default": "pbsmrtpipe.task_types.standard"
          },
          {
            "doc": "Determine if the task will be submitted to the cluster resources",
            "name": "is_distributed",
            "type": "boolean"
          },
          {
            "doc": "This needs to be converted to an ENUM. Allowed values $tmpfile $tmpdir",
            "name": "resource_types",
            "type": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ]
      }
    },
    {
      "name": "driver",
      "type": {
        "type": "record",
        "name": "ToolDriver",
        "fields": [
          {
            "doc": "path to exe. The first arg will the the resolved tool contract JSON",
            "name": "exe",
            "type": "string"
          },
          {
            "doc": "Serialization type. Either 'json' or 'avro' binary format ",
            "name": "serialization",
            "type": "string"
          }
        ]
      }
    }
  ]
}