{
  "openapi": "3.0.3",
  "info": {
    "title": "FlowPort · 流港 Management API",
    "version": "1.0.0",
    "description": "管理地址的 /api/v1；Bearer API Key 与 UI 共用业务接口。read 仅 GET/HEAD；write 可管理配置、发布、Worker 与失败记录。Key/账户管理只使用 Cookie+CSRF，不属于此对外契约。成功响应为 JSON，错误为 text/plain；时间为 Unix 毫秒，revision/计数为 int64。"
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/source-types": {
      "get": {
        "operationId": "listSourceTypes",
        "summary": "查询 Source 目录",
        "tags": [
          "source-types"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SourceType"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/destination-types": {
      "get": {
        "operationId": "listDestinationTypes",
        "summary": "查询 Destination 目录",
        "tags": [
          "destination-types"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DestinationType"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/flows": {
      "get": {
        "operationId": "listFlows",
        "summary": "查询草稿与当前发布状态",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Flow"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/flows/{id}": {
      "get": {
        "operationId": "getFlow",
        "summary": "读取单条流草稿",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "put": {
        "operationId": "saveFlow",
        "summary": "保存完整草稿",
        "tags": [
          "flows"
        ],
        "description": "新流 revision=0；已有流带最近读取的 revision，过期返回 409。保存不发布，也不启停；敏感占位符回传保留原值。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Flow"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteFlow",
        "summary": "删除停止且全部历史 Worker 确认排空的数据流",
        "tags": [
          "flows"
        ],
        "description": "停止返回后仍需等待所有关联 Worker 确认停止且无积压/失败；未确认时返回 400。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/flows/{id}/publish": {
      "post": {
        "operationId": "publishFlow",
        "summary": "生成不可变发布版本并异步下发",
        "tags": [
          "flows"
        ],
        "description": "发布响应不等于远端来源已就绪；继续查询 deployment。旧积压按接受时版本投递。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/flows/{id}/start": {
      "post": {
        "operationId": "startFlow",
        "summary": "启用最后发布版本",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/flows/{id}/stop": {
      "post": {
        "operationId": "stopFlow",
        "summary": "停止新采集，继续发送已接受积压",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/flows/{id}/deployment": {
      "get": {
        "operationId": "getDeployment",
        "summary": "查询下发与实际运行版本",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deployment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/flows/{id}/observe": {
      "get": {
        "operationId": "observeFlow",
        "summary": "查询已发布运行链路和累计计数",
        "tags": [
          "flows"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ObservedFlow"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "worker",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "原 Worker ID；集群失败操作必须明确提供，避免节点本地 ID 冲突。"
          }
        ]
      }
    },
    "/destinations": {
      "get": {
        "operationId": "listDestinations",
        "summary": "查询发送目标",
        "tags": [
          "destinations"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Destination"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/destinations/{id}": {
      "get": {
        "operationId": "getDestination",
        "summary": "读取单个发送目标",
        "tags": [
          "destinations"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Destination"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "put": {
        "operationId": "saveDestination",
        "summary": "创建或完整保存发送目标",
        "tags": [
          "destinations"
        ],
        "description": "变更需重新发布引用它的数据流才生效；******** 保留同协议旧凭证。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Destination"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Destination"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteDestination",
        "summary": "删除未被当前草稿或发布版本引用的目标",
        "tags": [
          "destinations"
        ],
        "description": "被引用返回 409；历史投递快照保留。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/pipeline/preview": {
      "post": {
        "operationId": "previewPipeline",
        "summary": "用至多 100 条真实样本预览 Pipeline",
        "tags": [
          "pipeline"
        ],
        "description": "需要 write Key。不会保存、发布或投递数据；整数与纳秒时间不应由低精度客户端重编码。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            }
          }
        }
      }
    },
    "/status": {
      "get": {
        "operationId": "getStatus",
        "summary": "查询集群/本机绝对状态",
        "tags": [
          "status"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/workers": {
      "get": {
        "operationId": "listWorkers",
        "summary": "查询 Worker 及最后报告",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Worker"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/workers/{id}": {
      "get": {
        "operationId": "getWorker",
        "summary": "查询 Worker 详情",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Worker"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "operationId": "updateWorker",
        "summary": "修改名称、标签与新任务分配开关",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkerUpdate"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeWorker",
        "summary": "完成排空后撤销 Worker 身份",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "force",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "强制撤销身份，不迁移或删除离线节点队列。"
          }
        ]
      }
    },
    "/workers/join-tokens": {
      "post": {
        "operationId": "createJoinToken",
        "summary": "创建十分钟、一次使用的加入凭证",
        "tags": [
          "workers"
        ],
        "description": "需要 write Key；返回的加入凭证不是管理 API Key。 必须激活商业 License 且注册名额未满，否则返回 403。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JoinToken"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/workers/{id}/drain": {
      "post": {
        "operationId": "drainWorker",
        "summary": "幂等排空并返回操作 ID",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DrainOperation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/workers/{id}/resume": {
      "post": {
        "operationId": "resumeWorker",
        "summary": "恢复健康在线节点并重新校验",
        "tags": [
          "workers"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/failures": {
      "get": {
        "operationId": "listFailures",
        "summary": "查询每 Worker 最近至多 100 条失败元数据",
        "tags": [
          "failures"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Failure"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/failures/{id}/sample": {
      "get": {
        "operationId": "getFailureSample",
        "summary": "从原 Worker 读取至多 256 KiB 的失败样本",
        "tags": [
          "failures"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FailureSample"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "worker",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "原 Worker ID；集群失败操作必须明确提供，避免节点本地 ID 冲突。"
          }
        ]
      }
    },
    "/failures/{id}/replay": {
      "post": {
        "operationId": "replayFailure",
        "summary": "从原 Worker 重放失败记录",
        "tags": [
          "failures"
        ],
        "description": "已编码发送失败重新应用当前目标/分流，不重复执行 Pipeline；可能重复投递到先前成功目标。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "worker",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "原 Worker ID；集群失败操作必须明确提供，避免节点本地 ID 冲突。"
          }
        ]
      }
    },
    "/failures/{id}": {
      "delete": {
        "operationId": "deleteFailure",
        "summary": "永久丢弃原 Worker 的失败记录",
        "tags": [
          "failures"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "worker",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "原 Worker ID；集群失败操作必须明确提供，避免节点本地 ID 冲突。"
          }
        ]
      }
    },
    "/settings/workspace": {
      "get": {
        "operationId": "getWorkspaceSettings",
        "summary": "查询工作台偏好",
        "tags": [
          "settings"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSettings"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      },
      "put": {
        "operationId": "saveWorkspaceSettings",
        "summary": "完整保存工作台偏好",
        "tags": [
          "settings"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceSettings"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkspaceSettings"
              }
            }
          }
        }
      }
    },
    "/settings/ingress": {
      "get": {
        "operationId": "getIngressSettings",
        "summary": "查询对外接入地址模板",
        "tags": [
          "settings"
        ],
        "description": "",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngressSettings"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      },
      "put": {
        "operationId": "saveIngressSettings",
        "summary": "保存对外接入地址模板",
        "tags": [
          "settings"
        ],
        "description": "空值恢复默认；只接受无用户信息/查询/片段的 HTTP(S) URL，不改变监听地址。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngressSettings"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IngressSettings"
              }
            }
          }
        }
      }
    },
    "/openapi.yaml": {
      "get": {
        "operationId": "getOpenAPIDefinition",
        "summary": "下载本接口定义",
        "tags": [
          "reference"
        ],
        "responses": {
          "200": {
            "description": "OpenAPI 定义（JSON 也是合法 YAML）",
            "content": {
              "application/yaml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "404": {
            "$ref": "#/components/responses/HTTP404"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "429": {
            "$ref": "#/components/responses/HTTP429"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/audit-logs": {
      "get": {
        "operationId": "listAuditLogs",
        "summary": "查询管理操作记录",
        "tags": [
          "audit-logs"
        ],
        "description": "需要Cookie或有效read/write Bearer。管理端保留最近10000条元数据，不包含请求正文、认证凭证或原始错误正文；结果未确认须核对实际状态。只读查询不产生操作记录。",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            },
            "description": "名称、ID、操作者或IP，不区分大小写"
          },
          {
            "name": "resource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "flows",
                "destinations",
                "workers",
                "failures",
                "settings",
                "api_keys"
              ]
            },
            "description": "对象类型"
          },
          {
            "name": "outcome",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "success",
                "failure",
                "unconfirmed"
              ]
            },
            "description": "请求结果，不等于异步任务已经完成"
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "admin",
                "api_key"
              ]
            },
            "description": "操作者类型"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            },
            "description": "开始Unix毫秒，包含边界"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            },
            "description": "结束Unix毫秒，包含边界且不早于from"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "description": "每页条数"
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "上一页next_before字符串；新操作不会移动旧页"
          }
        ],
        "responses": {
          "200": {
            "description": "当前保留记录的筛选结果，按开始时递增ID倒序",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditPage"
                }
              }
            }
          },
          "400": {
            "description": "筛选条件无效",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "未认证或凭证无效",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "原生存储不可读",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/diagnostics": {
      "post": {
        "operationId": "diagnoseConnection",
        "summary": "Test current Source/Destination or sample upstream data",
        "tags": [
          "diagnostics"
        ],
        "description": "write key required. Does not save or publish. Executed on selected Worker. HTTP 200 does not imply success: inspect report.state and each check. No business writes or additional message consumption. sample only supported for Source.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnosticRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diagnostic report, including partial or failed checks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticReport"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "write key or Cookie+CSRF required"
          },
          "409": {
            "description": "No available Worker"
          },
          "429": {
            "description": "Diagnostic concurrency limit"
          },
          "503": {
            "description": "Worker timed out or did not complete"
          }
        }
      }
    },
    "/license": {
      "get": {
        "operationId": "getLicenseStatus",
        "summary": "查询版本与授权状态",
        "tags": [
          "settings"
        ],
        "description": "read/write Key 或管理员会话。只返回授权元信息，不返回签名文件。",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LicenseStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          }
        },
        "security": [
          {
            "apiKey": []
          },
          {
            "adminSession": []
          }
        ]
      },
      "put": {
        "operationId": "activateLicense",
        "summary": "激活或更新 License",
        "tags": [
          "settings"
        ],
        "description": "仅管理员 Cookie 与 CSRF；API Key 不允许激活。绑定集群并校验签名、有效期，失败不替换现有授权。",
        "security": [
          {
            "adminSession": [],
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "license"
                ],
                "additionalProperties": false,
                "properties": {
                  "license": {
                    "type": "string",
                    "maxLength": 65536,
                    "description": "LicRegister compact JWS（最大 64 KiB）或旧版 fp1（最大 16 KiB），仅离线验证。"
                  },
                  "preview_revision": {
                    "type": "string",
                    "description": "可选预检 revision；授权/成员变化时返回 409，UI 必须携带",
                    "maxLength": 64
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LicenseStatus"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          },
          "409": {
            "$ref": "#/components/responses/HTTP409"
          },
          "503": {
            "$ref": "#/components/responses/HTTP503"
          }
        }
      }
    },
    "/license/preview": {
      "post": {
        "operationId": "previewLicense",
        "summary": "验证授权并预览 Worker 影响",
        "description": "仅管理员 Cookie+CSRF；只读，不保存授权或写入操作记录。返回最多 20 个新增受限节点及总数。",
        "tags": [
          "settings"
        ],
        "security": [
          {
            "adminSession": [],
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "license"
                ],
                "properties": {
                  "license": {
                    "type": "string",
                    "maxLength": 65536,
                    "description": "LicRegister compact JWS（最大 64 KiB）或旧版 fp1（最大 16 KiB），仅离线验证。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "只读预检",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LicensePreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/HTTP400"
          },
          "401": {
            "$ref": "#/components/responses/HTTP401"
          },
          "403": {
            "$ref": "#/components/responses/HTTP403"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "cw_api_<id>_<secret>",
        "description": "在系统设置的管理 API 页签创建，Authorization: Bearer <key>；不接受查询参数中的 Key。"
      },
      "adminSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "collectway_session"
      },
      "csrfToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-CSRF-Token"
      }
    },
    "responses": {
      "HTTP400": {
        "description": "格式/配置错误或操作前提不满足",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP401": {
        "description": "缺少、无效、过期或已撤销的 API Key",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP403": {
        "description": "只读凭证无权写入；账户/Key 管理仅允许浏览器会话",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP404": {
        "description": "资源不存在或当前部署未提供此集群接口",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP409": {
        "description": "发布 revision 过期、资源仍被引用或状态冲突",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP429": {
        "description": "请求限流",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "HTTP503": {
        "description": "服务或持久化暂不可用",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },
    "schemas": {
      "Ok": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        }
      },
      "Source": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "config": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "type",
          "config"
        ]
      },
      "RouteCondition": {
        "type": "object",
        "properties": {
          "tag": {
            "type": "string"
          },
          "operator": {
            "type": "string",
            "enum": [
              "eq",
              "neq",
              "exists",
              "not_exists"
            ]
          },
          "value": {
            "type": "string"
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteCondition"
            }
          }
        }
      },
      "RouteRule": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string"
          },
          "destination_id": {
            "type": "string"
          },
          "destination_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "when": {
            "$ref": "#/components/schemas/RouteCondition"
          }
        }
      },
      "Routing": {
        "type": "object",
        "properties": {
          "tag": {
            "type": "string"
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteRule"
            }
          }
        },
        "required": [
          "rules"
        ]
      },
      "Flow": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "pipelines": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "destination_id": {
            "type": "string"
          },
          "destination_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "routing": {
            "$ref": "#/components/schemas/Routing"
          },
          "queue_bytes": {
            "type": "integer",
            "format": "int64"
          },
          "enabled": {
            "type": "boolean"
          },
          "revision": {
            "type": "integer",
            "format": "int64"
          },
          "worker_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ack_policy": {
            "type": "string",
            "enum": [
              "local",
              ""
            ]
          }
        },
        "required": [
          "id",
          "name",
          "source",
          "pipelines",
          "queue_bytes",
          "revision"
        ]
      },
      "Destination": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "config": {
            "type": "object",
            "additionalProperties": true,
            "description": "Protocol-specific configuration from GET /destination-types. Cloud targets include aws_cloudwatch_logs, azure_blob, gcp_cloud_storage and gcp_stackdriver_logs. Azure account_secret/sas_token, AWS keys, GCP credentials_json and token are encrypted and redacted; ******** preserves an existing value only for the same protocol. See cloud-destinations help for IAM, read-only diagnostics and delivery boundaries."
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "SourceType": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "group": {
            "type": "string"
          },
          "mode": {
            "type": "string"
          },
          "signals": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "defaults": {
            "type": "object",
            "additionalProperties": true
          },
          "docs": {
            "type": "string"
          }
        }
      },
      "DestinationType": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "group": {
            "type": "string"
          },
          "signals": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "defaults": {
            "type": "object",
            "additionalProperties": true
          },
          "docs": {
            "type": "string"
          }
        }
      },
      "Stats": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "pending": {
            "type": "integer",
            "format": "int64"
          },
          "failed": {
            "type": "integer",
            "format": "int64"
          },
          "bytes": {
            "type": "integer",
            "format": "int64"
          },
          "received": {
            "type": "integer",
            "format": "int64"
          },
          "sent": {
            "type": "integer",
            "format": "int64"
          },
          "dropped": {
            "type": "integer",
            "format": "int64"
          },
          "last_sent": {
            "type": "integer",
            "format": "int64"
          },
          "last_error": {
            "type": "string"
          }
        }
      },
      "SourceState": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "since": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "Deployment": {
        "type": "object",
        "properties": {
          "flow_id": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "format": "int64"
          },
          "mode": {
            "type": "string",
            "enum": [
              "shared",
              "exclusive"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "stopped",
              "waiting",
              "syncing",
              "partial_failure"
            ]
          },
          "task": {
            "type": "object",
            "additionalProperties": true
          },
          "workers": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "Status": {
        "type": "object",
        "properties": {
          "flows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Stats"
            }
          },
          "sources": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/SourceState"
            }
          },
          "deployments": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/Deployment"
            }
          }
        }
      },
      "Worker": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "hostname": {
            "type": "string"
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "nullable": true
          },
          "local": {
            "type": "boolean"
          },
          "assign": {
            "type": "boolean"
          },
          "draining": {
            "type": "boolean"
          },
          "removed": {
            "type": "boolean"
          },
          "operation_id": {
            "type": "string"
          },
          "last_seen": {
            "type": "integer",
            "format": "int64"
          },
          "online": {
            "type": "boolean"
          },
          "ready": {
            "type": "boolean"
          },
          "report": {
            "type": "object",
            "additionalProperties": true
          },
          "license_blocked": {
            "type": "boolean",
            "description": "授权失效或超配额，停止新采集但保留队列投递"
          }
        }
      },
      "WorkerUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assign": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "labels"
        ]
      },
      "JoinToken": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "expires_at": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "DrainOperation": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string"
          }
        }
      },
      "ObservedFlow": {
        "type": "object",
        "properties": {
          "flow": {
            "$ref": "#/components/schemas/Flow"
          },
          "destinations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Destination"
            }
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "stats": {
            "$ref": "#/components/schemas/Stats"
          },
          "source": {
            "$ref": "#/components/schemas/SourceState"
          },
          "sample_at": {
            "type": "integer",
            "format": "int64"
          },
          "deployment": {
            "$ref": "#/components/schemas/Deployment"
          }
        }
      },
      "Failure": {
        "type": "object",
        "properties": {
          "worker_id": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "flow_id": {
            "type": "string"
          },
          "version_id": {
            "type": "integer",
            "format": "int64"
          },
          "state": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "destination_id": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "attempts": {
            "type": "integer",
            "format": "int64"
          },
          "created_at": {
            "type": "integer",
            "format": "int64"
          },
          "payload": {
            "type": "string",
            "format": "byte"
          }
        }
      },
      "FailureSample": {
        "type": "object",
        "properties": {
          "worker_id": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "flow_id": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "payload": {
            "type": "string",
            "format": "byte"
          },
          "sample_text": {
            "type": "string"
          }
        }
      },
      "PreviewRequest": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string"
          },
          "script": {
            "type": "string"
          },
          "format": {
            "type": "string",
            "enum": [
              "json",
              "ndjson",
              "text"
            ]
          },
          "sample": {
            "type": "string"
          }
        },
        "required": [
          "sample",
          "format"
        ]
      },
      "PreviewResponse": {
        "type": "object",
        "properties": {
          "before": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string"
                },
                "points": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "nullable": true
                },
                "dropped": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          }
        }
      },
      "WorkspaceSettings": {
        "type": "object",
        "properties": {
          "default_queue_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 1048576,
            "maximum": 1099511627776,
            "multipleOf": 1048576
          },
          "refresh_seconds": {
            "type": "integer",
            "minimum": 3,
            "maximum": 60
          },
          "animate_flow": {
            "type": "boolean"
          }
        },
        "required": [
          "default_queue_bytes",
          "refresh_seconds",
          "animate_flow"
        ]
      },
      "IngressSettings": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          }
        },
        "required": [
          "url"
        ]
      },
      "AuditRecord": {
        "type": "object",
        "required": [
          "id",
          "time",
          "duration_ms",
          "action",
          "resource",
          "object_id",
          "object_name",
          "actor_kind",
          "actor_id",
          "actor_name",
          "ip",
          "outcome",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[1-9][0-9]*$",
            "description": "递增记录ID，以字符串保留完整精度"
          },
          "time": {
            "type": "integer",
            "format": "int64",
            "description": "开始Unix毫秒"
          },
          "duration_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "action": {
            "type": "string"
          },
          "resource": {
            "type": "string",
            "enum": [
              "flows",
              "destinations",
              "workers",
              "failures",
              "settings",
              "api_keys"
            ]
          },
          "object_id": {
            "type": "string"
          },
          "object_name": {
            "type": "string"
          },
          "actor_kind": {
            "type": "string",
            "enum": [
              "admin",
              "api_key"
            ]
          },
          "actor_id": {
            "type": "string"
          },
          "actor_name": {
            "type": "string"
          },
          "ip": {
            "type": "string",
            "description": "直接连接地址，不信任转发头"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "success",
              "failure",
              "unconfirmed"
            ]
          },
          "status": {
            "type": "integer",
            "minimum": 0,
            "maximum": 599,
            "description": "HTTP状态；未确认为0"
          },
          "worker_id": {
            "type": "string"
          },
          "operation_id": {
            "type": "string"
          },
          "forced": {
            "type": "boolean",
            "description": "Worker移除请求显式传入force=true"
          }
        }
      },
      "AuditPage": {
        "type": "object",
        "required": [
          "items",
          "next_before",
          "total",
          "retained",
          "capacity"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditRecord"
            }
          },
          "next_before": {
            "type": "string",
            "description": "更早一页游标，没有下一页为空"
          },
          "total": {
            "type": "integer",
            "description": "当前符合筛选条件的保留记录数量，不是冻结快照"
          },
          "retained": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          },
          "capacity": {
            "type": "integer",
            "enum": [
              10000
            ]
          }
        }
      },
      "DiagnosticRequest": {
        "type": "object",
        "required": [
          "target",
          "mode"
        ],
        "additionalProperties": false,
        "properties": {
          "target": {
            "type": "string",
            "enum": [
              "source",
              "destination"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "connect",
              "sample"
            ]
          },
          "flow_id": {
            "type": "string"
          },
          "worker_id": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "destination": {
            "$ref": "#/components/schemas/Destination"
          }
        }
      },
      "DiagnosticReport": {
        "type": "object",
        "required": [
          "state",
          "checks",
          "elapsed_ms",
          "points",
          "truncated"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "passed",
              "partial",
              "failed"
            ]
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "state",
                "message"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "passed",
                    "unknown",
                    "failed"
                  ]
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "worker_id": {
            "type": "string"
          },
          "elapsed_ms": {
            "type": "integer",
            "format": "int64"
          },
          "sample": {
            "type": "string",
            "description": "Decoded Point JSON retained as a string to preserve integers and nanoseconds; not Pipeline output."
          },
          "category": {
            "type": "string"
          },
          "points": {
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          }
        }
      },
      "LicenseStatus": {
        "type": "object",
        "required": [
          "edition",
          "state",
          "cluster_id",
          "verification_ready",
          "multi_worker",
          "max_workers",
          "registered_workers",
          "blocked_workers",
          "can_add_worker",
          "server_time",
          "supported_formats"
        ],
        "properties": {
          "edition": {
            "type": "string",
            "enum": [
              "community",
              "commercial"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "none",
              "active",
              "expired",
              "not_yet_valid",
              "invalid"
            ]
          },
          "cluster_id": {
            "type": "string"
          },
          "verification_ready": {
            "type": "boolean"
          },
          "multi_worker": {
            "type": "boolean"
          },
          "max_workers": {
            "type": "integer"
          },
          "registered_workers": {
            "type": "integer"
          },
          "blocked_workers": {
            "type": "integer"
          },
          "can_add_worker": {
            "type": "boolean"
          },
          "server_time": {
            "type": "integer",
            "format": "int64"
          },
          "license": {
            "$ref": "#/components/schemas/LicenseClaims"
          },
          "supported_formats": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "licregister",
                "fp1"
              ]
            },
            "description": "Formats supported by the build-pinned public keys. Empty for builds without verification keys. This does not certify a particular file or kid."
          }
        }
      },
      "LicenseClaims": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "product": {
            "type": "string",
            "enum": [
              "flowport",
              "collectway"
            ]
          },
          "id": {
            "type": "string"
          },
          "customer": {
            "type": "string"
          },
          "cluster_id": {
            "type": "string"
          },
          "max_workers": {
            "type": "integer",
            "minimum": 2,
            "maximum": 100000
          },
          "issued_at": {
            "type": "integer",
            "format": "int64"
          },
          "not_before": {
            "type": "integer",
            "format": "int64"
          },
          "expires_at": {
            "type": "integer",
            "format": "int64",
            "description": "Unix 毫秒；permanent=true 时为 0。"
          },
          "permanent": {
            "type": "boolean",
            "description": "LicRegister 永久授权为 true，此时 expires_at 为 0；仍受 not_before 和 Worker 配额限制。"
          }
        }
      },
      "LicensePreview": {
        "type": "object",
        "required": [
          "status",
          "revision",
          "current_max_workers",
          "newly_blocked_count",
          "newly_enabled_count",
          "newly_blocked"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/LicenseStatus"
          },
          "revision": {
            "type": "string"
          },
          "current_max_workers": {
            "type": "integer"
          },
          "newly_blocked_count": {
            "type": "integer"
          },
          "newly_enabled_count": {
            "type": "integer"
          },
          "newly_blocked": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "id",
                "name"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
