Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: POST /api/notify/dry-run runs a draft flows document

This commit is contained in:
atlas 2026-10-25 01:51:16 +02:00 • committed by mara
commit e8538d8690

View file

@ -165,6 +165,20 @@ pub(crate) fn unreadable(why: &DecodeError) -> ProblemDetails {
)
}
/// The document a body describes, or the first way it fails
/// [`Document::check`].
pub(crate) fn checked_document(
disabled_builtins: Vec<String>,
flows: Vec<Flow>,
) -> Result<Document, String> {
let doc = Document {
version: notify_flows::VERSION,
disabled_builtins,
flows,
};
doc.check().map(|()| doc)
}
/// Replace the flows.
#[utoipa::path(
put,
@ -196,12 +210,7 @@ pub(crate) async fn put_flows(
body: Result<Json<PutFlows>, JsonRejection>,
) -> Result<Json<FlowsView>, ProblemDetails> {
let Json(put) = body.map_err(|e| error_problem(StatusCode::BAD_REQUEST, &e.body_text()))?;
let doc = Document {
version: notify_flows::VERSION,
disabled_builtins: put.disabled_builtins,
flows: put.flows,
};
doc.check()
let doc = checked_document(put.disabled_builtins, put.flows)
.map_err(|why| error_problem(StatusCode::BAD_REQUEST, &why))?;
let client = queue(&state).map_err(refused)?;
let store = open(&client).await.map_err(|e| queue_problem(&e))?;