{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Configuration for build cache with Azure storage configuration",

  "type": "object",

  "additionalProperties": false,

  "required": ["storageAccountName", "storageContainerName"],

  "definitions": {
    "loginFlow": {
      "type": "string",
      "description": "The Primary Entra ID login flow to use. Defaults to 'AdoCodespacesAuth' on GitHub Codespaces, 'VisualStudioCode' otherwise. If this flow fails it will fall back based on the configuration in `loginFlowFailover`.",
      "enum": [
        "AdoCodespacesAuth",
        "InteractiveBrowser",
        "DeviceCode",
        "VisualStudioCode",
        "AzureCli",
        "AzureDeveloperCli",
        "AzurePowerShell"
      ]
    },
    "fallbackLoginFlow": {
      "$ref": "#/definitions/loginFlow",
      "description": "The Entra ID login flow to fall back to. If null, a failure in this login mode is terminal."
    }
  },

  "properties": {
    "storageAccountName": {
      "type": "string",
      "description": "(Required) The name of the the Azure storage account to use for build cache."
    },

    "storageContainerName": {
      "type": "string",
      "description": "(Required) The name of the container in the Azure storage account to use for build cache."
    },

    "azureEnvironment": {
      "type": "string",
      "description": "The Azure environment the storage account exists in. Defaults to AzurePublicCloud.",
      "enum": ["AzurePublicCloud", "AzureChina", "AzureGermany", "AzureGovernment"]
    },

    "loginFlow": {
      "$ref": "#/definitions/loginFlow"
    },

    "loginFlowFailover": {
      "type": "object",
      "description": "Optional configuration for a fallback login flow if the primary login flow fails. If not defined, the default order is: AdoCodespacesAuth -> VisualStudioCode -> AzureCli -> AzureDeveloperCli -> AzurePowerShell -> InteractiveBrowser -> DeviceCode.",
      "additionalProperties": false,
      "properties": {
        "AdoCodespacesAuth": {
          "allOf": [
            { "$ref": "#/definitions/fallbackLoginFlow" },
            { "not": { "enum": ["AdoCodespacesAuth"] } }
          ]
        },
        "InteractiveBrowser": {
          "allOf": [
            { "$ref": "#/definitions/fallbackLoginFlow" },
            { "not": { "enum": ["InteractiveBrowser"] } }
          ]
        },
        "DeviceCode": {
          "allOf": [{ "$ref": "#/definitions/fallbackLoginFlow" }, { "not": { "enum": ["DeviceCode"] } }]
        },
        "VisualStudioCode": {
          "allOf": [
            { "$ref": "#/definitions/fallbackLoginFlow" },
            { "not": { "enum": ["VisualStudioCode"] } }
          ]
        },
        "AzureCli": {
          "allOf": [{ "$ref": "#/definitions/fallbackLoginFlow" }, { "not": { "enum": ["AzureCli"] } }]
        },
        "AzureDeveloperCli": {
          "allOf": [
            { "$ref": "#/definitions/fallbackLoginFlow" },
            { "not": { "enum": ["AzureDeveloperCli"] } }
          ]
        },
        "AzurePowerShell": {
          "allOf": [{ "$ref": "#/definitions/fallbackLoginFlow" }, { "not": { "enum": ["AzurePowerShell"] } }]
        }
      }
    },

    "blobPrefix": {
      "type": "string",
      "description": "An optional prefix for cache item blob names."
    },

    "storageEndpoint": {
      "type": "string",
      "description": "An optional custom endpoint URL for the Azure Blob Storage account. Use this to connect to Azurite, private endpoints, or storage emulators. When specified, this overrides the default endpoint derived from storageAccountName. Example: \"http://127.0.0.1:10000/devstoreaccount1\" or \"https://my-proxy.example.com/devstoreaccount1\"",
      "format": "uri"
    },

    "isCacheWriteAllowed": {
      "type": "boolean",
      "description": "If set to true, allow writing to the cache. Defaults to false."
    },

    "readRequiresAuthentication": {
      "type": "boolean",
      "description": "If set to true, reading the cache requires authentication. Defaults to false."
    }
  }
}
