Files
gitks/api/repo/topics.rs
T
zhenyi cec6dce955 feat(api): expand API endpoints for repo, PR, user, workspace management
- Add git operation endpoints: archive, compare branches, diff, tree,
  repository extras
- Add repo endpoints: contributors, delete fork, get branch/commit
  status/deploy key/invitation/member/release/tag/webhook, topics,
  release assets, webhook deliveries/retry
- Add PR endpoints: review requests, templates
- Add user endpoints: block/unblock, follow/unfollow, presence,
  personal access tokens, account restore
- Add workspace endpoints: billing history, approvals, domains,
  integrations, invitations, members, webhooks, restore
- Add internal API, notification API, IM API modules
- Update route configuration and OpenAPI spec
2026-06-10 18:49:27 +08:00

68 lines
2.0 KiB
Rust

use actix_web::{HttpResponse, web};
use serde::Deserialize;
use utoipa::IntoParams;
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::service::AppService;
use crate::service::repo::core::UpdateRepoParams;
use crate::session::Session;
#[derive(Debug, Deserialize, IntoParams)]
pub struct PathParams {
pub workspace_name: String,
pub repo_name: String,
}
#[derive(Debug, Deserialize, utoipa::ToSchema)]
pub struct TopicsBody {
pub topics: Vec<String>,
}
#[utoipa::path(
put,
path = "/api/v1/workspaces/{workspace_name}/repos/{repo_name}/topics",
tag = "Repos",
operation_id = "repoUpdateTopics",
params(PathParams),
request_body(content = TopicsBody),
responses(
(status = 200, description = "Topics updated", body = ApiResponse<Vec<String>>),
(status = 401, description = "Unauthorized", body = ApiErrorResponse),
(status = 404, description = "Repo not found", body = ApiErrorResponse),
),
security(("session_cookie" = []))
)]
pub async fn update_topics(
service: web::Data<AppService>,
session: Session,
path: web::Path<PathParams>,
body: web::Json<TopicsBody>,
) -> Result<HttpResponse, AppError> {
let result = service
.repo
.repo_update(
&session,
&path.workspace_name,
&path.repo_name,
UpdateRepoParams {
name: None,
description: None,
visibility: None,
default_branch: None,
topics: Some(body.topics.clone()),
homepage: None,
has_issues: None,
has_wiki: None,
has_pull_requests: None,
allow_forking: None,
allow_merge_commit: None,
allow_squash_merge: None,
allow_rebase_merge: None,
delete_branch_on_merge: None,
},
)
.await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(result.topics)))
}