Skip to content
Clone
a06673b
28 lines 946 B Rust
use axum::Json;
use axum::extract::{Path, State};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::branch_protection::{BranchProtectionView, EditBranchProtectionOption};
#[utoipa::path(
patch,
path = "/repo/{channel_id}/{repo_id}/branch_protections/{policy_id}",
tag = "repo",
request_body = EditBranchProtectionOption,
responses((status = 200, description = "Edit a branch protection", body = BranchProtectionView)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, policy_id)): Path<(Uuid, Uuid, Uuid)>,
Json(input): Json<EditBranchProtectionOption>,
) -> RepoResult<Json<BranchProtectionView>> {
let view = svc
.edit_branch_protection(claims.sub, repo_id, policy_id, input)
.await?;
Ok(Json(view))
}