{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.datastrato.ai/schemas/audit-record.schema.json",
  "title": "Datastrato Enterprise audit record",
  "description": "One line of the audit log written by JsonAuditFormatter.",
  "type": "object",
  "required": [
    "timestamp",
    "user",
    "operation",
    "operationType",
    "identifier",
    "status",
    "operationStatus",
    "eventSource",
    "remoteAddress",
    "customInfo"
  ],
  "properties": {
    "timestamp": {
      "description": "When the operation finished, ISO 8601 with milliseconds and the zone offset.",
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}(Z|[+-]\\d{2}:\\d{2})$"
    },
    "user": {
      "description": "The authenticated principal, 'anonymous' under the simple authenticator without a name, or 'unknown' for an HTTP-level record with no authenticated principal.",
      "type": ["string", "null"]
    },
    "operationType": {
      "description": "What was done. An open set: new operation types appear as features are added. Key on this field.",
      "type": "string"
    },
    "operation": {
      "description": "Older, coarser operation name kept for existing consumers. Several operation types share one value.",
      "type": "string"
    },
    "identifier": {
      "description": "Full dotted name of the object, starting with the metalake, or null for HTTP-level records.",
      "type": ["string", "null"]
    },
    "operationStatus": {
      "description": "Outcome of the operation.",
      "enum": ["SUCCESS", "FAILURE", "UNPROCESSED", "UNKNOWN"]
    },
    "status": {
      "description": "Outcome under its older name, kept for existing consumers.",
      "enum": ["SUCCESS", "FAILURE", "UNKNOWN"]
    },
    "eventSource": {
      "description": "The endpoint that served the request.",
      "enum": [
        "GRAVITINO_SERVER",
        "GRAVITINO_ICEBERG_REST_SERVER",
        "GRAVITINO_LANCE_REST_SERVER"
      ]
    },
    "remoteAddress": {
      "description": "Where the request came from: the first X-Forwarded-For entry, or the connection address.",
      "type": ["string", "null"]
    },
    "customInfo": {
      "description": "Extra facts about the operation, as string keys and values. Empty when there are none.",
      "type": "object",
      "additionalProperties": { "type": "string" }
    },
    "resultCount": {
      "description": "Number of items a list operation returned. Present only on list operations.",
      "type": "integer",
      "minimum": 0
    }
  },
  "additionalProperties": true
}
