use actix_web::{web, HttpResponse}; use serde::Deserialize; use utoipa::IntoParams; use crate::api::response::{ApiResponse, ApiErrorResponse}; use crate::error::AppError; use crate::models::prs::PrStatus; use crate::service::AppService; use crate::session::Session; #[derive(Debug, Deserialize, IntoParams)] pub struct PathParams { /// Workspace name (unique identifier) pub workspace_name: String, /// Repository name (unique within the workspace) pub repo_name: String, /// PR number (unique within the repository) pub number: i64, } /// Get PR status summary /// /// Returns the current status of a PR including checks state, mergeability, /// approval count, and file change statistics. /// Requires read access to the repository. #[utoipa::path( get, path = "/api/v1/workspaces/{workspace_name}/repos/{repo_name}/prs/{number}/status", tag = "Pull Requests", operation_id = "prGetStatus", params(PathParams), responses( (status = 200, description = "PR status retrieved successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 403, description = "Insufficient permissions", body = ApiErrorResponse), (status = 404, description = "PR or status not found", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security(("session_cookie" = [])) )] pub async fn get_status( service: web::Data, session: Session, path: web::Path, ) -> Result { let status = service .pr .pr_status(&session, &path.workspace_name, &path.repo_name, path.number) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(status))) }