release-platform.v1.openapi.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. openapi: 3.1.0
  2. info:
  3. title: ZCode Release Platform API
  4. version: 1.0.0
  5. description: Candidate/build/approval/publication contract for the ZCode packaging platform.
  6. servers:
  7. - url: https://packaging.example.internal/v1
  8. security:
  9. - bearerAuth: []
  10. tags:
  11. - name: candidates
  12. - name: builds
  13. - name: approval
  14. - name: publications
  15. paths:
  16. /release-candidates:
  17. post:
  18. tags: [candidates]
  19. operationId: createReleaseCandidate
  20. security:
  21. - bearerAuth: [candidate:create]
  22. parameters:
  23. - $ref: "#/components/parameters/IdempotencyKey"
  24. requestBody:
  25. required: true
  26. content:
  27. application/json:
  28. schema:
  29. $ref: "#/components/schemas/CreateCandidateRequest"
  30. responses:
  31. "201":
  32. description: Candidate created.
  33. content:
  34. application/json:
  35. schema:
  36. $ref: "#/components/schemas/ReleaseCandidate"
  37. "409":
  38. $ref: "#/components/responses/IdempotencyConflict"
  39. /release-candidates/{candidateId}:
  40. parameters:
  41. - $ref: "#/components/parameters/CandidateId"
  42. get:
  43. tags: [candidates]
  44. operationId: getReleaseCandidate
  45. responses:
  46. "200":
  47. description: Candidate state and manifest.
  48. content:
  49. application/json:
  50. schema:
  51. $ref: "#/components/schemas/ReleaseCandidate"
  52. "404":
  53. $ref: "#/components/responses/CandidateNotFound"
  54. /release-candidates/{candidateId}/builds:
  55. parameters:
  56. - $ref: "#/components/parameters/CandidateId"
  57. post:
  58. tags: [builds]
  59. operationId: createBuild
  60. security:
  61. - bearerAuth: [build:create]
  62. parameters:
  63. - $ref: "#/components/parameters/IdempotencyKey"
  64. requestBody:
  65. required: true
  66. content:
  67. application/json:
  68. schema:
  69. $ref: "#/components/schemas/CreateBuildRequest"
  70. responses:
  71. "202":
  72. description: Build queued.
  73. content:
  74. application/json:
  75. schema:
  76. $ref: "#/components/schemas/BuildAccepted"
  77. "409":
  78. $ref: "#/components/responses/IdempotencyConflict"
  79. /release-candidates/{candidateId}/builds/{buildId}/complete:
  80. parameters:
  81. - $ref: "#/components/parameters/CandidateId"
  82. - $ref: "#/components/parameters/BuildId"
  83. post:
  84. tags: [builds]
  85. operationId: completeBuild
  86. security:
  87. - bearerAuth: [build:complete]
  88. parameters:
  89. - $ref: "#/components/parameters/IdempotencyKey"
  90. requestBody:
  91. required: true
  92. content:
  93. application/json:
  94. schema:
  95. $ref: "#/components/schemas/BuildCompleteRequest"
  96. responses:
  97. "200":
  98. description: Build accepted after object and digest verification.
  99. content:
  100. application/json:
  101. schema:
  102. $ref: "#/components/schemas/BuildResult"
  103. "422":
  104. $ref: "#/components/responses/ContractViolation"
  105. /release-candidates/{candidateId}/notes:
  106. parameters:
  107. - $ref: "#/components/parameters/CandidateId"
  108. post:
  109. tags: [approval]
  110. operationId: createNotesDraft
  111. security:
  112. - bearerAuth: [notes:submit]
  113. parameters:
  114. - $ref: "#/components/parameters/IdempotencyKey"
  115. requestBody:
  116. required: true
  117. content:
  118. application/json:
  119. schema:
  120. $ref: "#/components/schemas/NotesDraftRequest"
  121. responses:
  122. "201":
  123. description: Notes draft created.
  124. content:
  125. application/json:
  126. schema:
  127. $ref: "#/components/schemas/NotesDraft"
  128. "422":
  129. $ref: "#/components/responses/ContractViolation"
  130. /release-candidates/{candidateId}/approvals:
  131. parameters:
  132. - $ref: "#/components/parameters/CandidateId"
  133. post:
  134. tags: [approval]
  135. operationId: approveReleaseCandidate
  136. security:
  137. - bearerAuth: [notes:approve]
  138. parameters:
  139. - $ref: "#/components/parameters/IdempotencyKey"
  140. - $ref: "#/components/parameters/IfMatch"
  141. requestBody:
  142. required: true
  143. content:
  144. application/json:
  145. schema:
  146. $ref: "#/components/schemas/ApprovalRequest"
  147. responses:
  148. "200":
  149. description: Approval recorded.
  150. content:
  151. application/json:
  152. schema:
  153. $ref: "#/components/schemas/Approval"
  154. "409":
  155. $ref: "#/components/responses/InvalidState"
  156. /release-candidates/{candidateId}/publications:
  157. parameters:
  158. - $ref: "#/components/parameters/CandidateId"
  159. post:
  160. tags: [publications]
  161. operationId: createPublication
  162. security:
  163. - bearerAuth: [publish:create]
  164. parameters:
  165. - $ref: "#/components/parameters/IdempotencyKey"
  166. requestBody:
  167. required: true
  168. content:
  169. application/json:
  170. schema:
  171. $ref: "#/components/schemas/PublicationRequest"
  172. responses:
  173. "202":
  174. description: Publication started.
  175. content:
  176. application/json:
  177. schema:
  178. $ref: "#/components/schemas/Publication"
  179. "409":
  180. $ref: "#/components/responses/InvalidState"
  181. "422":
  182. $ref: "#/components/responses/ContractViolation"
  183. /release-candidates/{candidateId}/retry:
  184. parameters:
  185. - $ref: "#/components/parameters/CandidateId"
  186. post:
  187. tags: [publications]
  188. operationId: retryReleaseCandidate
  189. security:
  190. - bearerAuth: [publish:retry]
  191. parameters:
  192. - $ref: "#/components/parameters/IdempotencyKey"
  193. responses:
  194. "202":
  195. description: Retry started without changing existing artifact digests.
  196. content:
  197. application/json:
  198. schema:
  199. $ref: "#/components/schemas/RetryResult"
  200. "409":
  201. $ref: "#/components/responses/InvalidState"
  202. components:
  203. securitySchemes:
  204. bearerAuth:
  205. type: http
  206. scheme: bearer
  207. bearerFormat: OIDC
  208. description: Short-lived OIDC service token with scope claims.
  209. parameters:
  210. CandidateId:
  211. name: candidateId
  212. in: path
  213. required: true
  214. schema:
  215. type: string
  216. pattern: "^cand_[A-Za-z0-9_-]{8,128}$"
  217. BuildId:
  218. name: buildId
  219. in: path
  220. required: true
  221. schema:
  222. type: string
  223. pattern: "^build_[A-Za-z0-9_-]{8,128}$"
  224. IdempotencyKey:
  225. name: Idempotency-Key
  226. in: header
  227. required: true
  228. schema:
  229. type: string
  230. minLength: 8
  231. maxLength: 256
  232. IfMatch:
  233. name: If-Match
  234. in: header
  235. required: true
  236. schema:
  237. type: string
  238. responses:
  239. CandidateNotFound:
  240. description: Candidate does not exist.
  241. content:
  242. application/json:
  243. schema:
  244. $ref: "#/components/schemas/ErrorResponse"
  245. IdempotencyConflict:
  246. description: Same idempotency key was used with a different request.
  247. content:
  248. application/json:
  249. schema:
  250. $ref: "#/components/schemas/ErrorResponse"
  251. InvalidState:
  252. description: Requested state transition is not allowed.
  253. content:
  254. application/json:
  255. schema:
  256. $ref: "#/components/schemas/ErrorResponse"
  257. ContractViolation:
  258. description: Manifest, digest, version, or notes contract failed.
  259. content:
  260. application/json:
  261. schema:
  262. $ref: "#/components/schemas/ErrorResponse"
  263. schemas:
  264. Platform:
  265. type: object
  266. additionalProperties: false
  267. required: [os, arch]
  268. properties:
  269. os:
  270. type: string
  271. enum: [macos, windows, linux]
  272. arch:
  273. type: string
  274. enum: [x64, arm64]
  275. Source:
  276. type: object
  277. additionalProperties: false
  278. required: [repository, commit, version]
  279. properties:
  280. repository: { type: string }
  281. commit: { type: string, pattern: "^[0-9a-f]{40,64}$" }
  282. version: { type: string }
  283. ref: { type: string }
  284. CreateCandidateRequest:
  285. type: object
  286. additionalProperties: false
  287. required: [source, targets]
  288. properties:
  289. source: { $ref: "#/components/schemas/Source" }
  290. targets:
  291. type: array
  292. minItems: 1
  293. items: { $ref: "#/components/schemas/Platform" }
  294. ReleaseCandidate:
  295. type: object
  296. additionalProperties: true
  297. required: [schemaVersion, candidateId, source, state, platforms, provenance, createdAt]
  298. properties:
  299. schemaVersion: { const: release-candidate.v1 }
  300. candidateId: { type: string }
  301. source: { $ref: "#/components/schemas/Source" }
  302. state:
  303. type: string
  304. enum:
  305. [
  306. created,
  307. building,
  308. ready,
  309. approval_pending,
  310. approved,
  311. publishing,
  312. published,
  313. build_failed,
  314. rejected,
  315. publish_failed_retryable,
  316. cancelled,
  317. ]
  318. platforms:
  319. type: array
  320. items: { type: object }
  321. provenance: { type: object }
  322. createdAt: { type: string, format: date-time }
  323. CreateBuildRequest:
  324. type: object
  325. additionalProperties: false
  326. required: [platform]
  327. properties:
  328. platform: { $ref: "#/components/schemas/Platform" }
  329. workerPool: { type: string }
  330. constraints: { type: object, additionalProperties: true }
  331. BuildAccepted:
  332. type: object
  333. required: [buildId, candidateId, state, upload]
  334. properties:
  335. buildId: { type: string }
  336. candidateId: { type: string }
  337. state: { type: string, enum: [queued, running] }
  338. upload:
  339. type: object
  340. required: [manifestUploadUrl, artifactUploadPrefix, expiresAt]
  341. properties:
  342. manifestUploadUrl: { type: string, format: uri }
  343. artifactUploadPrefix: { type: string }
  344. expiresAt: { type: string, format: date-time }
  345. BuildCompleteRequest:
  346. type: object
  347. required: [platformManifest, provenance]
  348. properties:
  349. platformManifest: { type: object }
  350. provenance: { type: object }
  351. BuildResult:
  352. type: object
  353. required: [buildId, candidateId, state]
  354. properties:
  355. buildId: { type: string }
  356. candidateId: { type: string }
  357. state: { type: string, enum: [succeeded] }
  358. NotesDraftRequest:
  359. type: object
  360. required: [revision, locales]
  361. properties:
  362. revision: { type: string, pattern: "^sha256:[a-f0-9]{64}$" }
  363. locales:
  364. type: object
  365. required: [zh-CN, en-US]
  366. properties:
  367. zh-CN: { $ref: "#/components/schemas/LocalizedNotes" }
  368. en-US: { $ref: "#/components/schemas/LocalizedNotes" }
  369. LocalizedNotes:
  370. type: object
  371. required: [markdown]
  372. properties:
  373. markdown: { type: string, minLength: 1 }
  374. NotesDraft:
  375. allOf:
  376. - $ref: "#/components/schemas/NotesDraftRequest"
  377. - type: object
  378. required: [notesDraftId, candidateId, status]
  379. properties:
  380. notesDraftId: { type: string }
  381. candidateId: { type: string }
  382. status: { type: string, enum: [pending] }
  383. ApprovalRequest:
  384. type: object
  385. required: [notesRevision, decision]
  386. properties:
  387. notesRevision: { type: string }
  388. decision: { type: string, enum: [approve, reject] }
  389. Approval:
  390. type: object
  391. required: [candidateId, notesRevision, decision, approvedBy, approvedAt]
  392. properties:
  393. candidateId: { type: string }
  394. notesRevision: { type: string }
  395. decision: { type: string, enum: [approve, reject] }
  396. approvedBy: { type: object }
  397. approvedAt: { type: string, format: date-time }
  398. PublicationRequest:
  399. type: object
  400. required: [notesRevision, channel]
  401. properties:
  402. notesRevision: { type: string }
  403. channel: { type: string, enum: [gray, stable] }
  404. Publication:
  405. type: object
  406. required: [publicationId, candidateId, notesRevision, channel, state]
  407. properties:
  408. publicationId: { type: string }
  409. candidateId: { type: string }
  410. notesRevision: { type: string }
  411. channel: { type: string, enum: [gray, stable] }
  412. state: { type: string, enum: [publishing, published, publish_failed_retryable] }
  413. RetryResult:
  414. type: object
  415. required: [candidateId, attempt, state]
  416. properties:
  417. candidateId: { type: string }
  418. attempt: { type: integer, minimum: 1 }
  419. state: { type: string, enum: [building, publishing] }
  420. ErrorResponse:
  421. type: object
  422. required: [error]
  423. properties:
  424. error:
  425. type: object
  426. required: [code, message, retryable, requestId]
  427. properties:
  428. code: { type: string }
  429. message: { type: string }
  430. details: { type: object, additionalProperties: true }
  431. retryable: { type: boolean }
  432. requestId: { type: string }