{
  "$defs": {
    "AccessPolicy": {
      "additionalProperties": false,
      "description": "Access rules on a data connection, copied onto each connected dataset (POC DATA-CATALOGUE \u00a72).",
      "properties": {
        "allowed_uses": {
          "items": {
            "enum": [
              "fit",
              "score",
              "side_modelling",
              "benchmark",
              "transform"
            ],
            "type": "string"
          },
          "title": "Allowed Uses",
          "type": "array"
        },
        "copy_policy": {
          "default": "transient_only",
          "enum": [
            "allowed",
            "transient_only",
            "aggregates_only"
          ],
          "title": "Copy Policy",
          "type": "string"
        },
        "licence_limits": {
          "anyOf": [
            {
              "$ref": "#/$defs/LicenceLimits"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "min_segment_size": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "For aggregates_only; defaults to the contract's G-PRIV-01 floor.",
          "title": "Min Segment Size"
        },
        "retention_days": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "For cached copies; defaults to the client contract's retention_days (rules.effective_access).",
          "title": "Retention Days"
        }
      },
      "title": "AccessPolicy",
      "type": "object"
    },
    "ConnectionTest": {
      "additionalProperties": false,
      "description": "Result of ``POST /v1/connections/{id}:test``: reachability, auth and schema. No rows.",
      "properties": {
        "auth_ok": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Auth Ok"
        },
        "latency_ms": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Latency Ms"
        },
        "message": {
          "default": "",
          "title": "Message",
          "type": "string"
        },
        "notes": {
          "items": {
            "$ref": "#/$defs/Note"
          },
          "title": "Notes",
          "type": "array"
        },
        "ok": {
          "title": "Ok",
          "type": "boolean"
        },
        "reachable": {
          "title": "Reachable",
          "type": "boolean"
        },
        "schema_columns": {
          "items": {
            "type": "string"
          },
          "title": "Schema Columns",
          "type": "array"
        },
        "stub": {
          "default": false,
          "description": "Labelled stub connector (CONNECTOR_STUB).",
          "title": "Stub",
          "type": "boolean"
        },
        "tested_at": {
          "format": "date-time",
          "title": "Tested At",
          "type": "string"
        }
      },
      "required": [
        "ok",
        "tested_at",
        "reachable"
      ],
      "title": "ConnectionTest",
      "type": "object"
    },
    "LicenceLimits": {
      "additionalProperties": false,
      "description": "Vendor or client licence limits checked before export (spec \u00a720).",
      "properties": {
        "ids": {
          "items": {
            "type": "string"
          },
          "title": "Ids",
          "type": "array"
        },
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Text"
        }
      },
      "title": "LicenceLimits",
      "type": "object"
    },
    "Note": {
      "additionalProperties": false,
      "description": "Informational or warning note (e.g. ``ENGINE_STUB``, ``NOT_IMPLEMENTED_IN_POC``).",
      "properties": {
        "code": {
          "pattern": "^[A-Z][A-Z0-9_]*$",
          "title": "Code",
          "type": "string"
        },
        "gate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Gate"
        },
        "message": {
          "title": "Message",
          "type": "string"
        },
        "severity": {
          "default": "info",
          "enum": [
            "info",
            "warn"
          ],
          "title": "Severity",
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "title": "Note",
      "type": "object"
    },
    "SecretStatus": {
      "additionalProperties": false,
      "description": "All the API ever echoes about a secret: its reference, whether one is set, and when it changed.\nRotating the secret changes ``updated_at``, never the connection's id.",
      "properties": {
        "secret_ref": {
          "description": "secret://<client_id>/<name>",
          "pattern": "^secret://[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-/]+$",
          "title": "Secret Ref",
          "type": "string"
        },
        "set": {
          "default": false,
          "title": "Set",
          "type": "boolean"
        },
        "updated_at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Updated At"
        }
      },
      "required": [
        "secret_ref"
      ],
      "title": "SecretStatus",
      "type": "object"
    }
  },
  "$id": "https://schemas.ump.dev/v1/data-connection.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "access": {
      "$ref": "#/$defs/AccessPolicy"
    },
    "approved_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): approver principal.",
      "title": "Governance ApprovedBy"
    },
    "client_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Client Id"
    },
    "config": {
      "additionalProperties": true,
      "description": "Non-secret settings: host, base URL, project, table pattern, JSON path, pagination. Never a password or token.",
      "title": "Config",
      "type": "object"
    },
    "connector": {
      "enum": [
        "rest_api",
        "sql",
        "bigquery",
        "object_store",
        "clean_room"
      ],
      "title": "Connector",
      "type": "string"
    },
    "content_hash": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): the artifact content hash.",
      "title": "Governance ContentHash"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Description"
    },
    "gate_results": {
      "anyOf": [
        {
          "items": {},
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): gate results of the latest run.",
      "title": "Governance GateResults"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): artifact id.",
      "title": "Governance Id"
    },
    "last_test": {
      "anyOf": [
        {
          "$ref": "#/$defs/ConnectionTest"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "owner": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Owner"
    },
    "revision": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): content revision (spec \u00a77).",
      "title": "Governance Revision"
    },
    "secret": {
      "anyOf": [
        {
          "$ref": "#/$defs/SecretStatus"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "state": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): lifecycle state of the version.",
      "title": "Governance State"
    },
    "stub": {
      "default": false,
      "description": "The connector is a labelled stub in this POC build.",
      "title": "Stub",
      "type": "boolean"
    },
    "submitted_by": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Governance member (spec \u00a76): submitter principal.",
      "title": "Governance SubmittedBy"
    },
    "valid_to": {
      "default": null,
      "description": "Governance member (spec \u00a76): end of the validity window (spec \u00a77).",
      "title": "Governance ValidTo"
    }
  },
  "required": [
    "name",
    "connector"
  ],
  "title": "DataConnection",
  "type": "object"
}
