{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Template",
  "$id": "https://ela.st/harp-v1-template.json",
  "definitions": {
    "Template": {
      "properties": {
        "apiVersion": {
          "type": "string",
          "const": "harp.elastic.co/v1"
        },
        "kind": {
          "type": "string",
          "const": "BundleTemplate"
        },
        "meta": {
          "$ref": "#/definitions/harp.bundle.v1.TemplateMeta",
          "additionalProperties": false
        },
        "spec": {
          "$ref": "#/definitions/harp.bundle.v1.TemplateSpec",
          "additionalProperties": false
        }
      },
      "required": ["apiVersion", "kind", "meta", "spec"],
      "additionalProperties": false,
      "type": "object",
      "title": "Template",
      "description": "Template represents bundle template generation definition."
    },
    "harp.bundle.v1.ApplicationComponentNS": {
      "properties": {
        "type": {
          "type": ["string", "null"],
          "description": "Application type."
        },
        "name": {
          "type": "string",
          "description": "Application name.",
          "default": "application-1",
          "examples": [
            "application-1",
            "harp"
          ]
        },
        "description": {
          "type": "string",
          "description": "Application short description.",
          "default": "Application 1 is used for ..."
        },
        "secrets": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.SecretSuffix"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Secret definitions."
        }
      },
      "required": ["name", "description", "secrets"],
      "additionalProperties": false,
      "type": "object",
      "title": "Application Component NS",
      "description": "ApplicationComponentNS describes application components."
    },
    "harp.bundle.v1.InfrastructureNS": {
      "properties": {
        "provider": {
          "type": "string",
          "description": "Infrastructure provider",
          "default": "aws",
          "examples": [
            "aws",
            "azure",
            "gcp",
            "ibm",
            "local"
          ]
        },
        "account": {
          "type": "string",
          "description": "Infrastructure provider account",
          "default": "1234567890"
        },
        "name": {
          "type": ["string", "null"],
          "description": "Infrastructure provider account alias (user-friendly name)"
        },
        "description": {
          "type": ["string", "null"],
          "description": "Short descript for the infrastructure purpose."
        },
        "regions": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.InfrastructureRegionNS"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Cloud Provider Regions"
        }
      },
      "required": ["provider", "account", "regions"],
      "additionalProperties": false,
      "type": "object",
      "title": "Infrastructure NS",
      "description": "InfrastructureSpec is the container for R1 secret generators."
    },
    "harp.bundle.v1.InfrastructureRegionNS": {
      "properties": {
        "name": {
          "type": "string",
          "description": "Infrastructure provider region name",
          "default": "eu-central-1",
          "examples": [
            "us-east-1",
            "us-west-2"
          ]
        },
        "services": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.InfrastructureServiceNS"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Service secret definitions"
        }
      },
      "required": ["name", "services"],
      "additionalProperties": false,
      "type": "object",
      "title": "Infrastructure Region NS",
      "description": "InfrastructureRegionSpec describes region partition."
    },
    "harp.bundle.v1.InfrastructureServiceNS": {
      "properties": {
        "type": {
          "type": "string",
          "description": "Service type.",
          "default": "ec2",
          "examples": [
            "ec2",
            "rds",
            "kms",
            "iam"
          ]
        },
        "name": {
          "type": "string",
          "description": "Service name.",
          "default": ""
        },
        "description": {
          "type": ["string", "null"],
          "description": "Service usage short description."
        },
        "secrets": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.SecretSuffix"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Secret definitions."
        }
      },
      "required": ["type", "name", "secrets"],
      "additionalProperties": false,
      "type": "object",
      "title": "Infrastructure Service NS",
      "description": "InfrastructureServiceSpec describes infrastructure service."
    },
    "harp.bundle.v1.Namespaces": {
      "properties": {
        "infrastructure": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.InfrastructureNS"
          },
          "additionalProperties": false,
          "type": ["array", "null"],
          "description": "Infrastructure secret definitions."
        },
        "platform": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.PlatformRegionNS"
          },
          "additionalProperties": false,
          "type": ["array", "null"],
          "description": "Platform secret definitions."
        },
        "product": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.ProductComponentNS"
          },
          "additionalProperties": false,
          "type": ["array", "null"],
          "description": "Product secret definitions."
        },
        "application": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.ApplicationComponentNS"
          },
          "additionalProperties": false,
          "type": ["array", "null"],
          "description": "Application secret definitions."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "Namespaces",
      "description": "Namespaces defines secret generation template specification accoridng to CSO path naming."
    },
    "harp.bundle.v1.PlatformComponentNS": {
      "properties": {
        "type": {
          "type": "string",
          "description": "Component type."
        },
        "name": {
          "type": "string",
          "description": "Component name."
        },
        "description": {
          "type": "string",
          "description": "Component short description."
        },
        "secrets": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.SecretSuffix"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Secret definitions."
        }
      },
      "required": ["name", "secrets"],
      "additionalProperties": false,
      "type": "object",
      "title": "Platform Component NS",
      "description": "PlatformComponentSpec describes platform components."
    },
    "harp.bundle.v1.PlatformRegionNS": {
      "properties": {
        "region": {
          "type": "string",
          "description": "Platform region name."
        },
        "description": {
          "type": "string",
          "description": "Platform region short description."
        },
        "components": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.PlatformComponentNS"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Platform components deployed in the given region."
        }
      },
      "required": ["region", "components"],
      "additionalProperties": false,
      "type": "object",
      "title": "Platform Region NS",
      "description": "PlatformRegionNS is the container for R2 secret generators."
    },
    "harp.bundle.v1.ProductComponentNS": {
      "properties": {
        "type": {
          "type": "string",
          "description": "Product type."
        },
        "name": {
          "type": "string",
          "description": "Product name."
        },
        "description": {
          "type": "string",
          "description": "Product short description."
        },
        "secrets": {
          "items": {
            "$ref": "#/definitions/harp.bundle.v1.SecretSuffix"
          },
          "additionalProperties": false,
          "type": "array",
          "description": "Secret definitions."
        }
      },
      "required": ["name", "secrets"],
      "additionalProperties": false,
      "type": "object",
      "title": "Product Component NS",
      "description": "ProductComponentNS describes product components."
    },
    "harp.bundle.v1.SecretSuffix": {
      "properties": {
        "suffix": {
          "type": "string",
          "description": "CSO Suffix.",
          "default": "path/subpath/leaf",
          "examples": [
            "database/credentials/admin",
            "http/server/cookie_seed"
          ]
        },
        "description": {
          "type": "string",
          "description": "Short description of the purpose of the secret.",
          "default": "This secret is used for ..."
        },
        "vendor": {
          "type": ["boolean", "null"],
          "description": "Defines if secret is managed or not (generated vs static secret).",
          "default": false
        },
        "template": {
          "type": ["string", "null"],
          "description": "JSON Template for K/V Generation.",
          "default": "{}",
          "contentMediaType": "application/json"
        },
        "content": {
          "additionalProperties": {
            "type": "string"
          },
          "type": ["object", "null"],
          "description": "String Content for file embedding process. (filename / content)"
        },
        "labels": {
          "additionalProperties": {
            "type": "string"
          },
          "type": ["object", "null"],
          "description": "Secret labels contains identifying information used for query (i.e. Patch selector).",
          "default": {
            "key": "value"
          }
        },
        "annotations": {
          "additionalProperties": {
            "type": "string"
          },
          "type": ["object", "null"],
          "description": "Secret annotations not used internally. Used by external harp environments.",
          "default": {
            "key": "value"
          }
        }
      },
      "required": ["suffix"],
      "oneOf": [{
          "allOf": [{
              "required": ["template"]
            },
            {
              "not": {
                "required": ["content"]
              }
            }
          ]
        },
        {
          "allOf": [{
              "required": ["content"]
            },
            {
              "not": {
                "required": ["template"]
              }
            }
          ]
        },
        {
          "allOf": [{
              "required": ["template"]
            },
            {
              "required": ["content"]
            }
          ]
        }
      ],
      "additionalProperties": false,
      "type": "object",
      "title": "Secret Suffix",
      "description": "SecretSuffix holds secret value generation details."
    },
    "harp.bundle.v1.Selector": {
      "properties": {
        "quality": {
          "type": ["string", "null"],
          "description": "Quality defines default quality value for CSO path builder.",
          "default": "production",
          "examples": [
            "dev",
            "qa",
            "staging",
            "production"
          ]
        },
        "platform": {
          "type": ["string", "null"],
          "description": "Platform defines default platform value in CSO path builder.",
          "default": "platform-1"
        },
        "product": {
          "type": ["string", "null"],
          "description": "Product defines default product value in CSO path builder.",
          "default": "product-1"
        },
        "application": {
          "type": ["string", "null"],
          "description": "Application defines default application value in CSO path builder.",
          "default": "application-1"
        },
        "version": {
          "type": ["string", "null"],
          "description": "Version defines default version value in CSO path builder.",
          "default": "v1.0.0"
        },
        "component": {
          "type": ["string", "null"],
          "description": "Component defines default component value in CSO path builder.",
          "default": "component",
          "examples": [
            "backend",
            "frontend",
            "database",
            "client",
            "server"
          ]
        }
      },
      "dependencies": {
        "component": ["version"],
        "version": ["product"],
        "product": ["platform"],
        "platform": ["quality"]
      },
      "additionalProperties": false,
      "type": "object",
      "title": "Selector",
      "description": "BundleTemplateSelector defines secret path generator default values."
    },
    "harp.bundle.v1.TemplateMeta": {
      "properties": {
        "name": {
          "type": "string",
          "description": "Template name.",
          "default": "bundle-template-1"
        },
        "owner": {
          "type": "string",
          "description": "Template owner.",
          "default": "owner@domain.tld"
        },
        "description": {
          "type": "string",
          "description": "Short description for template role.",
          "default": "This template generates all secrets for ..."
        }
      },
      "required": ["name", "owner", "description"],
      "additionalProperties": false,
      "type": "object",
      "title": "Template Meta",
      "description": "TemplateMeta handles bundle template metadata."
    },
    "harp.bundle.v1.TemplateSpec": {
      "properties": {
        "selector": {
          "$ref": "#/definitions/harp.bundle.v1.Selector",
          "additionalProperties": false
        },
        "namespaces": {
          "$ref": "#/definitions/harp.bundle.v1.Namespaces",
          "additionalProperties": false
        }
      },
      "required": ["namespaces"],
      "additionalProperties": false,
      "type": "object",
      "title": "Template Spec",
      "description": "TemplateSpec handles bundle template specification."
    }
  }
}
