{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.humancellatlas.org/system/2.2.0/file_descriptor",
  "description": "Checksums and other information for asserting the integrity of a data file.",
  "additionalProperties": false,
  "required": [
    "describedBy",
    "schema_type",
    "content_type",
    "size",
    "sha256",
    "crc32c",
    "file_id",
    "file_version",
    "file_name"
  ],
  "title": "File descriptor",
  "name": "file_descriptor",
  "type": "object",
  "properties": {
    "describedBy": {
      "description": "The URL reference to the schema.",
      "type": "string",
      "pattern": "^https?://schema.(.*)?humancellatlas.org/system/(([0-9]{1,}.[0-9]{1,}.[0-9]{1,})|([a-zA-Z]*?))/file_descriptor$"
    },
    "schema_version": {
      "description": "The version number of the schema in major.minor.patch format.",
      "type": "string",
      "pattern": "^[0-9]{1,}\\.[0-9]{1,}\\.[0-9]{1,}$",
      "example": "4.6.1"
    },
    "schema_type": {
      "description": "The type of the metadata schema entity.",
      "type": "string",
      "enum": [
        "file_descriptor"
      ]
    },
    "file_name": {
      "description": "The object name of the data file relative to the staging area's `data/` directory",
      "type": "string",
      "user_friendly": "Staging file name",
      "example": "1b6d8348-d6e9-406a-aa6a-7ee886e52bf9/IDC9_L004_R2.fastq.gz"
    },
    "file_id": {
      "description": "UUID that uniquely identifies each data file in its source",
      "type": "string",
      "user_friendly": "File UUID",
      "example": "111f222a-333b-444c-555d-eee63ddfccc7",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    },
    "file_version": {
      "description": "The version of the file given in date time format",
      "type": "string",
      "user_friendly": "File version",
      "example": "2020-05-01T04:26:07.021870Z",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{6}Z$"
    },
    "content_type": {
      "description": "An appropriate MIME type for this file.",
      "type": "string",
      "user_friendly": "Content type",
      "example": "application/gzip"
    },
    "size": {
      "description": "The size of the file in bytes.",
      "type": "integer",
      "minimum": 0,
      "user_friendly": "Size",
      "example": 2147483648
    },
    "sha256": {
      "description": "The SHA-256 hash of the file.",
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "user_friendly": "SHA-256",
      "example": "12998c017066eb0d2a70b94e6ed3192985855ce390f321bbdb832022888bd251"
    },
    "crc32c": {
      "description": "The CRC-32C code generated for this file.",
      "type": "string",
      "pattern": "^[a-f0-9]{8}$",
      "user_friendly": "CRC32C",
      "example": "0b83b575"
    },
    "sha1": {
      "description": "The SHA-1 hash of the file.",
      "type": "string",
      "pattern": "^[a-f0-9]{40}$",
      "user_friendly": "SHA-1",
      "example": "6e71b3cac15d32fe2d36c270887df9479c25c640"
    },
    "s3_etag": {
      "description": "An AWS S3 ETag of this file",
      "user_friendly": "S3 ETag",
      "type": "string",
      "example": "c92e5374ac0a53b228d4c1511c2d2842-63"
    },
    "drs_uri": {
      "description": "Data Repository Service URI pointing at this file. If this property is absent, a data file exists in the repository containing this descriptor. If this property is present and not `null`, a data file exists in another repository at the specified URI. If this property is present but `null`, the data file is not available, but will likely become available in the future, along with an updated descriptor referencing it.",
      "user_friendly": "Data Repository Service URI",
      "anyOf": [
        {
          "type": "null"
        },
        {
          "$comment": "Host-based DRS URI. We use the `uri` format so as to not reinvent the wheel but we need to disallow colons in the authority (what the DRS spec calls hostname) and in the path (what the DRS spec calls ID). The DRS spec explicitly states that the hostname can't have a colon. And if we allowed colons in the ID, `drs://a/b:c` would be ambiguous: it could be a host-based DRS URI with hostname `a` and ID `b:c` or a compact identifier-based DRS URI with prefix `a/b` and accession `c`.",
          "type": "string",
          "format": "uri",
          "pattern": "^drs://[^/:]+/[^:]+$"
        },
        {
          "$comment": "Compact identifier-based DRS URI. We can't use the `uri` format because a colon in the URI authority must be followed by a numeric port number, whereas the DRS spec simply says to use the compact identifier verbatim, without escaping the colon that separates prefix and accession. Accessions arent't necessarily numeric. We can be pretty restrictive about the prefix (optional provider code, followed by slash and namespace) because the spec explicitly lists the allowed characters, but like the ID in host-based DRS URIs, there are no such restrictions for accession.",
          "type": "string",
          "pattern": "^drs://([A-Za-z0-9._]+/)?[A-Za-z0-9._]+:.+$"
        }
      ],
      "example": "drs://drs.example.org/314159"
    }
  }
}
