{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-plan/2022-03-01-preview4",
  "description": "PriceAndAvailability plan level resource schema definition",
  "allOf": [
    {
      "$ref": "https://schema.mp.microsoft.com/schema/resource/2022-03-01-preview2"
    },
    {
      "title": "plan",
      "type": "object",
      "required": [
        "product",
        "plan",
        "audience"
      ],
      "properties": {
        "product": {
          "$ref": "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2"
        },
        "plan": {
          "$ref": "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2"
        },
        "meterDefine": {
          "$ref": "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2"
        },
        "billingTag": {
          "type": "string"
        },
        "visibility": {
          "enum": [
            "visible",
            "hidden"
          ]
        },
        "markets": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2"
        },
        "pricing": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-price/2022-03-01-preview4"
        },
        "trial": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-trial/2022-03-01-preview3"
        },
        "softwareReservation": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-software-reservation/2022-03-01-preview2"
        },
        "audience": {
          "enum": [
            "public",
            "private"
          ]
        },
        "privateAudiences": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-audiences/2022-03-01-preview3"
        }
      }
    }
  ],
  "$defs": {
    "https://schema.mp.microsoft.com/schema/resource/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/resource/2022-03-01-preview2",
      "$comment": "This schema is extended by a resource type schema. We allow additional properties to enable that",
      "type": "object",
      "properties": {
        "resourceName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 50
        },
        "id": {
          "$ref": "https://schema.mp.microsoft.com/schema/durable-id/2022-03-01-preview2"
        },
        "validations": {
          "type": "array",
          "items": {
            "$ref": "https://schema.mp.microsoft.com/schema/validation/2022-03-01-preview2"
          },
          "readonly": true
        }
      },
      "required": [
        "$schema"
      ],
      "additionalProperties": true
    },
    "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2",
      "oneOf": [
        {
          "$ref": "https://schema.mp.microsoft.com/schema/durable-id/2022-03-01-preview2"
        },
        {
          "type": "object",
          "properties": {
            "externalId": {
              "description": "ExternalId for product and plan references. Property reference must be named product or plan.",
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9-_]{2,49}$",
              "minLength": 3,
              "maxLength": 50,
              "$example": {
                "plan": {
                  "externalId": "customerNamedPlan123"
                }
              }
            }
          },
          "required": [
            "externalId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "resourceName": {
              "description": "Resource Name that can be referenced using this value by another resource.",
              "type": "string",
              "pattern": "^[a-zA-Z0-9-_]\u002B$",
              "minLength": 1,
              "maxLength": 50,
              "$example": {
                "plan": {
                  "resourceName": "resourcePlan1"
                }
              }
            }
          },
          "required": [
            "resourceName"
          ]
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2",
      "description": "PriceAndAvailability audience definition",
      "title": "markets",
      "type": "array",
      "default": [],
      "items": {
        "type": "string",
        "pattern": "[a-z]{2,3}"
      }
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-price/2022-03-01-preview4": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-price/2022-03-01-preview4",
      "description": "PriceAndAvailability audience definition",
      "title": "price",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "licenseModel": {
          "enum": [
            "byol",
            "payAsYouGo"
          ]
        },
        "corePricing": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-core-price/2022-03-01-preview2"
        },
        "systemMeterPricing": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-system-meter-price/2022-03-01-preview2"
        },
        "recurrentPrice": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-recurrent-price/2022-03-01-preview3"
        },
        "customMeters": {
          "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-custom-meter-price/2022-03-01-preview3"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "licenseModel": {
                "const": "byol"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "not": {
                  "required": [
                    "corePricing",
                    "systemMeterPricing",
                    "recurrentPrice",
                    "customMeters"
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-trial/2022-03-01-preview3": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-trial/2022-03-01-preview3",
      "description": "PriceAndAvailability trial definition",
      "title": "trial",
      "type": [
        "object",
        "null"
      ],
      "required": [
        "type",
        "value"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "enum": [
            "day",
            "week",
            "month",
            "year"
          ]
        },
        "value": {
          "type": "number",
          "default": 0
        }
      }
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-software-reservation/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-software-reservation/2022-03-01-preview2",
      "description": "PriceAndAvailability audience definition",
      "title": "softwareReservation",
      "type": [
        "array",
        "null"
      ],
      "default": [],
      "items": {
        "type": "object",
        "required": [
          "type",
          "term",
          "percentageSave"
        ],
        "additionalProperties": false,
        "properties": {
          "type": {
            "enum": [
              "month",
              "year"
            ]
          },
          "term": {
            "type": "number",
            "default": 0
          },
          "percentageSave": {
            "type": "number",
            "default": 0
          }
        }
      }
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-audiences/2022-03-01-preview3": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-audiences/2022-03-01-preview3",
      "description": "PriceAndAvailability audience definition",
      "title": "audiences",
      "type": [
        "array",
        "null"
      ],
      "default": [],
      "items": {
        "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-audience/2022-03-01-preview3"
      }
    },
    "https://schema.mp.microsoft.com/schema/durable-id/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/durable-id/2022-03-01-preview2",
      "description": "A durable-id to an existing resource.",
      "type": "string",
      "pattern": "^[a-z](-?[a-z0-9]\u002B)*/[a-z0-9-]\u002B(\\/?[a-z0-9-])*$"
    },
    "https://schema.mp.microsoft.com/schema/validation/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/validation/2022-03-01-preview2",
      "allOf": [
        {
          "$ref": "https://schema.mp.microsoft.com/schema/inner-error/2022-03-01-preview2"
        },
        {
          "properties": {
            "$schema": {
              "$ref": "https://schema.mp.microsoft.com/schema/schema-uri/2022-03-01-preview2"
            },
            "level": {
              "type": "string",
              "enum": [
                "informational",
                "warning"
              ]
            }
          },
          "required": [
            "level"
          ]
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/inner-error/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/inner-error/2022-03-01-preview2",
      "type": "object",
      "properties": {
        "resourceId": {
          "$ref": "https://schema.mp.microsoft.com/schema/resource-reference/2022-03-01-preview2"
        },
        "code": {
          "type": "string",
          "readOnly": true,
          "enum": [
            "businessValidationError",
            "collectionLimitExceeded",
            "invalidId",
            "invalidEntityStatus",
            "invalidRequest",
            "invalidResource",
            "invalidState",
            "notDeployed",
            "notSupported",
            "operationCanceled",
            "productLocked",
            "resourceNotFound",
            "schemaValidationError"
          ]
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "$ref": "https://schema.mp.microsoft.com/schema/inner-error/2022-03-01-preview2"
          }
        }
      },
      "required": [
        "code"
      ]
    },
    "https://schema.mp.microsoft.com/schema/schema-uri/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/schema-uri/2022-03-01-preview2",
      "title": "Product Ingestion schema uri",
      "type": "string",
      "pattern": "^https://(schema(-int)?\\.mp\\.microsoft\\.com)|(product-ingestion(-int)?\\.azureedge\\.net)/schema/[a-z][a-z0-9]\u002B(?:-[a-z0-9]\u002B)*/\\d{4}(?:-\\d\\d){2}(?:-dev|-preview\\d\u002B)?$"
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-core-price/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-core-price/2022-03-01-preview2",
      "description": "PriceAndAvailability audience definition",
      "title": "price",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "priceInputOption": {
          "enum": [
            "free",
            "flat",
            "perCore",
            "perCoreSize",
            "perMarketAndCoreSize"
          ]
        },
        "price": {
          "type": "number",
          "default": 0
        },
        "pricePerCore": {
          "type": "number",
          "default": 0
        },
        "pricePerCoreSize": {
          "type": "object",
          "additionalProperties": {
            "type": "number",
            "default": 0
          }
        },
        "prices": {
          "type": "array",
          "default": [],
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "markets",
              "prices",
              "currency"
            ],
            "properties": {
              "markets": {
                "type": "array",
                "default": [],
                "items": {
                  "type": "string",
                  "pattern": "[a-z]{2,3}"
                }
              },
              "currency": {
                "type": "string",
                "pattern": "[a-z]{3}"
              },
              "prices": {
                "type": "object",
                "additionalProperties": {
                  "type": "number",
                  "default": 0
                }
              }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "free"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "not": {
                  "required": [
                    "price"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCore"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCoreSize"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "prices"
                  ]
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "flat"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "price"
                ]
              },
              {
                "not": {
                  "required": [
                    "pricePerCore"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCoreSize"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "prices"
                  ]
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perCore"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "pricePerCore"
                ]
              },
              {
                "not": {
                  "required": [
                    "price"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCoreSize"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "prices"
                  ]
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perCoreSize"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "pricePerCoreSize"
                ]
              },
              {
                "not": {
                  "required": [
                    "price"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCore"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "prices"
                  ]
                }
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perMarketAndCoreSize"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "prices"
                ]
              },
              {
                "not": {
                  "required": [
                    "price"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCore"
                  ]
                }
              },
              {
                "not": {
                  "required": [
                    "pricePerCoreSize"
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-system-meter-price/2022-03-01-preview2": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-system-meter-price/2022-03-01-preview2",
      "description": "PriceAndAvailability system meter pricing definition",
      "title": "system-meter",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "priceInputOption": {
          "enum": [
            "perCore",
            "perEveryCoreInCluster"
          ]
        },
        "price": {
          "type": "number",
          "default": 0
        },
        "prices": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "prices": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "markets": {
                      "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2"
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "[a-z]{3}"
                    },
                    "price": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perCore"
              }
            }
          },
          "then": {
            "anyOf": [
              {
                "required": [
                  "price"
                ]
              },
              {
                "required": [
                  "prices"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perEveryCoreInCluster"
              }
            }
          },
          "then": {
            "anyOf": [
              {
                "required": [
                  "price"
                ]
              },
              {
                "required": [
                  "prices"
                ]
              }
            ]
          }
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-recurrent-price/2022-03-01-preview3": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-recurrent-price/2022-03-01-preview3",
      "description": "Recurrent pricing",
      "title": "recurrent-pricing",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "priceInputOption",
        "prices"
      ],
      "properties": {
        "priceInputOption": {
          "type": "string",
          "enum": [
            "perMarket",
            "usd"
          ],
          "default": "usd"
        },
        "recurrentPriceMode": {
          "type": "string",
          "enum": [
            "flatRate",
            "perUser"
          ],
          "default": "flatRate"
        },
        "userLimits": {
          "properties": {
            "min": {
              "type": "number"
            },
            "max": {
              "type": "number"
            }
          },
          "required": [
            "min",
            "max"
          ]
        },
        "prices": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "properties": {
              "billingTerm": {
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "month",
                      "year"
                    ],
                    "default": "month"
                  },
                  "value": {
                    "type": "number"
                  }
                },
                "required": [
                  "type",
                  "value"
                ]
              },
              "paymentOption": {
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "month",
                      "year"
                    ],
                    "default": "month"
                  },
                  "value": {
                    "type": "number"
                  }
                },
                "required": [
                  "type",
                  "value"
                ]
              },
              "prices": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "markets": {
                      "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2"
                    },
                    "currency": {
                      "type": "string",
                      "pattern": "[a-z]{3}"
                    },
                    "price": {
                      "type": "number"
                    }
                  }
                }
              },
              "pricePerPaymentInUsd": {
                "type": "number"
              }
            },
            "required": [
              "billingTerm"
            ]
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "perMarket"
              }
            }
          },
          "then": {
            "properties": {
              "prices": {
                "items": {
                  "required": [
                    "prices"
                  ],
                  "not": {
                    "required": [
                      "pricePerPaymentInUsd"
                    ]
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "priceInputOption": {
                "const": "usd"
              }
            }
          },
          "then": {
            "properties": {
              "prices": {
                "items": {
                  "required": [
                    "pricePerPaymentInUsd"
                  ],
                  "not": {
                    "required": [
                      "prices"
                    ]
                  }
                }
              }
            }
          }
        }
      ]
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-custom-meter-price/2022-03-01-preview3": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-custom-meter-price/2022-03-01-preview3",
      "description": "Recurrent pricing",
      "title": "recurrent-pricing",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "priceInputOption",
        "meters"
      ],
      "properties": {
        "priceInputOption": {
          "enum": [
            "perMarket",
            "usd"
          ],
          "default": "usd"
        },
        "meters": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "includedQuantities": {
                "type": "array",
                "properties": {
                  "billingTerm": {
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "month",
                          "year"
                        ],
                        "default": "month"
                      },
                      "value": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "type",
                      "value"
                    ]
                  },
                  "isInfinite": {
                    "type": "boolean"
                  },
                  "quantity": {
                    "type": "number"
                  }
                }
              },
              "prices": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "properties": {
                    "prices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "markets": {
                            "$ref": "https://schema.mp.microsoft.com/schema/price-and-availability-market/2022-03-01-preview2"
                          },
                          "currency": {
                            "type": "string",
                            "pattern": "[a-z]{3}"
                          },
                          "price": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "pricePerPaymentInUsd": {
                      "type": "number"
                    }
                  }
                }
              }
            },
            "pricePerPaymentInUsd": {
              "type": "number"
            },
            "billingTerm": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "month",
                    "year"
                  ],
                  "default": "month"
                },
                "value": {
                  "type": "number"
                }
              },
              "required": [
                "type",
                "value"
              ]
            },
            "paymentOption": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "month",
                    "year"
                  ],
                  "default": "month"
                },
                "value": {
                  "type": "number"
                }
              },
              "required": [
                "type",
                "value"
              ]
            }
          }
        }
      }
    },
    "https://schema.mp.microsoft.com/schema/price-and-availability-audience/2022-03-01-preview3": {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "$id": "https://schema.mp.microsoft.com/schema/price-and-availability-audience/2022-03-01-preview3",
      "description": "PriceAndAvailability audience definition",
      "title": "audience",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "enum": [
            "none",
            "subscription",
            "ea",
            "msdn",
            "tenant",
            "email"
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 50
        },
        "label": {
          "type": "string",
          "maxLength": 1000
        }
      }
    }
  }
}