{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "imports-v2/card_links.json",
  "title": "Card links",
  "description": "A link shown in the Links block of a card: a page in another system (`url`), another card of the package (`linked_card_ref`) or a document of the package (`linked_document_ref`). Write one record per link on a card; give exactly one of the three. Only http and https addresses are accepted. `description` is the caption shown to users.",
  "type": "object",
  "properties": {
    "external_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Your own identifier of the record, for example `k-mrr`, unique within the resource across all of its files and case sensitive. Other records refer to this one by it."
    },
    "card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "The card that shows the link. Give the external_id of a `cards` record."
    },
    "url": {
      "type": "string",
      "maxLength": 16384,
      "pattern": "^https?://",
      "format": "uri",
      "description": "The address of a page outside the package, for example `https://dashboards.example.com/mrr`. Only http and https; up to 16384 characters.",
      "x-required-when": "linked_card_ref and linked_document_ref are absent"
    },
    "linked_card_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "cards",
      "description": "Another card of the package that the link opens. It differs from `card_ref`, and its external_id contains only latin letters, digits, `_` and `-`. Give the external_id of a `cards` record.",
      "x-required-when": "url and linked_document_ref are absent"
    },
    "linked_document_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "x-ref": "documents",
      "description": "A document of the package that the link opens. Give the external_id of a `documents` record.",
      "x-required-when": "url and linked_card_ref are absent"
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "description": "The caption shown for the link, for example `Live MRR dashboard`."
    }
  },
  "required": [
    "external_id",
    "card_ref"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "oneOf": [
        {
          "required": [
            "url"
          ]
        },
        {
          "required": [
            "linked_card_ref"
          ]
        },
        {
          "required": [
            "linked_document_ref"
          ]
        }
      ]
    }
  ]
}
