Publish a DRAFT CapacityPlan
POST/capacity-plans/:id/publications
Moves the plan DRAFT -> PUBLISHED, saves it and queues, in the same database transaction, CapacityPlanPublished plus -- only when the plan has a shortage -- CapacityShortageDetected and BottleneckDetected in the transactional outbox. A relay publishes them to Kafka as CloudEvents (see asyncapi.yaml). Publishing twice is never silent: the second call is a 409 and queues nothing. Publishing supersedes (docs/adr/0024 decision 3): when another plan of the same site_id, location, path_id and window is PUBLISHED, that older plan becomes SUPERSEDED (superseded_by: this plan) and CapacityPlanSuperseded is queued first, in the same transaction. A SUPERSEDED plan is never published again (409).
Request
Responses
- 200
- 400
- 404
- 409
- 500
Plan published.
Response Headers
Present, with the value "true", only when the answer is a replay of an earlier request with the same Idempotency-Key.
Malformed request, or the Idempotency-Key header is missing (idempotency-key-required) or malformed (idempotency-key-invalid).
No CapacityPlan exists under id.
The plan is already PUBLISHED (capacity-plan-already-published) or was SUPERSEDED by a newer published plan of its window (capacity-plan-superseded) -- both FINAL, stored and replayed under the key; a concurrent publish of the same site, location, path and window won twice (version-conflict -- RETRYABLE: not stored, the key is released, retry it under the SAME key); or the Idempotency-Key was already used with a different request (idempotency-key-reused).
An unexpected failure (a store or outbox error). Answered as problem+json (internal-error). A 5xx answer is never stored under an Idempotency-Key and rolls back the aggregate change and its outbox rows, so the retry re-executes.