34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
use crate::{ApiResponse, error::ApiError};
|
|
use actix_web::{HttpResponse, Result, web};
|
|
use service::AppService;
|
|
use session::Session;
|
|
|
|
#[utoipa::path(
|
|
post,
|
|
path = "/api/projects/{source_project}/repos/{repo_name}/transfer",
|
|
params(
|
|
("source_project" = String, Path),
|
|
("repo_name" = String, Path),
|
|
),
|
|
request_body = service::project::transfer_repo::TransferRepoParams,
|
|
responses(
|
|
(status = 200, description = "Transfer repo to another project", body = ApiResponse<service::project::transfer_repo::TransferRepoResponse>),
|
|
(status = 401, description = "Unauthorized"),
|
|
(status = 403, description = "Forbidden"),
|
|
(status = 404, description = "Not found"),
|
|
),
|
|
tag = "Project"
|
|
)]
|
|
pub async fn project_transfer_repo(
|
|
service: web::Data<AppService>,
|
|
session: Session,
|
|
path: web::Path<(String, String)>,
|
|
body: web::Json<service::project::transfer_repo::TransferRepoParams>,
|
|
) -> Result<HttpResponse, ApiError> {
|
|
let (source_project_name, repo_name) = path.into_inner();
|
|
let resp = service
|
|
.transfer_repo(&session, source_project_name, repo_name, body.into_inner())
|
|
.await?;
|
|
Ok(ApiResponse::ok(resp).to_response())
|
|
}
|