{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/confighub/json-schema/confighub-unit-event-schema.json",
  "title": "UnitEvent",
  "description": "UnitEvent records the outcome of a UnitAction on a Unit: the result a worker reported for an\noperation queued for it, such as a function invocation on the Unit completing or failing, or a\ncancellation being acknowledged, and the failure of an operation that could not be delivered to\nits worker. Each event records the action, its result and status, any message, and when the\noperation started and ended. UnitEvents are numbered per Unit by UnitEventNum.\n\nUnitEvents do not report on live systems. Configuration reaches live systems through Releases,\nwhich GitOps tools such as Argo CD and Flux pull. Events written by bridge workers, which applied,\ndestroyed, and refreshed Units in live systems and have been removed, can remain in a Unit's\nhistory, but are no longer written.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/confighub-unitevent-api-openapi.yml#/components/schemas/UnitEvent",
  "type": "object",
  "properties": {
    "Action": {
      "allOf": [
        {
          "$ref": "#/$defs/ActionType"
        }
      ],
      "description": "Action is the action of the UnitAction this event reports on, such as InvokeFunctions or Cancel. Events written by bridge workers, which have been removed, can carry the actions they performed, such as Apply.",
      "x-confighub-where": {
        "dataType": "string"
      }
    },
    "BridgeWorkerID": {
      "type": "string",
      "description": "BridgeWorkerID is the ID of the worker the UnitAction was queued for: the worker that reported the result.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid",
        "references": "BridgeWorker"
      }
    },
    "CreatedAt": {
      "type": "string",
      "description": "The timestamp when the entity was created in \"2023-01-01T12:00:00Z\" format.",
      "format": "date-time",
      "readOnly": true,
      "x-confighub-where": {
        "dataType": "time"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "EntityType": {
      "type": "string",
      "description": "The type of entity.",
      "readOnly": true,
      "x-go-type-skip-optional-pointer": true
    },
    "HiddenReason": {
      "maxLength": 64,
      "pattern": "^([A-Za-z0-9]([\\-_.A-Za-z0-9]*[A-Za-z0-9])?)?$",
      "type": "string",
      "description": "The reason the entity is hidden, if it is. A hidden entity is left out of List and Search results, and of what bulk operations act on, unless the include_hidden parameter names its reason or is *, or the where parameter names the entity by Slug or ID. ConfigHub/YAML Units are created hidden with the reason BackingUnit unless given another.",
      "x-confighub-where": {
        "dataType": "string"
      },
      "x-go-type-skip-optional-pointer": true
    },
    "Message": {
      "type": "string",
      "description": "Message is the message reported with the result, by the worker or, for an operation that failed before reaching it, by ConfigHub.",
      "x-go-type-skip-optional-pointer": true
    },
    "OrganizationID": {
      "type": "string",
      "description": "Unique identifier for an Organization.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid",
        "references": "Organization"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "QueuedOperationID": {
      "type": "string",
      "description": "QueuedOperationID is the unique identifier of the UnitAction this event reports on.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid",
        "references": "QueuedOperation"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "Result": {
      "allOf": [
        {
          "$ref": "#/$defs/ActionResultType"
        }
      ],
      "description": "Result is what the action produced: FunctionInvocationCompleted or FunctionInvocationFailed for a function invocation, and None otherwise. Events written by bridge workers, which have been removed, can carry the results they reported.",
      "x-confighub-where": {
        "dataType": "string"
      }
    },
    "RevisionNum": {
      "type": "integer",
      "description": "RevisionNum is the number of the Unit's Revision the action was performed on.",
      "format": "int64",
      "x-confighub-where": {
        "dataType": "int",
        "references": "Revision"
      },
      "x-go-type-skip-optional-pointer": true
    },
    "SpaceID": {
      "type": "string",
      "description": "Unique identifier for a space.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid",
        "references": "Space"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "SpaceSlug": {
      "type": "string",
      "description": "Slug of the Space this entity belongs to. (readonly)",
      "readOnly": true,
      "x-go-type-skip-optional-pointer": true
    },
    "StartedAt": {
      "type": "string",
      "description": "StartedAt is when the operation started, in \"2023-01-01T12:00:00Z\" format.",
      "format": "date-time",
      "x-confighub-where": {
        "dataType": "time"
      },
      "x-go-type-skip-optional-pointer": true
    },
    "Status": {
      "allOf": [
        {
          "$ref": "#/$defs/ActionStatusType"
        }
      ],
      "description": "Status is the state of the operation the event reports: None, Pending, Submitted, Progressing, Completed, Failed, Canceled, or Aborted.",
      "x-confighub-where": {
        "dataType": "string"
      }
    },
    "TerminatedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "TerminatedAt is when the operation ended, in \"2023-01-01T12:00:00Z\" format. It is absent for an operation that had not ended when the event was recorded.",
      "format": "date-time",
      "x-confighub-where": {
        "dataType": "time"
      },
      "x-go-type-skip-optional-pointer": true
    },
    "UnitEventID": {
      "type": "string",
      "description": "UnitEventID is the unique identifier for this UnitEvent.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "UnitEventNum": {
      "type": "integer",
      "description": "UnitEventNum is the sequence number of this UnitEvent among the Unit's UnitEvents.",
      "format": "int64",
      "x-confighub-where": {
        "dataType": "int"
      },
      "x-go-type-skip-optional-pointer": true
    },
    "UnitID": {
      "type": "string",
      "description": "Unique identifier for a Unit.",
      "format": "uuid",
      "x-confighub-where": {
        "dataType": "uuid",
        "references": "Unit"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "UnitSlug": {
      "type": "string",
      "description": "Slug of the Unit this entity belongs to. (readonly)",
      "readOnly": true,
      "x-go-type-skip-optional-pointer": true
    },
    "UpdatedAt": {
      "type": "string",
      "description": "The timestamp when the entity was last updated in \"2023-01-01T12:00:00Z\" format.",
      "format": "date-time",
      "readOnly": true,
      "x-confighub-where": {
        "dataType": "time"
      },
      "x-go-type-skip-optional-pointer": true,
      "x-omitzero": true
    },
    "Version": {
      "type": "integer",
      "description": "An entity-specific sequence number used for optimistic concurrency control. The value read must be sent in calls to Update.",
      "format": "int64",
      "readOnly": false,
      "x-go-type-skip-optional-pointer": true
    }
  },
  "$defs": {
    "ActionResultType": {
      "enum": [
        "None",
        "FunctionInvocationCompleted",
        "FunctionInvocationFailed"
      ],
      "type": "string"
    },
    "ActionStatusType": {
      "enum": [
        "None",
        "Pending",
        "Submitted",
        "Progressing",
        "Completed",
        "Failed",
        "Canceled",
        "Aborted"
      ],
      "type": "string"
    },
    "ActionType": {
      "enum": [
        "N/A",
        "Cancel",
        "InvokeFunctions",
        "ListFunctions",
        "Apply"
      ],
      "type": "string"
    }
  }
}