{
  "components": {
    "schemas": {
      "AddAnnotationRequest": {
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "value"
        ],
        "type": "object"
      },
      "Agent": {
        "description": "Represents an agent in the database.",
        "properties": {
          "cluster_name": {
            "description": "Name of the cluster the agent belongs to.",
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the agent was created.",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp for soft deletion, if applicable.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the agent.",
            "format": "uuid",
            "type": "string"
          },
          "last_heartbeat": {
            "description": "Timestamp of the last heartbeat received from the agent.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "name": {
            "description": "Name of the agent.",
            "type": "string"
          },
          "status": {
            "description": "Current status of the agent.",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the agent was last updated.",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "name",
          "cluster_name",
          "status"
        ],
        "type": "object"
      },
      "AgentAnnotation": {
        "description": "Represents an agent annotation in the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent this annotation belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the annotation.",
            "format": "uuid",
            "type": "string"
          },
          "key": {
            "description": "Key of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          },
          "value": {
            "description": "Value of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent_id",
          "key",
          "value"
        ],
        "type": "object"
      },
      "AgentEvent": {
        "description": "Represents an agent event in the database.",
        "example": {
          "agent_id": "123e4567-e89b-12d3-a456-426614174001",
          "created_at": "2023-01-01T00:00:00Z",
          "deleted_at": null,
          "deployment_object_id": "123e4567-e89b-12d3-a456-426614174002",
          "event_type": "DEPLOYMENT",
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "message": "Deployment completed successfully",
          "status": "SUCCESS",
          "updated_at": "2023-01-01T00:00:00Z"
        },
        "properties": {
          "agent_id": {
            "description": "ID of the agent associated with this event.",
            "example": "123e4567-e89b-12d3-a456-426614174001",
            "format": "uuid",
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the event was created.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp for soft deletion, if applicable.",
            "example": "null",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "deployment_object_id": {
            "description": "ID of the deployment object associated with this event.",
            "example": "123e4567-e89b-12d3-a456-426614174002",
            "format": "uuid",
            "type": "string"
          },
          "event_type": {
            "description": "Type of the event.",
            "example": "DEPLOYMENT",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the event.",
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "message": {
            "description": "Optional message providing additional details about the event.",
            "example": "Deployment completed successfully",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "description": "Status of the event (e.g., \"SUCCESS\", \"FAILURE\", \"IN_PROGRESS\", \"PENDING\").",
            "example": "SUCCESS",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the event was last updated.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "agent_id",
          "deployment_object_id",
          "event_type",
          "status"
        ],
        "type": "object"
      },
      "AgentLabel": {
        "description": "Represents an agent label in the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent this label is associated with.",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the agent label.",
            "format": "uuid",
            "type": "string"
          },
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent_id",
          "label"
        ],
        "type": "object"
      },
      "AgentTarget": {
        "description": "Represents an agent target in the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent associated with this target.",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the agent target.",
            "format": "uuid",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack associated with this target.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent_id",
          "stack_id"
        ],
        "type": "object"
      },
      "AuditLog": {
        "description": "An audit log record from the database.",
        "properties": {
          "action": {
            "description": "The action performed (e.g., \"agent.created\", \"auth.failed\").",
            "type": "string"
          },
          "actor_id": {
            "description": "ID of the actor (NULL for system or unauthenticated).",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "actor_type": {
            "description": "Type of actor: admin, agent, generator, system.",
            "type": "string"
          },
          "created_at": {
            "description": "When the record was created.",
            "format": "date-time",
            "type": "string"
          },
          "details": {
            "description": "Additional structured details."
          },
          "id": {
            "description": "Unique identifier for the log entry.",
            "format": "uuid",
            "type": "string"
          },
          "ip_address": {
            "description": "Client IP address.",
            "nullable": true,
            "type": "string"
          },
          "resource_id": {
            "description": "ID of the affected resource (NULL if not applicable).",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "resource_type": {
            "description": "Type of resource affected.",
            "type": "string"
          },
          "timestamp": {
            "description": "When the event occurred.",
            "format": "date-time",
            "type": "string"
          },
          "user_agent": {
            "description": "Client user agent string.",
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "id",
          "timestamp",
          "actor_type",
          "action",
          "resource_type",
          "created_at"
        ],
        "type": "object"
      },
      "AuditLogListResponse": {
        "description": "Response structure for audit log list operations.",
        "properties": {
          "count": {
            "description": "Number of entries returned.",
            "minimum": 0,
            "type": "integer"
          },
          "limit": {
            "description": "Limit used for this query.",
            "format": "int64",
            "type": "integer"
          },
          "logs": {
            "description": "The audit log entries.",
            "items": {
              "$ref": "#/components/schemas/AuditLog"
            },
            "type": "array"
          },
          "offset": {
            "description": "Offset used for this query.",
            "format": "int64",
            "type": "integer"
          },
          "total": {
            "description": "Total count of matching entries (for pagination).",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "logs",
          "total",
          "count",
          "limit",
          "offset"
        ],
        "type": "object"
      },
      "AuthResponse": {
        "description": "Represents the response structure for authentication information.",
        "properties": {
          "admin": {
            "description": "Indicates if the authenticated entity is an admin.",
            "type": "boolean"
          },
          "agent": {
            "description": "The string representation of the agent's UUID, if applicable.",
            "nullable": true,
            "type": "string"
          },
          "generator": {
            "description": "The string representation of the generator's UUID, if applicable.",
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "admin"
        ],
        "type": "object"
      },
      "ClaimWorkOrderRequest": {
        "properties": {
          "agent_id": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "agent_id"
        ],
        "type": "object"
      },
      "CompleteWorkOrderRequest": {
        "properties": {
          "message": {
            "nullable": true,
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "success": {
            "type": "boolean"
          }
        },
        "required": [
          "success"
        ],
        "type": "object"
      },
      "ConfigChangeInfo": {
        "description": "Information about a single configuration change.",
        "properties": {
          "key": {
            "description": "The configuration key that changed.",
            "type": "string"
          },
          "new_value": {
            "description": "The new value (as a string representation).",
            "type": "string"
          },
          "old_value": {
            "description": "The previous value (as a string representation).",
            "type": "string"
          }
        },
        "required": [
          "key",
          "old_value",
          "new_value"
        ],
        "type": "object"
      },
      "ConfigReloadResponse": {
        "description": "Response structure for configuration reload operations.",
        "properties": {
          "changes": {
            "description": "List of configuration changes detected during reload.",
            "items": {
              "$ref": "#/components/schemas/ConfigChangeInfo"
            },
            "type": "array"
          },
          "message": {
            "description": "Optional message providing additional context.",
            "nullable": true,
            "type": "string"
          },
          "reloaded_at": {
            "description": "Timestamp when the configuration was reloaded.",
            "format": "date-time",
            "type": "string"
          },
          "success": {
            "description": "Indicates whether the reload was successful.",
            "type": "boolean"
          }
        },
        "required": [
          "reloaded_at",
          "changes",
          "success"
        ],
        "type": "object"
      },
      "CreateDiagnosticRequest": {
        "description": "Request body for creating a diagnostic request.",
        "properties": {
          "agent_id": {
            "description": "The agent that should handle this request.",
            "format": "uuid",
            "type": "string"
          },
          "requested_by": {
            "description": "Who is requesting the diagnostics (optional).",
            "nullable": true,
            "type": "string"
          },
          "retention_minutes": {
            "description": "How long the request should be retained in minutes (default 60, max 1440).",
            "format": "int64",
            "nullable": true,
            "type": "integer"
          }
        },
        "required": [
          "agent_id"
        ],
        "type": "object"
      },
      "CreateGeneratorResponse": {
        "description": "Response for a successful generator creation or PAK rotation.",
        "properties": {
          "generator": {
            "$ref": "#/components/schemas/Generator",
            "description": "The created generator."
          },
          "pak": {
            "description": "The Pre-Authentication Key for the generator.",
            "type": "string"
          }
        },
        "required": [
          "generator",
          "pak"
        ],
        "type": "object"
      },
      "CreateTemplateRequest": {
        "properties": {
          "description": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "parameters_schema": {
            "type": "string"
          },
          "template_content": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "template_content",
          "parameters_schema"
        ],
        "type": "object"
      },
      "CreateWebhookRequest": {
        "properties": {
          "auth_header": {
            "nullable": true,
            "type": "string"
          },
          "event_types": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "filters": {
            "$ref": "#/components/schemas/WebhookFilters"
          },
          "max_retries": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "target_labels": {
            "items": {
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "timeout_seconds": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "url": {
            "type": "string"
          },
          "validate": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "url",
          "event_types"
        ],
        "type": "object"
      },
      "CreateWorkOrderRequest": {
        "properties": {
          "backoff_seconds": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "claim_timeout_seconds": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "max_retries": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "target_agent_ids": {
            "items": {
              "format": "uuid",
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "targeting": {
            "$ref": "#/components/schemas/WorkOrderTargeting"
          },
          "work_type": {
            "type": "string"
          },
          "yaml_content": {
            "type": "string"
          }
        },
        "required": [
          "work_type",
          "yaml_content"
        ],
        "type": "object"
      },
      "DeliveryResultRequest": {
        "properties": {
          "duration_ms": {
            "format": "int64",
            "nullable": true,
            "type": "integer"
          },
          "error": {
            "nullable": true,
            "type": "string"
          },
          "status_code": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "success": {
            "type": "boolean"
          }
        },
        "required": [
          "success"
        ],
        "type": "object"
      },
      "DeploymentHealth": {
        "description": "Represents a deployment health record in the database.",
        "example": {
          "agent_id": "123e4567-e89b-12d3-a456-426614174001",
          "checked_at": "2023-01-01T00:00:00Z",
          "created_at": "2023-01-01T00:00:00Z",
          "deployment_object_id": "123e4567-e89b-12d3-a456-426614174002",
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "status": "healthy",
          "summary": "{\"pods_ready\": 3, \"pods_total\": 3, \"conditions\": []}",
          "updated_at": "2023-01-01T00:00:00Z"
        },
        "properties": {
          "agent_id": {
            "description": "ID of the agent that reported this health status.",
            "example": "123e4567-e89b-12d3-a456-426614174001",
            "format": "uuid",
            "type": "string"
          },
          "checked_at": {
            "description": "Timestamp when the agent last checked health.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the record was created.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "deployment_object_id": {
            "description": "ID of the deployment object this health status applies to.",
            "example": "123e4567-e89b-12d3-a456-426614174002",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the health record.",
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "description": "Health status: healthy, degraded, failing, or unknown.",
            "example": "healthy",
            "type": "string"
          },
          "summary": {
            "description": "JSON-encoded summary with pod counts, conditions, and resource details.",
            "example": "{\"pods_ready\": 3, \"pods_total\": 3, \"conditions\": []}",
            "nullable": true,
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the record was last updated.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent_id",
          "deployment_object_id",
          "status",
          "checked_at",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "DeploymentHealthResponse": {
        "description": "Response for deployment object health query.",
        "properties": {
          "deployment_object_id": {
            "description": "The deployment object ID.",
            "format": "uuid",
            "type": "string"
          },
          "health_records": {
            "description": "List of health records from different agents.",
            "items": {
              "$ref": "#/components/schemas/DeploymentHealth"
            },
            "type": "array"
          },
          "overall_status": {
            "description": "Overall status (worst status across all agents).",
            "type": "string"
          }
        },
        "required": [
          "deployment_object_id",
          "health_records",
          "overall_status"
        ],
        "type": "object"
      },
      "DeploymentObject": {
        "description": "Represents a deployment object in the database.",
        "properties": {
          "created_at": {
            "description": "Timestamp when the deployment object was created.",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp for soft deletion, if applicable.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the deployment object.",
            "format": "uuid",
            "type": "string"
          },
          "is_deletion_marker": {
            "description": "Indicates if this object marks a deletion.",
            "type": "boolean"
          },
          "sequence_id": {
            "description": "Auto-incrementing sequence number for ordering.",
            "format": "int64",
            "type": "integer"
          },
          "stack_id": {
            "description": "ID of the stack this deployment object belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "submitted_at": {
            "description": "Timestamp when the deployment was submitted.",
            "format": "date-time",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the deployment object was last updated.",
            "format": "date-time",
            "type": "string"
          },
          "yaml_checksum": {
            "description": "SHA-256 checksum of the YAML content.",
            "type": "string"
          },
          "yaml_content": {
            "description": "YAML content of the deployment.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "sequence_id",
          "stack_id",
          "yaml_content",
          "yaml_checksum",
          "submitted_at",
          "is_deletion_marker"
        ],
        "type": "object"
      },
      "DeploymentObjectHealthSummary": {
        "description": "Summary of health for a deployment object within a stack.",
        "properties": {
          "degraded_agents": {
            "description": "Number of agents reporting degraded.",
            "minimum": 0,
            "type": "integer"
          },
          "failing_agents": {
            "description": "Number of agents reporting failing.",
            "minimum": 0,
            "type": "integer"
          },
          "healthy_agents": {
            "description": "Number of agents reporting healthy.",
            "minimum": 0,
            "type": "integer"
          },
          "id": {
            "description": "The deployment object ID.",
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "description": "Overall status for this deployment object.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "healthy_agents",
          "degraded_agents",
          "failing_agents"
        ],
        "type": "object"
      },
      "DeploymentObjectHealthUpdate": {
        "description": "Health update for a single deployment object.",
        "properties": {
          "checked_at": {
            "description": "When the health was checked.",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "The deployment object ID.",
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "description": "Health status: healthy, degraded, failing, or unknown.",
            "type": "string"
          },
          "summary": {
            "$ref": "#/components/schemas/HealthSummary",
            "description": "Structured health summary."
          }
        },
        "required": [
          "id",
          "status",
          "checked_at"
        ],
        "type": "object"
      },
      "DiagnosticRequest": {
        "description": "A diagnostic request record from the database.",
        "properties": {
          "agent_id": {
            "description": "The agent that should handle this request.",
            "format": "uuid",
            "type": "string"
          },
          "claimed_at": {
            "description": "When the agent claimed the request.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "completed_at": {
            "description": "When the request was completed.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "created_at": {
            "description": "When the request was created.",
            "format": "date-time",
            "type": "string"
          },
          "deployment_object_id": {
            "description": "The deployment object to gather diagnostics for.",
            "format": "uuid",
            "type": "string"
          },
          "expires_at": {
            "description": "When the request expires and should be cleaned up.",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the diagnostic request.",
            "format": "uuid",
            "type": "string"
          },
          "requested_by": {
            "description": "Who requested the diagnostics (e.g., operator username).",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "description": "Status: pending, claimed, completed, failed, expired.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "agent_id",
          "deployment_object_id",
          "status",
          "created_at",
          "expires_at"
        ],
        "type": "object"
      },
      "DiagnosticResponse": {
        "description": "Response containing a diagnostic request with optional result.",
        "properties": {
          "request": {
            "$ref": "#/components/schemas/DiagnosticRequest",
            "description": "The diagnostic request."
          },
          "result": {
            "$ref": "#/components/schemas/DiagnosticResult",
            "description": "The diagnostic result, if completed."
          }
        },
        "required": [
          "request"
        ],
        "type": "object"
      },
      "DiagnosticResult": {
        "description": "A diagnostic result record from the database.",
        "properties": {
          "collected_at": {
            "description": "When the diagnostics were collected by the agent.",
            "format": "date-time",
            "type": "string"
          },
          "created_at": {
            "description": "When the result was created in the database.",
            "format": "date-time",
            "type": "string"
          },
          "events": {
            "description": "JSON-encoded Kubernetes events.",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the diagnostic result.",
            "format": "uuid",
            "type": "string"
          },
          "log_tails": {
            "description": "JSON-encoded log tails (optional).",
            "nullable": true,
            "type": "string"
          },
          "pod_statuses": {
            "description": "JSON-encoded pod statuses.",
            "type": "string"
          },
          "request_id": {
            "description": "The diagnostic request this result belongs to.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "request_id",
          "pod_statuses",
          "events",
          "collected_at",
          "created_at"
        ],
        "type": "object"
      },
      "ErrorResponse": {
        "description": "Wire format for every 4xx/5xx response body in the v1 API.",
        "properties": {
          "code": {
            "description": "Stable, machine-readable error code (e.g. `agent_not_found`).",
            "type": "string"
          },
          "details": {
            "additionalProperties": {},
            "description": "Optional structured context. Keys and value shapes are documented per\nerror code when present.",
            "nullable": true,
            "type": "object"
          },
          "message": {
            "description": "Human-readable message; not stable and may change between versions.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "Generator": {
        "description": "Represents a generator in the Brokkr system.",
        "properties": {
          "created_at": {
            "description": "Timestamp of when the generator was created.",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp of when the generator was deleted, if applicable.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "description": {
            "description": "Optional description of the generator.",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the generator.",
            "format": "uuid",
            "type": "string"
          },
          "is_active": {
            "description": "Indicates whether the generator is currently active.",
            "type": "boolean"
          },
          "last_active_at": {
            "description": "Timestamp of when the generator was last active.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "name": {
            "description": "Name of the generator.",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp of when the generator was last updated.",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "name",
          "is_active"
        ],
        "type": "object"
      },
      "HealthStatusUpdate": {
        "description": "Request body for updating health status from an agent.",
        "properties": {
          "deployment_objects": {
            "description": "List of deployment object health updates.",
            "items": {
              "$ref": "#/components/schemas/DeploymentObjectHealthUpdate"
            },
            "type": "array"
          }
        },
        "required": [
          "deployment_objects"
        ],
        "type": "object"
      },
      "HealthSummary": {
        "description": "Structured health summary for serialization/deserialization.",
        "properties": {
          "conditions": {
            "description": "List of detected problematic conditions (e.g., ImagePullBackOff).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "pods_ready": {
            "description": "Number of pods in ready state.",
            "format": "int32",
            "type": "integer"
          },
          "pods_total": {
            "description": "Total number of pods.",
            "format": "int32",
            "type": "integer"
          },
          "resources": {
            "description": "Optional detailed resource status.",
            "items": {
              "$ref": "#/components/schemas/ResourceHealth"
            },
            "nullable": true,
            "type": "array"
          }
        },
        "required": [
          "pods_ready",
          "pods_total",
          "conditions"
        ],
        "type": "object"
      },
      "ListDeliveriesQuery": {
        "properties": {
          "limit": {
            "format": "int64",
            "nullable": true,
            "type": "integer"
          },
          "offset": {
            "format": "int64",
            "nullable": true,
            "type": "integer"
          },
          "status": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "NewAgent": {
        "description": "Represents a new agent to be inserted into the database.",
        "properties": {
          "cluster_name": {
            "description": "Name of the cluster the agent belongs to.",
            "type": "string"
          },
          "name": {
            "description": "Name of the agent.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "cluster_name"
        ],
        "type": "object"
      },
      "NewAgentAnnotation": {
        "description": "Represents a new agent annotation to be inserted into the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent this annotation belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "key": {
            "description": "Key of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          },
          "value": {
            "description": "Value of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "key",
          "value"
        ],
        "type": "object"
      },
      "NewAgentEvent": {
        "description": "Represents a new agent event to be inserted into the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent associated with this event.",
            "format": "uuid",
            "type": "string"
          },
          "deployment_object_id": {
            "description": "ID of the deployment object associated with this event.",
            "format": "uuid",
            "type": "string"
          },
          "event_type": {
            "description": "Type of the event.",
            "type": "string"
          },
          "message": {
            "description": "Optional message providing additional details about the event.",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "description": "Status of the event (e.g., \"SUCCESS\", \"FAILURE\").",
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "deployment_object_id",
          "event_type",
          "status"
        ],
        "type": "object"
      },
      "NewAgentLabel": {
        "description": "Represents a new agent label to be inserted into the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent this label is associated with.",
            "format": "uuid",
            "type": "string"
          },
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "label"
        ],
        "type": "object"
      },
      "NewAgentTarget": {
        "description": "Represents a new agent target to be inserted into the database.",
        "properties": {
          "agent_id": {
            "description": "ID of the agent to associate with a stack.",
            "format": "uuid",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack to associate with an agent.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "agent_id",
          "stack_id"
        ],
        "type": "object"
      },
      "NewDeploymentObject": {
        "description": "Represents a new deployment object to be inserted into the database.",
        "properties": {
          "is_deletion_marker": {
            "description": "Indicates if this object marks a deletion.",
            "type": "boolean"
          },
          "stack_id": {
            "description": "ID of the stack this deployment object belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "yaml_checksum": {
            "description": "SHA-256 checksum of the YAML content.",
            "type": "string"
          },
          "yaml_content": {
            "description": "YAML content of the deployment.",
            "type": "string"
          }
        },
        "required": [
          "stack_id",
          "yaml_content",
          "yaml_checksum",
          "is_deletion_marker"
        ],
        "type": "object"
      },
      "NewGenerator": {
        "description": "Represents the data required to create a new generator.",
        "properties": {
          "description": {
            "description": "Optional description of the new generator.",
            "nullable": true,
            "type": "string"
          },
          "name": {
            "description": "Name of the new generator.",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "NewStack": {
        "description": "Represents a new stack to be inserted into the database.",
        "properties": {
          "description": {
            "description": "Optional description of the stack.",
            "nullable": true,
            "type": "string"
          },
          "generator_id": {
            "description": "Optional generator ID.",
            "format": "uuid",
            "type": "string"
          },
          "name": {
            "description": "Name of the stack.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "generator_id"
        ],
        "type": "object"
      },
      "NewStackAnnotation": {
        "description": "Represents a new stack annotation to be inserted into the database.",
        "properties": {
          "key": {
            "description": "Key of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack this annotation belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "value": {
            "description": "Value of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "stack_id",
          "key",
          "value"
        ],
        "type": "object"
      },
      "NewStackLabel": {
        "description": "Represents a new stack label to be inserted into the database.",
        "properties": {
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack this label is associated with.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "stack_id",
          "label"
        ],
        "type": "object"
      },
      "NewStackTemplate": {
        "description": "Represents a new stack template to be inserted into the database.",
        "properties": {
          "checksum": {
            "description": "SHA-256 checksum of template_content.",
            "type": "string"
          },
          "description": {
            "description": "Optional description of the template.",
            "nullable": true,
            "type": "string"
          },
          "generator_id": {
            "description": "Generator ID - NULL for system templates (admin-only).",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "name": {
            "description": "Name of the template.",
            "type": "string"
          },
          "parameters_schema": {
            "description": "JSON Schema for parameter validation.",
            "type": "string"
          },
          "template_content": {
            "description": "Tera template content.",
            "type": "string"
          },
          "version": {
            "description": "Version number.",
            "format": "int32",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "version",
          "template_content",
          "parameters_schema",
          "checksum"
        ],
        "type": "object"
      },
      "NewTemplateAnnotation": {
        "description": "Represents a new template annotation to be inserted into the database.",
        "properties": {
          "key": {
            "description": "The annotation key (max 64 characters, no whitespace).",
            "type": "string"
          },
          "template_id": {
            "description": "ID of the template this annotation is associated with.",
            "format": "uuid",
            "type": "string"
          },
          "value": {
            "description": "The annotation value (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "template_id",
          "key",
          "value"
        ],
        "type": "object"
      },
      "NewTemplateLabel": {
        "description": "Represents a new template label to be inserted into the database.",
        "properties": {
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          },
          "template_id": {
            "description": "ID of the template this label is associated with.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "template_id",
          "label"
        ],
        "type": "object"
      },
      "PendingWebhookDelivery": {
        "properties": {
          "attempts": {
            "format": "int32",
            "type": "integer"
          },
          "auth_header": {
            "nullable": true,
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "max_retries": {
            "format": "int32",
            "type": "integer"
          },
          "payload": {
            "type": "string"
          },
          "subscription_id": {
            "format": "uuid",
            "type": "string"
          },
          "timeout_seconds": {
            "format": "int32",
            "type": "integer"
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "subscription_id",
          "event_type",
          "payload",
          "url",
          "timeout_seconds",
          "max_retries",
          "attempts"
        ],
        "type": "object"
      },
      "ResourceHealth": {
        "description": "Health status for an individual Kubernetes resource.",
        "properties": {
          "kind": {
            "description": "Resource kind (e.g., Deployment, StatefulSet).",
            "type": "string"
          },
          "message": {
            "description": "Optional status message.",
            "nullable": true,
            "type": "string"
          },
          "name": {
            "description": "Resource name.",
            "type": "string"
          },
          "namespace": {
            "description": "Resource namespace.",
            "type": "string"
          },
          "ready": {
            "description": "Whether the resource is ready.",
            "type": "boolean"
          }
        },
        "required": [
          "kind",
          "name",
          "namespace",
          "ready"
        ],
        "type": "object"
      },
      "Stack": {
        "description": "Represents a stack in the database.",
        "properties": {
          "created_at": {
            "description": "Timestamp when the stack was created.",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp for soft deletion, if applicable.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "description": {
            "description": "Optional description of the stack.",
            "nullable": true,
            "type": "string"
          },
          "generator_id": {
            "description": "Optional generator ID.",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the stack.",
            "format": "uuid",
            "type": "string"
          },
          "name": {
            "description": "Name of the stack.",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the stack was last updated.",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "name",
          "generator_id"
        ],
        "type": "object"
      },
      "StackAnnotation": {
        "description": "Represents a stack annotation in the database.",
        "properties": {
          "id": {
            "description": "Unique identifier for the annotation.",
            "format": "uuid",
            "type": "string"
          },
          "key": {
            "description": "Key of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack this annotation belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "value": {
            "description": "Value of the annotation (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "stack_id",
          "key",
          "value"
        ],
        "type": "object"
      },
      "StackHealthResponse": {
        "description": "Response for stack health query.",
        "properties": {
          "deployment_objects": {
            "description": "Health per deployment object.",
            "items": {
              "$ref": "#/components/schemas/DeploymentObjectHealthSummary"
            },
            "type": "array"
          },
          "overall_status": {
            "description": "Overall status for the stack.",
            "type": "string"
          },
          "stack_id": {
            "description": "The stack ID.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "stack_id",
          "overall_status",
          "deployment_objects"
        ],
        "type": "object"
      },
      "StackLabel": {
        "description": "Represents a stack label in the database.",
        "properties": {
          "id": {
            "description": "Unique identifier for the stack label.",
            "format": "uuid",
            "type": "string"
          },
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          },
          "stack_id": {
            "description": "ID of the stack this label is associated with.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "stack_id",
          "label"
        ],
        "type": "object"
      },
      "StackTemplate": {
        "description": "Represents a stack template in the database.",
        "properties": {
          "checksum": {
            "description": "SHA-256 checksum of template_content.",
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the template was created.",
            "format": "date-time",
            "type": "string"
          },
          "deleted_at": {
            "description": "Timestamp for soft deletion, if applicable.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "description": {
            "description": "Optional description of the template.",
            "nullable": true,
            "type": "string"
          },
          "generator_id": {
            "description": "Generator ID - NULL for system templates (admin-only).",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the template.",
            "format": "uuid",
            "type": "string"
          },
          "name": {
            "description": "Name of the template.",
            "type": "string"
          },
          "parameters_schema": {
            "description": "JSON Schema for parameter validation.",
            "type": "string"
          },
          "template_content": {
            "description": "Tera template content.",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the template was last updated.",
            "format": "date-time",
            "type": "string"
          },
          "version": {
            "description": "Version number (auto-incremented per name+generator_id).",
            "format": "int32",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "name",
          "version",
          "template_content",
          "parameters_schema",
          "checksum"
        ],
        "type": "object"
      },
      "SubmitDiagnosticResult": {
        "description": "Request body for submitting diagnostic results.",
        "properties": {
          "collected_at": {
            "description": "When the diagnostics were collected.",
            "format": "date-time",
            "type": "string"
          },
          "events": {
            "description": "JSON-encoded Kubernetes events.",
            "type": "string"
          },
          "log_tails": {
            "description": "JSON-encoded log tails (optional).",
            "nullable": true,
            "type": "string"
          },
          "pod_statuses": {
            "description": "JSON-encoded pod statuses.",
            "type": "string"
          }
        },
        "required": [
          "pod_statuses",
          "events",
          "collected_at"
        ],
        "type": "object"
      },
      "TemplateAnnotation": {
        "description": "Represents a template annotation in the database.",
        "properties": {
          "created_at": {
            "description": "Timestamp when the annotation was created.",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the template annotation.",
            "format": "uuid",
            "type": "string"
          },
          "key": {
            "description": "The annotation key (max 64 characters, no whitespace).",
            "type": "string"
          },
          "template_id": {
            "description": "ID of the template this annotation is associated with.",
            "format": "uuid",
            "type": "string"
          },
          "value": {
            "description": "The annotation value (max 64 characters, no whitespace).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "template_id",
          "key",
          "value",
          "created_at"
        ],
        "type": "object"
      },
      "TemplateInstantiationRequest": {
        "properties": {
          "parameters": {},
          "template_id": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "template_id",
          "parameters"
        ],
        "type": "object"
      },
      "TemplateLabel": {
        "description": "Represents a template label in the database.",
        "properties": {
          "created_at": {
            "description": "Timestamp when the label was created.",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the template label.",
            "format": "uuid",
            "type": "string"
          },
          "label": {
            "description": "The label text (max 64 characters, no whitespace).",
            "type": "string"
          },
          "template_id": {
            "description": "ID of the template this label is associated with.",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "template_id",
          "label",
          "created_at"
        ],
        "type": "object"
      },
      "UpdateTemplateRequest": {
        "properties": {
          "description": {
            "nullable": true,
            "type": "string"
          },
          "parameters_schema": {
            "type": "string"
          },
          "template_content": {
            "type": "string"
          }
        },
        "required": [
          "template_content",
          "parameters_schema"
        ],
        "type": "object"
      },
      "UpdateWebhookRequest": {
        "properties": {
          "auth_header": {
            "nullable": true,
            "type": "string"
          },
          "enabled": {
            "nullable": true,
            "type": "boolean"
          },
          "event_types": {
            "items": {
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "filters": {
            "$ref": "#/components/schemas/WebhookFilters"
          },
          "max_retries": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "target_labels": {
            "items": {
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "timeout_seconds": {
            "format": "int32",
            "nullable": true,
            "type": "integer"
          },
          "url": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "WebhookDelivery": {
        "description": "A webhook delivery record from the database.",
        "properties": {
          "acquired_by": {
            "description": "Agent ID that acquired this delivery (NULL = broker).",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "acquired_until": {
            "description": "TTL for the acquisition - release if exceeded.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "attempts": {
            "description": "Number of delivery attempts.",
            "format": "int32",
            "type": "integer"
          },
          "completed_at": {
            "description": "When the delivery completed (success or dead).",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "created_at": {
            "description": "When the delivery was created.",
            "format": "date-time",
            "type": "string"
          },
          "event_id": {
            "description": "The event ID (idempotency key).",
            "format": "uuid",
            "type": "string"
          },
          "event_type": {
            "description": "The event type being delivered.",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the delivery.",
            "format": "uuid",
            "type": "string"
          },
          "last_attempt_at": {
            "description": "When the last delivery attempt was made.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "last_error": {
            "description": "Error message from last failed attempt.",
            "nullable": true,
            "type": "string"
          },
          "next_retry_at": {
            "description": "When to retry after failure.",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "payload": {
            "description": "JSON-encoded event payload.",
            "type": "string"
          },
          "status": {
            "description": "Delivery status: pending, acquired, success, failed, dead.",
            "type": "string"
          },
          "subscription_id": {
            "description": "The subscription this delivery belongs to.",
            "format": "uuid",
            "type": "string"
          },
          "target_labels": {
            "description": "Labels for delivery targeting (copied from subscription).",
            "items": {
              "nullable": true,
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          }
        },
        "required": [
          "id",
          "subscription_id",
          "event_type",
          "event_id",
          "payload",
          "status",
          "attempts",
          "created_at"
        ],
        "type": "object"
      },
      "WebhookFilters": {
        "description": "Filters for webhook subscriptions.",
        "properties": {
          "agent_id": {
            "description": "Filter by specific agent ID.",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "labels": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Filter by labels (all must match).",
            "nullable": true,
            "type": "object"
          },
          "stack_id": {
            "description": "Filter by specific stack ID.",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "WebhookResponse": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "nullable": true,
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "event_types": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "filters": {
            "$ref": "#/components/schemas/WebhookFilters"
          },
          "has_auth_header": {
            "type": "boolean"
          },
          "has_url": {
            "type": "boolean"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "max_retries": {
            "format": "int32",
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "target_labels": {
            "items": {
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "timeout_seconds": {
            "format": "int32",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "has_url",
          "has_auth_header",
          "event_types",
          "enabled",
          "max_retries",
          "timeout_seconds",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "WebhookSubscription": {
        "description": "A webhook subscription record from the database.",
        "properties": {
          "created_at": {
            "description": "When the subscription was created.",
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "description": "Who created the subscription.",
            "nullable": true,
            "type": "string"
          },
          "enabled": {
            "description": "Whether the subscription is active.",
            "type": "boolean"
          },
          "event_types": {
            "description": "Event types to subscribe to (supports wildcards like \"deployment.*\").",
            "items": {
              "nullable": true,
              "type": "string"
            },
            "type": "array"
          },
          "filters": {
            "description": "JSON-encoded filters.",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the subscription.",
            "format": "uuid",
            "type": "string"
          },
          "max_retries": {
            "description": "Maximum delivery retry attempts.",
            "format": "int32",
            "type": "integer"
          },
          "name": {
            "description": "Human-readable name for the subscription.",
            "type": "string"
          },
          "target_labels": {
            "description": "Labels for delivery targeting (NULL = broker delivers).",
            "items": {
              "nullable": true,
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "timeout_seconds": {
            "description": "HTTP request timeout in seconds.",
            "format": "int32",
            "type": "integer"
          },
          "updated_at": {
            "description": "When the subscription was last updated.",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "event_types",
          "enabled",
          "max_retries",
          "timeout_seconds",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "WorkOrder": {
        "description": "Represents an active work order in the queue.",
        "example": {
          "backoff_seconds": 60,
          "claim_timeout_seconds": 3600,
          "claimed_at": null,
          "claimed_by": null,
          "created_at": "2023-01-01T00:00:00Z",
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "last_error": null,
          "last_error_at": null,
          "max_retries": 3,
          "next_retry_after": null,
          "retry_count": 0,
          "status": "PENDING",
          "updated_at": "2023-01-01T00:00:00Z",
          "work_type": "build",
          "yaml_content": "apiVersion: shipwright.io/v1beta1\nkind: Build\n..."
        },
        "properties": {
          "backoff_seconds": {
            "description": "Base backoff seconds for exponential retry calculation.",
            "example": 60,
            "format": "int32",
            "type": "integer"
          },
          "claim_timeout_seconds": {
            "description": "Seconds before a claimed work order is considered stale.",
            "example": 3600,
            "format": "int32",
            "type": "integer"
          },
          "claimed_at": {
            "description": "Timestamp when the work order was claimed.",
            "example": "null",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "claimed_by": {
            "description": "ID of the agent that claimed this work order (if any).",
            "example": "null",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the work order was created.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Unique identifier for the work order.",
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "last_error": {
            "description": "Most recent error message from failed execution attempt.",
            "example": "null",
            "nullable": true,
            "type": "string"
          },
          "last_error_at": {
            "description": "Timestamp of the most recent failure.",
            "example": "null",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "max_retries": {
            "description": "Maximum number of retry attempts.",
            "example": 3,
            "format": "int32",
            "type": "integer"
          },
          "next_retry_after": {
            "description": "Timestamp when RETRY_PENDING work order becomes PENDING again.",
            "example": "null",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "retry_count": {
            "description": "Current retry count.",
            "example": 0,
            "format": "int32",
            "type": "integer"
          },
          "status": {
            "description": "Queue status: PENDING, CLAIMED, or RETRY_PENDING.",
            "example": "PENDING",
            "type": "string"
          },
          "updated_at": {
            "description": "Timestamp when the work order was last updated.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "work_type": {
            "description": "Type of work (e.g., \"build\", \"test\", \"backup\").",
            "example": "build",
            "type": "string"
          },
          "yaml_content": {
            "description": "Multi-document YAML content (e.g., Build + WorkOrder definitions).",
            "example": "apiVersion: shipwright.io/v1beta1\nkind: Build\n...",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created_at",
          "updated_at",
          "work_type",
          "yaml_content",
          "status",
          "claim_timeout_seconds",
          "max_retries",
          "retry_count",
          "backoff_seconds"
        ],
        "type": "object"
      },
      "WorkOrderLog": {
        "description": "Represents a completed work order in the audit log.",
        "example": {
          "claimed_at": "2023-01-01T00:01:00Z",
          "claimed_by": "123e4567-e89b-12d3-a456-426614174001",
          "completed_at": "2023-01-01T00:05:00Z",
          "created_at": "2023-01-01T00:00:00Z",
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "result_message": "sha256:abc123...",
          "retries_attempted": 0,
          "success": true,
          "work_type": "build",
          "yaml_content": "apiVersion: shipwright.io/v1beta1\nkind: Build\n..."
        },
        "properties": {
          "claimed_at": {
            "description": "Timestamp when the work order was claimed.",
            "example": "2023-01-01T00:01:00Z",
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "claimed_by": {
            "description": "ID of the agent that executed this work order.",
            "example": "123e4567-e89b-12d3-a456-426614174001",
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "completed_at": {
            "description": "Timestamp when the work order completed.",
            "example": "2023-01-01T00:05:00Z",
            "format": "date-time",
            "type": "string"
          },
          "created_at": {
            "description": "Timestamp when the work order was created.",
            "example": "2023-01-01T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Original work order ID.",
            "example": "123e4567-e89b-12d3-a456-426614174000",
            "format": "uuid",
            "type": "string"
          },
          "result_message": {
            "description": "Result message (image digest on success, error details on failure).",
            "example": "sha256:abc123...",
            "nullable": true,
            "type": "string"
          },
          "retries_attempted": {
            "description": "Number of retry attempts before completion.",
            "example": 0,
            "format": "int32",
            "type": "integer"
          },
          "success": {
            "description": "Whether the work completed successfully.",
            "example": true,
            "type": "boolean"
          },
          "work_type": {
            "description": "Type of work.",
            "example": "build",
            "type": "string"
          },
          "yaml_content": {
            "description": "Original YAML content for debugging/reconstruction.",
            "example": "apiVersion: shipwright.io/v1beta1\nkind: Build\n...",
            "type": "string"
          }
        },
        "required": [
          "id",
          "work_type",
          "created_at",
          "completed_at",
          "success",
          "retries_attempted",
          "yaml_content"
        ],
        "type": "object"
      },
      "WorkOrderTargeting": {
        "properties": {
          "agent_ids": {
            "items": {
              "format": "uuid",
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "annotations": {
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true,
            "type": "object"
          },
          "labels": {
            "items": {
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "admin_pak": {
        "in": "header",
        "name": "Authorization",
        "type": "apiKey"
      },
      "agent_pak": {
        "in": "header",
        "name": "Authorization",
        "type": "apiKey"
      },
      "generator_pak": {
        "in": "header",
        "name": "Authorization",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "description": "",
    "license": {
      "name": ""
    },
    "title": "brokkr-broker",
    "version": "0.0.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/admin/audit-logs": {
      "get": {
        "description": "Returns audit log entries matching the specified filters, ordered by\ntimestamp descending (most recent first).\n\n# Authentication\n\nRequires admin PAK authentication.\n\n# Query Parameters\n\n- `actor_type`: Filter by actor type (admin, agent, generator, system).\n- `actor_id`: Filter by actor UUID.\n- `action`: Filter by action (exact match or prefix with *).\n- `resource_type`: Filter by resource type.\n- `resource_id`: Filter by resource UUID.\n- `from`: Filter by start time (inclusive).\n- `to`: Filter by end time (exclusive).\n- `limit`: Maximum results (default 100, max 1000).\n- `offset`: Number of results to skip.\n\n# Returns\n\n- `200 OK`: List of audit logs with pagination info.\n- `401 UNAUTHORIZED`: Missing or invalid authentication.\n- `403 FORBIDDEN`: Authenticated but not an admin.\n- `500 INTERNAL_SERVER_ERROR`: Database error.",
        "operationId": "list_audit_logs",
        "parameters": [
          {
            "description": "Filter by actor type (admin, agent, generator, system).",
            "example": "admin",
            "in": "query",
            "name": "actor_type",
            "required": false,
            "schema": {
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by actor ID.",
            "in": "query",
            "name": "actor_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by action (exact match or prefix with *).",
            "example": "agent.*",
            "in": "query",
            "name": "action",
            "required": false,
            "schema": {
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by resource type.",
            "example": "agent",
            "in": "query",
            "name": "resource_type",
            "required": false,
            "schema": {
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by resource ID.",
            "in": "query",
            "name": "resource_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by start time (inclusive, ISO 8601).",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "format": "date-time",
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Filter by end time (exclusive, ISO 8601).",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "format": "date-time",
              "nullable": true,
              "type": "string"
            }
          },
          {
            "description": "Maximum number of results (default 100, max 1000).",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int64",
              "nullable": true,
              "type": "integer"
            }
          },
          {
            "description": "Number of results to skip.",
            "example": 0,
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "format": "int64",
              "nullable": true,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditLogListResponse"
                }
              }
            },
            "description": "Audit logs retrieved successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Missing or invalid authentication"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not authorized (admin only)"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Database error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "summary": "Lists audit logs with optional filtering and pagination.",
        "tags": [
          "Admin"
        ]
      }
    },
    "/admin/config/reload": {
      "post": {
        "description": "This endpoint triggers a hot-reload of configurable settings without\nrequiring a broker restart. Only settings marked as \"dynamic\" can be\nreloaded; static settings (like database URL) require a restart.\n\n# Authentication\n\nRequires admin PAK authentication.\n\n# Returns\n\n- `200 OK`: Configuration reloaded successfully with list of changes.\n- `401 UNAUTHORIZED`: Missing or invalid authentication.\n- `403 FORBIDDEN`: Authenticated but not an admin.\n- `500 INTERNAL_SERVER_ERROR`: Failed to reload configuration.",
        "operationId": "reload_config",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfigReloadResponse"
                }
              }
            },
            "description": "Configuration reloaded successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Missing or invalid authentication"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not authorized (admin only)"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Failed to reload configuration"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "summary": "Reloads the broker configuration from disk.",
        "tags": [
          "Admin"
        ]
      }
    },
    "/agent-events": {
      "get": {
        "operationId": "list_agent_events",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentEvent"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List all agent events"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "agent-events"
        ]
      }
    },
    "/agent-events/{id}": {
      "get": {
        "operationId": "get_agent_event",
        "parameters": [
          {
            "description": "Agent event id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentEvent"
                }
              }
            },
            "description": "Get agent event by id"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent event not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "agent-events"
        ]
      }
    },
    "/agents": {
      "get": {
        "operationId": "list_agents",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Agent"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved agents"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      },
      "post": {
        "operationId": "create_agent",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {}
              }
            },
            "description": "Successfully created agent"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/": {
      "get": {
        "operationId": "search_agent",
        "parameters": [
          {
            "description": "Name of the agent to search for",
            "in": "query",
            "name": "name",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Name of the cluster to search in",
            "in": "query",
            "name": "cluster_name",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            },
            "description": "Successfully found agent"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{agent_id}/webhooks/pending": {
      "get": {
        "operationId": "get_pending_agent_webhooks",
        "parameters": [
          {
            "description": "Agent ID",
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PendingWebhookDelivery"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Pending webhook deliveries for this agent"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Agent access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/agents/{agent_id}/work-orders/pending": {
      "get": {
        "operationId": "list_pending_for_agent",
        "parameters": [
          {
            "description": "Agent ID",
            "in": "path",
            "name": "agent_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Filter by work type",
            "in": "query",
            "name": "work_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WorkOrder"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of pending work orders"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/agents/{id}": {
      "delete": {
        "operationId": "delete_agent",
        "parameters": [
          {
            "description": "ID of the agent to delete",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successfully deleted agent"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      },
      "get": {
        "operationId": "get_agent",
        "parameters": [
          {
            "description": "ID of the agent to retrieve",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            },
            "description": "Successfully retrieved agent"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      },
      "put": {
        "operationId": "update_agent",
        "parameters": [
          {
            "description": "ID of the agent to update",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Agent"
                }
              }
            },
            "description": "Successfully updated agent"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{id}/annotations": {
      "get": {
        "operationId": "agents_list_annotations",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentAnnotation"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved agent annotations"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-annotations"
        ]
      },
      "post": {
        "operationId": "agents_add_annotation",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgentAnnotation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAnnotation"
                }
              }
            },
            "description": "Successfully added agent annotation"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agent-annotations"
        ]
      }
    },
    "/agents/{id}/annotations/{key}": {
      "delete": {
        "operationId": "agents_remove_annotation",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Annotation key to remove",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successfully removed agent annotation"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Annotation not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agent-annotations"
        ]
      }
    },
    "/agents/{id}/diagnostics/pending": {
      "get": {
        "operationId": "get_pending_diagnostics",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/DiagnosticRequest"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved pending diagnostics"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "diagnostics"
        ]
      }
    },
    "/agents/{id}/events": {
      "get": {
        "operationId": "list_events",
        "parameters": [
          {
            "description": "ID of the agent to list events for",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentEvent"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved agent events"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-events"
        ]
      },
      "post": {
        "operationId": "create_event",
        "parameters": [
          {
            "description": "ID of the agent to create an event for",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgentEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentEvent"
                }
              }
            },
            "description": "Successfully created agent event"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-events"
        ]
      }
    },
    "/agents/{id}/health-status": {
      "patch": {
        "description": "# Authorization\nRequires matching agent ID.",
        "operationId": "update_health_status",
        "parameters": [
          {
            "description": "ID of the agent reporting health",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HealthStatusUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successfully updated health status"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "summary": "Updates health status for deployment objects from an agent.",
        "tags": [
          "health"
        ]
      }
    },
    "/agents/{id}/heartbeat": {
      "post": {
        "operationId": "record_heartbeat",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successfully recorded agent heartbeat"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{id}/labels": {
      "get": {
        "operationId": "agents_list_labels",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentLabel"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved agent labels"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-labels"
        ]
      },
      "post": {
        "operationId": "agents_add_label",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgentLabel"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentLabel"
                }
              }
            },
            "description": "Successfully added agent label"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agent-labels"
        ]
      }
    },
    "/agents/{id}/labels/{label}": {
      "delete": {
        "operationId": "agents_remove_label",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "The label to remove",
            "in": "path",
            "name": "label",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successfully removed agent label"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Label not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "agent-labels"
        ]
      }
    },
    "/agents/{id}/rotate-pak": {
      "post": {
        "operationId": "rotate_agent_pak",
        "parameters": [
          {
            "description": "Agent id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {}
              }
            },
            "description": "Successfully rotated agent PAK"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{id}/stacks": {
      "get": {
        "operationId": "get_associated_stacks",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Stack"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved associated stacks"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{id}/target-state": {
      "get": {
        "operationId": "get_target_state",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Mode of operation: 'incremental' (default) or 'full'",
            "in": "query",
            "name": "mode",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/DeploymentObject"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved target state"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agents"
        ]
      }
    },
    "/agents/{id}/targets": {
      "get": {
        "operationId": "list_targets",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AgentTarget"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Successfully retrieved agent targets"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-targets"
        ]
      },
      "post": {
        "operationId": "add_target",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgentTarget"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentTarget"
                }
              }
            },
            "description": "Successfully added agent target"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-targets"
        ]
      }
    },
    "/agents/{id}/targets/{stack_id}": {
      "delete": {
        "operationId": "remove_target",
        "parameters": [
          {
            "description": "ID of the agent",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "ID of the stack",
            "in": "path",
            "name": "stack_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successfully removed agent target"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Target not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "agent-targets"
        ]
      }
    },
    "/auth/pak": {
      "post": {
        "description": "This function handles the authentication process for both admin and agent PAKs.",
        "operationId": "verify_pak",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "PAK verified successfully"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid PAK"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "summary": "Verifies a PAK (Personal Access Key) and returns an AuthResponse.",
        "tags": [
          "auth"
        ]
      }
    },
    "/deployment-objects/{id}": {
      "get": {
        "description": "# Authorization\nRequires either:\n- Admin privileges\n- Agent associated with the deployment object's stack\n- Generator that owns the deployment object's stack",
        "operationId": "get_deployment_object",
        "parameters": [
          {
            "description": "ID of the deployment object to retrieve",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentObject"
                }
              }
            },
            "description": "Successfully retrieved deployment object"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Unauthorized - No valid PAK provided"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Deployment object not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "summary": "Retrieves a deployment object by ID, with access control based on user role.",
        "tags": [
          "deployment-objects"
        ]
      }
    },
    "/deployment-objects/{id}/diagnostics": {
      "post": {
        "operationId": "create_diagnostic_request",
        "parameters": [
          {
            "description": "ID of the deployment object",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDiagnosticRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticRequest"
                }
              }
            },
            "description": "Successfully created diagnostic request"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request parameters"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Deployment object or agent not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "diagnostics"
        ]
      }
    },
    "/deployment-objects/{id}/health": {
      "get": {
        "description": "# Authorization\nRequires admin privileges.",
        "operationId": "get_deployment_health",
        "parameters": [
          {
            "description": "ID of the deployment object",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentHealthResponse"
                }
              }
            },
            "description": "Successfully retrieved health"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "summary": "Gets health status for a specific deployment object.",
        "tags": [
          "health"
        ]
      }
    },
    "/diagnostics/{id}": {
      "get": {
        "operationId": "get_diagnostic",
        "parameters": [
          {
            "description": "ID of the diagnostic request",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticResponse"
                }
              }
            },
            "description": "Successfully retrieved diagnostic"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Diagnostic request not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "diagnostics"
        ]
      }
    },
    "/diagnostics/{id}/claim": {
      "post": {
        "operationId": "claim_diagnostic",
        "parameters": [
          {
            "description": "ID of the diagnostic request to claim",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticRequest"
                }
              }
            },
            "description": "Successfully claimed diagnostic request"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Diagnostic request not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Conflict - request already claimed or completed"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "diagnostics"
        ]
      }
    },
    "/diagnostics/{id}/result": {
      "post": {
        "operationId": "submit_diagnostic_result",
        "parameters": [
          {
            "description": "ID of the diagnostic request",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitDiagnosticResult"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticResult"
                }
              }
            },
            "description": "Successfully submitted diagnostic result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid result data"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Diagnostic request not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Conflict - result already submitted"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "diagnostics"
        ]
      }
    },
    "/generators": {
      "get": {
        "operationId": "list_generators",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Generator"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List all generators"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      },
      "post": {
        "operationId": "create_generator",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewGenerator"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateGeneratorResponse"
                }
              }
            },
            "description": "Generator created successfully"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid generator data"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Generator name already taken"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      }
    },
    "/generators/{id}": {
      "delete": {
        "operationId": "delete_generator",
        "parameters": [
          {
            "description": "Generator id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Generator deleted successfully"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Unauthorized access"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Generator not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      },
      "get": {
        "operationId": "get_generator",
        "parameters": [
          {
            "description": "Generator id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generator"
                }
              }
            },
            "description": "Get generator by id"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Unauthorized access"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Generator not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      },
      "put": {
        "operationId": "update_generator",
        "parameters": [
          {
            "description": "Generator id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Generator"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generator"
                }
              }
            },
            "description": "Generator updated successfully"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Unauthorized access"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Generator not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      }
    },
    "/generators/{id}/rotate-pak": {
      "post": {
        "operationId": "rotate_generator_pak",
        "parameters": [
          {
            "description": "Generator id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateGeneratorResponse"
                }
              }
            },
            "description": "Generator PAK rotated successfully"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Unauthorized access"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Generator not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "generators"
        ]
      }
    },
    "/stacks": {
      "get": {
        "operationId": "list_stacks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Stack"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of stacks"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "post": {
        "operationId": "create_stack",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewStack"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stack"
                }
              }
            },
            "description": "Stack created"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}": {
      "delete": {
        "operationId": "delete_stack",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Stack deleted"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "get": {
        "operationId": "get_stack",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stack"
                }
              }
            },
            "description": "Stack found"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "put": {
        "operationId": "update_stack",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Stack"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Stack"
                }
              }
            },
            "description": "Stack updated"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Bad request"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}/annotations": {
      "get": {
        "operationId": "stacks_list_annotations",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/StackAnnotation"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of stack annotations"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "post": {
        "operationId": "stacks_add_annotation",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewStackAnnotation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackAnnotation"
                }
              }
            },
            "description": "Annotation added"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid annotation"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}/annotations/{key}": {
      "delete": {
        "operationId": "stacks_remove_annotation",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Annotation key to remove",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Annotation removed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack or annotation not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}/deployment-objects": {
      "get": {
        "operationId": "list_deployment_objects",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/DeploymentObject"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of deployment objects for the stack"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "post": {
        "operationId": "create_deployment_object",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "description": "Deployment object payload with yaml_content and optional is_deletion_marker",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentObject"
                }
              }
            },
            "description": "Deployment object created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}/health": {
      "get": {
        "description": "# Authorization\nRequires admin privileges.",
        "operationId": "get_stack_health",
        "parameters": [
          {
            "description": "ID of the stack",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackHealthResponse"
                }
              }
            },
            "description": "Successfully retrieved stack health"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - PAK does not have required rights"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "summary": "Gets health status for all deployment objects in a stack.",
        "tags": [
          "health"
        ]
      }
    },
    "/stacks/{id}/labels": {
      "get": {
        "operationId": "stacks_list_labels",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/StackLabel"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of stack labels"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      },
      "post": {
        "operationId": "stacks_add_label",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackLabel"
                }
              }
            },
            "description": "Label added"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid label"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{id}/labels/{label}": {
      "delete": {
        "operationId": "stacks_remove_label",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Label to remove",
            "in": "path",
            "name": "label",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Label removed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Stack or label not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/stacks/{stack_id}/deployment-objects/from-template": {
      "post": {
        "operationId": "instantiate_template",
        "parameters": [
          {
            "description": "Stack ID",
            "in": "path",
            "name": "stack_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateInstantiationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentObject"
                }
              }
            },
            "description": "Deployment object created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid parameters or template rendering failed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template or stack not found"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template labels don't match stack"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "stacks"
        ]
      }
    },
    "/templates": {
      "get": {
        "operationId": "list_templates",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/StackTemplate"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of templates"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      },
      "post": {
        "operationId": "create_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackTemplate"
                }
              }
            },
            "description": "Template created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request - bad Tera syntax or validation error"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/templates/{id}": {
      "delete": {
        "operationId": "delete_template",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Template deleted"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      },
      "get": {
        "operationId": "get_template",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackTemplate"
                }
              }
            },
            "description": "Template found"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      },
      "put": {
        "operationId": "update_template",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTemplateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StackTemplate"
                }
              }
            },
            "description": "New template version created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request - bad Tera syntax or validation error"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/templates/{id}/annotations": {
      "get": {
        "operationId": "templates_list_annotations",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/TemplateAnnotation"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of annotations"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      },
      "post": {
        "operationId": "templates_add_annotation",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddAnnotationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateAnnotation"
                }
              }
            },
            "description": "Annotation added"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid annotation"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/templates/{id}/annotations/{key}": {
      "delete": {
        "operationId": "templates_remove_annotation",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Annotation key to remove",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Annotation removed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template or annotation not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/templates/{id}/labels": {
      "get": {
        "operationId": "templates_list_labels",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/TemplateLabel"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of labels"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      },
      "post": {
        "operationId": "templates_add_label",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateLabel"
                }
              }
            },
            "description": "Label added"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid label"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/templates/{id}/labels/{label}": {
      "delete": {
        "operationId": "templates_remove_label",
        "parameters": [
          {
            "description": "Template ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Label to remove",
            "in": "path",
            "name": "label",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Label removed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Template or label not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "generator_pak": []
          }
        ],
        "tags": [
          "templates"
        ]
      }
    },
    "/webhook-deliveries/{id}/result": {
      "post": {
        "operationId": "report_delivery_result",
        "parameters": [
          {
            "description": "Delivery ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeliveryResultRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Delivery result recorded"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Agent access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Delivery not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "list_webhooks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WebhookResponse"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List all webhook subscriptions"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      },
      "post": {
        "operationId": "create_webhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            },
            "description": "Webhook subscription created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request data"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/webhooks/event-types": {
      "get": {
        "operationId": "list_event_types",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List available event types"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/webhooks/{id}": {
      "delete": {
        "operationId": "delete_webhook",
        "parameters": [
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Webhook subscription deleted"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Webhook subscription not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      },
      "get": {
        "operationId": "get_webhook",
        "parameters": [
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            },
            "description": "Get webhook subscription by ID"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Webhook subscription not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      },
      "put": {
        "operationId": "update_webhook",
        "parameters": [
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            },
            "description": "Webhook subscription updated"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request data"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Webhook subscription not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "operationId": "list_deliveries",
        "parameters": [
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Filter by delivery status",
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of results",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "Offset for pagination",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WebhookDelivery"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List deliveries for subscription"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Webhook subscription not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "operationId": "test_webhook",
        "parameters": [
          {
            "description": "Webhook subscription ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Test delivery successful"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Test delivery failed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - Admin access required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Webhook subscription not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "webhooks"
        ]
      }
    },
    "/work-order-log": {
      "get": {
        "operationId": "list_work_order_log",
        "parameters": [
          {
            "description": "Filter by work type",
            "in": "query",
            "name": "work_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by success status",
            "in": "query",
            "name": "success",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Filter by agent ID",
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Limit number of results",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WorkOrderLog"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of completed work orders"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/work-order-log/{id}": {
      "get": {
        "operationId": "get_work_order_log",
        "parameters": [
          {
            "description": "Work order log ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderLog"
                }
              }
            },
            "description": "Work order log entry found"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Work order log entry not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/work-orders": {
      "get": {
        "operationId": "list_work_orders",
        "parameters": [
          {
            "description": "Filter by status",
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by work type",
            "in": "query",
            "name": "work_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/WorkOrder"
                  },
                  "type": "array"
                }
              }
            },
            "description": "List of work orders"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      },
      "post": {
        "operationId": "create_work_order",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrder"
                }
              }
            },
            "description": "Work order created"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Invalid request"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/work-orders/{id}": {
      "delete": {
        "operationId": "delete_work_order",
        "parameters": [
          {
            "description": "Work order ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Work order deleted"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Work order not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      },
      "get": {
        "operationId": "get_work_order",
        "parameters": [
          {
            "description": "Work order ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrder"
                }
              }
            },
            "description": "Work order found"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden - requires admin PAK"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Work order not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/work-orders/{id}/claim": {
      "post": {
        "operationId": "claim_work_order",
        "parameters": [
          {
            "description": "Work order ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClaimWorkOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrder"
                }
              }
            },
            "description": "Work order claimed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Work order not found or not claimable"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    },
    "/work-orders/{id}/complete": {
      "post": {
        "operationId": "complete_work_order",
        "parameters": [
          {
            "description": "Work order ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteWorkOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkOrderLog"
                }
              }
            },
            "description": "Work order completed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Work order not found"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "security": [
          {
            "admin_pak": []
          },
          {
            "agent_pak": []
          }
        ],
        "tags": [
          "work-orders"
        ]
      }
    }
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "tags": [
    {
      "description": "Agent Events management API",
      "name": "agent-events"
    },
    {
      "description": "Generator management API",
      "name": "generators"
    },
    {
      "description": "Agent Labels management API",
      "name": "agent-labels"
    },
    {
      "description": "Agent Annotations management API",
      "name": "agent-annotations"
    },
    {
      "description": "Agent Targets management API",
      "name": "agent-targets"
    },
    {
      "description": "Core Agent management API",
      "name": "agents"
    },
    {
      "description": "Deployment Objects management API",
      "name": "deployment-objects"
    },
    {
      "description": "Stack management API",
      "name": "stacks"
    },
    {
      "description": "Stack Templates management API",
      "name": "templates"
    },
    {
      "description": "Work Orders management API",
      "name": "work-orders"
    },
    {
      "description": "Work Order Log API",
      "name": "work-order-log"
    },
    {
      "description": "Authentication API",
      "name": "auth"
    },
    {
      "description": "Deployment Health monitoring API",
      "name": "health"
    },
    {
      "description": "On-demand diagnostics API",
      "name": "diagnostics"
    },
    {
      "description": "Webhook subscription and delivery API",
      "name": "webhooks"
    },
    {
      "description": "Administrative operations API",
      "name": "Admin"
    }
  ]
}