{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/rudder-techniques.json",
  "$defs": {
    "uuid": {
      "type": "string",
      "format": "uuid"
    },
    "techniqueParameter": {
      "type": "object",
      "title": "technique parameter",
      "defaultSnippets": [
        {
          "label": "- (technique parameter)",
          "type": "object",
          "description": "add a new technique parameter",
          "suggestionKind": 9,
          "body": {
            "name": "\"internal_name\"",
            "description": "\"Friendly name\"",
            "constraints": {
              "allow_empty": false
            }
          }
        }
      ],
      "required": ["name"],
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/uuid",
          "title": "technique parameter id",
          "description": "UUID identifying the parameter",
          "markdownDescription": "```Optional```\n\nUUID identifying the parameter"
        },
        "description": {
          "title": "technique parameter description",
          "description": "Technique parameter description",
          "markdownDescription": "```Optional```\n\nTechnique parameter description",
          "type": "string"
        },
        "documentation": {
          "title": "technique parameter documentation",
          "type": "string",
          "description": "Technique parameter documentation, nor in Markdown format",
          "markdownDescription": "```Optional```\n\nTechnique parameter documentation, not in markdown format"
        },
        "name": {
          "title": "technique parameter name",
          "description": "Technique parameter name, must match the '^[a-zA-Z0-9_]+$' pattern",
          "markdownDescription": "```Optional```\n\nTechnique parameter name, must match the `^[a-zA-Z0-9_]+$` pattern",
          "type": "string",
          "pattern": "^[a-zA-Z0-9_]+$"
        },
        "type": {
          "type": "string",
          "title": "technique parameter type",
          "description": "Technique parameter type, only 'multiline-string' is currently supported for techniques visible in the technique editor",
          "markdownDescription": "```Optional```\n\nTechnique parameter type, only 'multiline-string' is currently supported for techniques visible in the technique editor",
          "enum": [
            null,
            "string",
            "multiline-string",
            "json",
            "yaml",
            "boolean",
            "mail",
            "ip",
            "ipv4",
            "ipv6",
            "integer",
            "size-b",
            "size-kb",
            "size-mb",
            "size-gb",
            "size-tb",
            "permissions",
            "shared-file",
            "password"
          ]
        },
        "default": {
          "title": "technique parameter default value",
          "description": "Default value of the parameter",
          "markdownDescription": "```Optional```\n\nDefault value of the parameter",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "boolean"
            },
            {
              "type": "number"
            }
          ]
        },
        "constraints": {
          "type": "object",
          "title": "technique parameter constraint",
          "description": "Additional checks on the parameter value when directives are computed",
          "markdownDescription": "```Optional```\n\nAdditional checks on the parameter value when directives are computed",
          "additionalProperties": false,
          "properties": {
            "allow_empty": {
              "title": "technique parameter allow empty constraint",
              "type": "boolean"
            },
            "password_hashes": {
              "type": "array",
              "title": "technique parameter password hashes constraint",
              "items": {
                "type": "string",
                "enum": [
                  null,
                  "pre-hashed",
                  "plain",
                  "unix-crypt-des",
                  "md5",
                  "sha1",
                  "sha256",
                  "sha512",
                  "md5-crypt",
                  "sha256-crypt",
                  "sha512-crypt",
                  "md5-crypt-aix",
                  "sha256-crypt-aix",
                  "sha512-crypt-aix"
                ]
              }
            },
            "regex": {
              "type": "object",
              "title": "technique parameter regex constraint",
              "required": ["value"],
              "properties": {
                "value": {
                  "type": "string",
                  "format": "regex",
                  "title": "technique parameter regex constraint pattern"
                },
                "error_message": {
                  "title": "technique parameter regex constraint error message",
                  "type": "string"
                }
              }
            },
            "select": {
              "type": "array",
              "title": "technique parameter select constraint",
              "items": {
                "type": "object",
                "required": ["value"],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "tags": {
      "type": "object"
    },
    "policyMode": {
      "type": "string",
      "enum": ["audit", "enforce", "none"]
    },
    "methodReportingMode": {
      "type": "object",
      "title": "method reporting mode",
      "properties": {
        "mode": {
          "enum": ["disabled", "enabled"]
        }
      }
    },
    "blockReportingMode": {
      "title": "block reporting mode",
      "examples": [
        {
          "mode": "focus",
          "id": "\"8f00b173-826e-46a3-9f57-7416de9b1b02\""
        },
        {
          "mode": "weighted"
        }
      ],
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "mode": {
              "enum": [
                "worst-case-weighted-one",
                "worst-case-weighted-sum",
                "disabled",
                "enabled",
                "weighted"
              ]
            }
          },
          "required": ["mode"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/uuid"
            },
            "mode": {
              "const": "focus"
            }
          },
          "required": ["mode", "id"],
          "additionalProperties": false
        }
      ]
    },
    "methodCall": {
      "type": "object",
      "title": "method call",
      "additionalProperties": false,
      "defaultSnippets": [
        {
          "label": "- (method call)",
          "type": "object",
          "description": "add a new method call",
          "suggestionKind": 9,
          "body": {
            "name": "\"My method title\"",
            "method": "package_present",
            "params": {
              "name": "vim"
            }
          }
        }
      ],
      "properties": {
        "name": {
          "title": "method call name",
          "type": "string"
        },
        "method": {
          "title": "name of the method to call",
          "type": "string"
        },
        "params": {
          "title": "technique params",
          "description": "parameters passed to the method",
          "markdownDescription": "See the [methods documentation](https://docs.rudder.io/techniques/8.0/audit_from_command.html) to know which parameters are needed",
          "type": "object"
        },
        "id": {
          "$ref": "#/$defs/uuid",
          "title": "method call id"
        },
        "tags": {
          "$ref": "#/$defs/tags",
          "title": "method call tags"
        },
        "policy_mode_override": {
          "$ref": "#/$defs/policyMode",
          "title": "method call policy mode override"
        },
        "condition": {
          "title": "condition",
          "description": "Method call optional condition",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "boolean"
            }
          ],
          "examples": ["debian|rhel", "SuSE.!sles_10"]
        },
        "reporting": {
          "$ref": "#/$defs/methodReportingMode"
        }
      },
      "required": ["method", "params"]
    },
    "blockCall": {
      "type": "object",
      "title": "block call",
      "additionalProperties": false,
      "defaultSnippets": [
        {
          "label": "- (block call)",
          "type": "object",
          "description": "add a new block call",
          "suggestionKind": 8,
          "body": {
            "name": "\"My block title\"",
            "condition": "any",
            "items": []
          }
        }
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/item"
          }
        },
        "name": {
          "title": "name",
          "description": "Block call name",
          "type": "string",
          "examples": ["My block title"]
        },
        "id": {
          "$ref": "#/$defs/uuid",
          "title": "block call id"
        },
        "tags": {
          "$ref": "#/$defs/tags",
          "title": "block call tags"
        },
        "policy_mode_override": {
          "$ref": "#/$defs/policyMode",
          "title": "block call policy mode"
        },
        "condition": {
          "title": "block call condition",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "boolean"
            }
          ],
          "examples": ["debian|rhel", "SuSE.!sles_10"]
        },
        "reporting": {
          "$ref": "#/$defs/blockReportingMode"
        }
      },
      "required": ["items"]
    },
    "item": {
      "type": "object",
      "title": "block or method call",
      "anyOf": [
        {
          "$ref": "#/$defs/blockCall"
        },
        {
          "$ref": "#/$defs/methodCall"
        }
      ]
    }
  },
  "title": "Rudder Technique",
  "description": "A Rudder technique",
  "type": "object",
  "required": ["id", "name", "version", "items"],
  "additionalProperties": false,
  "properties": {
    "format": {
      "title": "technique format",
      "type": "number"
    },
    "id": {
      "type": "string",
      "title": "id",
      "description": "Technique, must match the '^[a-zA-Z0-9_]+$' pattern",
      "markdownDescription": "```Mandatory```\n\nTechnique id, must respect the ```^[a-zA-Z0-9_]+$``` pattern.\n\nUsed implicitly in technique parameters and resource folder variable definitions:\n\n* ```${<technique_id>.<parameter_name>}```\n* ```${<technique_id>.resources_dir}```",
      "pattern": "^[a-zA-Z0-9_]+$",
      "default": "my_technique",
      "examples": ["my_new_technique"]
    },
    "name": {
      "title": "name",
      "description": "Human readable technique name",
      "markdownDescription": "```Mandatory```\n\nHuman readable technique name",
      "type": "string",
      "default": "My new technique",
      "examples": ["My new technique"]
    },
    "description": {
      "title": "description",
      "description": "Single line description of what the technique does",
      "markdownDescription": "```Optional```\n\nHuman readable technique name",
      "type": "string"
    },
    "documentation": {
      "type": "string",
      "title": "documentation",
      "description": "Technique documentation in Markdown format",
      "markdownDescription": "```Optional```\n\nTechnique documentation in Markdown format",
      "format": "markdown"
    },
    "tags": {
      "$ref": "#/$defs/tags",
      "description": "Optional key-value metadata",
      "markdownDescription": "```Optional```\n\nOptional key-value metadata",
      "examples": [
        {
          "cve": "\"CVE-2023-3456\""
        }
      ]
    },
    "params": {
      "type": "array",
      "title": "params",
      "description": "List of the technique parameters",
      "markdownDescription": "```Optional```\n\nList of technique parameters. See [the dedicated documentation](https://docs.rudder.io/techniques/8.0/syntax.html#parameters)",
      "items": {
        "$ref": "#/$defs/techniqueParameter"
      }
    },
    "category": {
      "title": "category",
      "description": "Rudder category to put the technique in",
      "markdownDescription": "```Optional```\n\nRudder category to put the technique in.\n\nIf empty, default to `ncf_techniques`, used by default by the technique editor.",
      "type": "string",
      "examples": [
        "ncf_techniques",
        "fileConfiguration",
        "fileDistribution",
        "jobScheduling"
      ]
    },
    "version": {
      "type": "string",
      "title": "version",
      "description": "Technique version in the 'X.Y' format",
      "markdownDescription": "```Mandatory```\n\nTechnique version in the 'X.Y' format",
      "pattern": "^[0-9]+\\.[0-9]+$",
      "default": "1.0",
      "examples": ["1.0"]
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "title": "items",
      "description": "List of block or method calls, can not be empty",
      "markdownDescription": "```Mandatory```\n\nList of block or method calls, can not be empty",
      "items": {
        "$ref": "#/$defs/item"
      }
    }
  }
}
