{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://constal.ai/docs/credentials/reference/provider-install.schema.json",
  "title": "Constal CredentialProvider installation",
  "type": "object",
  "required": ["package", "id", "config", "policies"],
  "oneOf": [
    { "required": ["credentials"] },
    { "required": ["bootstrap", "setupId"] }
  ],
  "additionalProperties": false,
  "properties": {
    "package": {
      "type": "object",
      "required": ["publisher", "namespace", "id", "version", "hash"],
      "additionalProperties": false,
      "properties": {
        "publisher": { "type": "string" },
        "namespace": { "type": "string" },
        "id": { "type": "string" },
        "version": { "type": "string" },
        "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
      }
    },
    "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,62}$" },
    "config": { "type": "object" },
    "credentials": { "type": "object", "additionalProperties": { "type": "string" } },
    "bootstrap": {
      "type": "object",
      "additionalProperties": {
        "oneOf": [
          { "type": "object", "required": ["credential"], "additionalProperties": false, "properties": { "credential": { "type": "string" } } },
          { "type": "object", "required": ["material"], "additionalProperties": false, "properties": { "material": { "type": "string", "minLength": 1, "writeOnly": true } } }
        ]
      }
    },
    "setupId": { "type": "string", "format": "uuid" },
    "policies": { "type": "array", "items": { "type": "string" } }
  }
}
