aboutsummaryrefslogtreecommitdiffstats
path: root/crates/configuration/src/server/http_svc/routes/typology/delete_typology.rs
blob: 0e85e295b5ce41b661f8b6576cdb199b6ddd1ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use axum::extract::{Query, State};
use tonic::IntoRequest;
use warden_core::configuration::typology::{
    DeleteTypologyConfigurationRequest, TypologyConfiguration,
    mutate_typologies_server::MutateTypologies,
};

use crate::{
    server::{error::AppError, http_svc::TAG_TYPOLOGIES, version::Version},
    state::AppHandle,
};

/// Get the typology configuration
#[utoipa::path(
    delete,
    path = "/{version}/typology",
    responses((
        status = OK,
        body = TypologyConfiguration
    )),
    params(
        ("version" = Version, Path, description = "API version, e.g., v1, v2, v3"),
        DeleteTypologyConfigurationRequest
    ),
    operation_id = "delete_typology_configuration", // https://github.com/juhaku/utoipa/issues/1170
    tag = TAG_TYPOLOGIES,
    )
]
#[axum::debug_handler]
#[tracing::instrument(skip(state))]
pub async fn delete_typology(
    State(state): State<AppHandle>,
    Query(params): Query<DeleteTypologyConfigurationRequest>,
) -> Result<axum::Json<TypologyConfiguration>, AppError> {
    let config = state
        .delete_typology_configuration(params.into_request())
        .await?
        .into_inner();

    Ok(axum::Json(config))
}