{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "title": "Puppet Task Metadata",
  "description": "The metadata format for Puppet Tasks",
  "type": "object",
  "properties": {
    "description": {
      "type": "string",
      "description": "A longer description(one paragraph) of how to use the task"
    },
    "puppet_task_version": {
      "type": "integer",
      "description": "The version of this spec used",
      "default": 1
    },
    "supports_noop": {
      "type": "boolean",
      "default": false,
      "description": "This task respects the '_noop' metaparam. If this false or absent the task runner will refuse to run this task if noop is specified."
    },
    "remote": {
      "type": "boolean",
      "default": false,
      "description": "This task is capable of operating on a remote target using connection information in the '_target' metaparam."
    },
    "input_method": {
      "type": "string",
      "enum": ["stdin", "environment", "both", "powershell"],
      "description": "What input method should be used to pass params to the task"
    },
    "parameters": {
      "$ref": "#/definitions/paramsObject",
      "description": "An object mapping valid parameter names to corresponding json-schemas"
    },
    "implementations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of task executable file"
          },
          "requirements": {
            "type": "array",
            "additionalItems": {
              "type": "string"
            },
            "description": "Features required on target to execute task"
          },
          "files": {
            "type": "array",
            "additionalItems": {
              "type": "string"
            },
            "description": "File resources required by task"
          }
        }
      },
      "description": "Rules for selecting implementation resources based on features available on target"
    },
    "files": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Path to file resources saved in valid module directory to be provided to task"
    },
    "private": {
      "type": "boolean",
      "description": "Should this task appear by default in UI lists of tasks"
    },
    "extensions": {
      "type": "object",
      "description": "Task Runner specific metadata extensions",
      "items": {
        "type": "object"
      }
    }
  },
  "definitions": {
    "parameterName": {
      "description": "Valid names for parameter keys",
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$"
    },
    "paramsObject": {
      "type": "object",
      "description": "An object with restricted keys and enumData support",
      "propertyNames": {"$ref": "#/definitions/parameterName"},
      "additionalProperties": {
        "type": "object",
        "description": "Extend Normal JSON schema to require an object and describe 'enumData' to map enum values to descriptions",
        "properties": {
          "description": {
            "description": "A description of the parameter",
            "type": "string"
          },
          "type": {
            "description": "A puppet type string that describes a data type that will match the parameter value",
            "type": "string"
          },
          "sensitive": {
            "description": "Whether the task runner should treat the parameter value as sensitive",
            "type": "boolean",
            "default": false
          },
          "default": {
            "description": "The default value to pass to the task implementation if the parameter isn't provided"
          }
        }
      }
    }
  }
}
