From b08f2f6aa3319ef70aeafd6b877ec9229ee3af4f Mon Sep 17 00:00:00 2001 From: ysyneu <9045284+ysyneu@users.noreply.github.com> Date: Tue, 1 Sep 2026 06:14:36 +0000 Subject: [PATCH] chore: sync OpenAPI spec from flashduty-docs + regenerate --- models_gen.go | 16 ++++++ openapi/openapi.en.json | 123 ++++++++++++++++++++++++++++++++++++++++ openapi/openapi.zh.json | 123 ++++++++++++++++++++++++++++++++++++++++ roundtrip_gen_test.go | 1 + status_pages.go | 14 +++++ 5 files changed, 277 insertions(+) diff --git a/models_gen.go b/models_gen.go index 98c8e12..9103bc5 100644 --- a/models_gen.go +++ b/models_gen.go @@ -2138,6 +2138,14 @@ type CreateStatusPageChangeTimelineRequest struct { Status string `json:"status" toon:"status"` } +// CreateStatusPageDraftRequest is generated from the Flashduty OpenAPI schema. +type CreateStatusPageDraftRequest struct { + // Draft payload, stored verbatim, up to 64 KB serialized. Validated fields: `page_id`, `type` (`incident` or `maintenance`), `name`, `message`; optional `change_id` (append an update to an existing event when > 0), `status`, `affected_components`, and `start_time`/`end_time` (Unix epoch seconds, new maintenance only). + Draft map[string]any `json:"draft" toon:"draft"` + // Opaque marker of the drafting origin, e.g. `ai_sre:sess_xxx`. Up to 64 characters. + Source string `json:"source,omitempty" toon:"source,omitempty"` +} + // CreateStatusPageRequest is generated from the Flashduty OpenAPI schema. type CreateStatusPageRequest struct { // Get-in-touch contact, such as a mailto or website URL. @@ -9783,6 +9791,14 @@ type StatusPageComponentItem struct { SectionID string `json:"section_id" toon:"section_id"` } +// StatusPageDraftCreateResponse is generated from the Flashduty OpenAPI schema. +type StatusPageDraftCreateResponse struct { + // Creation time in Unix epoch seconds. + CreatedAt Timestamp `json:"created_at" toon:"created_at"` + // Draft ID matching `draft_[A-Za-z0-9]{22}`; the console review link carries it. + DraftID string `json:"draft_id" toon:"draft_id"` +} + // StatusPageInfoResponse is generated from the Flashduty OpenAPI schema. type StatusPageInfoResponse struct { // Components tracked on the status page. diff --git a/openapi/openapi.en.json b/openapi/openapi.en.json index eb3cc92..2f1d624 100644 --- a/openapi/openapi.en.json +++ b/openapi/openapi.en.json @@ -12224,6 +12224,92 @@ ] } }, + "/status-page/draft/create": { + "post": { + "operationId": "statusPageDraftCreate", + "summary": "Create status page draft", + "description": "Store a status page event draft so a human can review and publish it from the console.", + "tags": [ + "On-call/Status pages" + ], + "x-mint": { + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **300 requests/minute**; **20 requests/second** per account |\n| Permissions | None — any valid `app_key` can call this operation |\n\n## Usage\n\n- The `draft` payload is stored verbatim (up to 64 KB); the console publish form reads it back to prefill the event.\n- A draft lives for 30 days and is consumed exactly once when the event is published.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/on-call/status-pages/status-page-draft-create", + "metadata": { + "sidebarTitle": "Create status page draft" + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/SuccessEnvelope" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/components/schemas/StatusPageDraftCreateResponse" + } + } + } + ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "draft_id": "draft_3xK9mQ2vN7pR4wT8yH1sJ5", + "created_at": 1788000000 + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/Unauthorized" + }, + "429": { + "$ref": "#/components/responses/TooManyRequests" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateStatusPageDraftRequest" + }, + "example": { + "draft": { + "v": 1, + "page_id": 5750613685214, + "type": "incident", + "name": "Web Console Degraded Performance", + "message": "We are investigating degraded performance affecting the web console.", + "affected_components": [ + { + "component_id": "01KC3GAZ6ZJE40H55GM31RPWZE", + "status": "degraded" + } + ] + }, + "source": "ai_sre:sess_01KC3H2A9ZQ8W7E6R5T4Y3U2I1" + } + } + } + } + } + }, "/status-page/change/create": { "post": { "operationId": "statusPageChangeCreate", @@ -42665,6 +42751,25 @@ } } }, + "StatusPageDraftCreateResponse": { + "type": "object", + "description": "Result of storing a status page draft.", + "required": [ + "draft_id", + "created_at" + ], + "properties": { + "draft_id": { + "type": "string", + "description": "Draft ID matching `draft_[A-Za-z0-9]{22}`; the console review link carries it." + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "Creation time in Unix epoch seconds." + } + } + }, "ImportStatusPageSubscribersRequest": { "type": "object", "description": "Parameters for bulk-importing subscribers. Each subscriber must have a non-empty `recipient` (≤255 chars) and subscribe to at least one component, change, or set `all: true`.", @@ -43195,6 +43300,24 @@ } } }, + "CreateStatusPageDraftRequest": { + "type": "object", + "description": "Parameters for storing a status page draft. The `draft` payload is stored verbatim; only the validated fields listed below are interpreted.", + "required": [ + "draft" + ], + "properties": { + "draft": { + "type": "object", + "description": "Draft payload, stored verbatim, up to 64 KB serialized. Validated fields: `page_id`, `type` (`incident` or `maintenance`), `name`, `message`; optional `change_id` (append an update to an existing event when > 0), `status`, `affected_components`, and `start_time`/`end_time` (Unix epoch seconds, new maintenance only)." + }, + "source": { + "type": "string", + "maxLength": 64, + "description": "Opaque marker of the drafting origin, e.g. `ai_sre:sess_xxx`. Up to 64 characters." + } + } + }, "RuleListRequest": { "type": "object", "description": "Filter parameter for listing rules in a folder.", diff --git a/openapi/openapi.zh.json b/openapi/openapi.zh.json index 8330b09..0f68dc5 100644 --- a/openapi/openapi.zh.json +++ b/openapi/openapi.zh.json @@ -12224,6 +12224,92 @@ ] } }, + "/status-page/draft/create": { + "post": { + "operationId": "statusPageDraftCreate", + "summary": "创建状态页草稿", + "description": "存储状态页事件草稿,供人工在控制台审核后发布。", + "tags": [ + "On-call/状态页" + ], + "x-mint": { + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **300 次/分钟**;**20 次/秒** |\n| 权限要求 | 无 —— 任意有效 `app_key` 均可调用 |\n\n## 使用说明\n\n- `draft` 载荷将被原样存储(最大 64 KB);控制台发布表单会读取它来预填事件内容。\n- 草稿保留 30 天,事件发布时被消费且仅可消费一次。\n- 每次调用都会记录到账户审计日志,请勿在请求字段中写入敏感信息。", + "href": "/zh/api-reference/on-call/status-pages/status-page-draft-create", + "metadata": { + "sidebarTitle": "创建状态页草稿" + } + }, + "responses": { + "200": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/SuccessEnvelope" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/components/schemas/StatusPageDraftCreateResponse" + } + } + } + ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "draft_id": "draft_3xK9mQ2vN7pR4wT8yH1sJ5", + "created_at": 1788000000 + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/BadRequest" + }, + "401": { + "$ref": "#/components/responses/Unauthorized" + }, + "429": { + "$ref": "#/components/responses/TooManyRequests" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateStatusPageDraftRequest" + }, + "example": { + "draft": { + "v": 1, + "page_id": 5750613685214, + "type": "incident", + "name": "Web Console Degraded Performance", + "message": "We are investigating degraded performance affecting the web console.", + "affected_components": [ + { + "component_id": "01KC3GAZ6ZJE40H55GM31RPWZE", + "status": "degraded" + } + ] + }, + "source": "ai_sre:sess_01KC3H2A9ZQ8W7E6R5T4Y3U2I1" + } + } + } + } + } + }, "/status-page/change/create": { "post": { "operationId": "statusPageChangeCreate", @@ -42665,6 +42751,25 @@ } } }, + "StatusPageDraftCreateResponse": { + "type": "object", + "description": "存储状态页草稿的结果。", + "required": [ + "draft_id", + "created_at" + ], + "properties": { + "draft_id": { + "type": "string", + "description": "草稿 ID,格式为 `draft_[A-Za-z0-9]{22}`;控制台审核链接会携带它。" + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "创建时间,Unix epoch 秒。" + } + } + }, "ImportStatusPageSubscribersRequest": { "type": "object", "description": "批量导入订阅者所需的参数。每个订阅者的 `recipient` 非空且不超过 255 字符;并且至少订阅一个组件/事件,或将 `all` 置为 true。", @@ -43195,6 +43300,24 @@ } } }, + "CreateStatusPageDraftRequest": { + "type": "object", + "description": "存储状态页草稿的参数。`draft` 载荷将被原样存储,仅下列被校验的字段会被解析。", + "required": [ + "draft" + ], + "properties": { + "draft": { + "type": "object", + "description": "草稿载荷,原样存储,序列化后最大 64 KB。被校验的字段:`page_id`、`type`(`incident` 或 `maintenance`)、`name`、`message`;可选 `change_id`(大于 0 时表示向已有事件追加进展)、`status`、`affected_components`,以及 `start_time`/`end_time`(Unix epoch 秒,仅新建维护窗口时使用)。" + }, + "source": { + "type": "string", + "maxLength": 64, + "description": "草稿来源的不透明标记,例如 `ai_sre:sess_xxx`。最长 64 个字符。" + } + } + }, "RuleListRequest": { "type": "object", "description": "按文件夹查询规则的过滤参数。", diff --git a/roundtrip_gen_test.go b/roundtrip_gen_test.go index a7938f6..6c1e0a1 100644 --- a/roundtrip_gen_test.go +++ b/roundtrip_gen_test.go @@ -226,6 +226,7 @@ var exampleDataDecoders = map[string]func(json.RawMessage) error{ }, "POST /status-page/component/upsert": func(d json.RawMessage) error { var v UpsertStatusPageComponentResponse; return json.Unmarshal(d, &v) }, "POST /status-page/create": func(d json.RawMessage) error { var v CreateStatusPageResponse; return json.Unmarshal(d, &v) }, + "POST /status-page/draft/create": func(d json.RawMessage) error { var v StatusPageDraftCreateResponse; return json.Unmarshal(d, &v) }, "POST /status-page/migrate-email-subscribers": func(d json.RawMessage) error { var v StatusPageMigrationStartResponse; return json.Unmarshal(d, &v) }, "POST /status-page/migrate-structure": func(d json.RawMessage) error { var v StatusPageMigrationStartResponse; return json.Unmarshal(d, &v) }, "POST /status-page/section/upsert": func(d json.RawMessage) error { var v UpsertStatusPageSectionResponse; return json.Unmarshal(d, &v) }, diff --git a/status_pages.go b/status_pages.go index e8d51df..4e47788 100644 --- a/status_pages.go +++ b/status_pages.go @@ -173,6 +173,20 @@ func (s *StatusPagesService) Delete(ctx context.Context, req *DeleteStatusPageRe return s.client.do(ctx, "/status-page/delete", req, nil) } +// Create status page draft. +// +// Store a status page event draft so a human can review and publish it from the console. +// +// API: POST /status-page/draft/create (statusPageDraftCreate). +func (s *StatusPagesService) DraftCreate(ctx context.Context, req *CreateStatusPageDraftRequest) (*StatusPageDraftCreateResponse, *Response, error) { + out := new(StatusPageDraftCreateResponse) + resp, err := s.client.do(ctx, "/status-page/draft/create", req, out) + if err != nil { + return nil, resp, err + } + return out, resp, nil +} + // Get status page detail. // // Retrieve detailed configuration for a specific status page.