@@ -118,6 +118,10 @@ pub fn routers() -> Router<AppState> {
118118 )
119119 . route ( "/retry-build" , post ( build_retry_handler) )
120120 . route ( "/v2/health" , get ( health_check_handler) )
121+ . route ( "/v2/task-retry/{id}" , post ( task_retry_handler) )
122+ . route ( "/v2/task/{cl}" , get ( task_get_handler) )
123+ . route ( "/v2/build-event/{task-id}" , get ( build_event_get_handler) )
124+ . route ( "/v2/target/{task-id}" , get ( target_get_handler) )
121125}
122126
123127/// Start queue management background task (event-driven + periodic cleanup)
@@ -1867,6 +1871,129 @@ async fn immediate_work(
18671871 }
18681872}
18691873
1874+ #[ derive( ToSchema , Serialize ) ]
1875+ pub struct MessageResponse {
1876+ pub message : String ,
1877+ }
1878+
1879+ #[ derive( ToSchema , Serialize ) ]
1880+ pub struct BuildEventDTO {
1881+ pub id : String ,
1882+ pub task_id : String ,
1883+ pub retry_count : i32 ,
1884+ pub exit_code : Option < i32 > ,
1885+ pub log : Option < String > ,
1886+ pub log_output_file : String ,
1887+ pub start_at : String ,
1888+ pub end_at : Option < String > ,
1889+ }
1890+
1891+ #[ derive( ToSchema , Serialize ) ]
1892+ pub struct OrionTaskDTO {
1893+ pub id : String ,
1894+ pub changes : String ,
1895+ pub repo_name : String ,
1896+ pub cl : String ,
1897+ pub created_at : String ,
1898+ }
1899+
1900+ #[ derive( ToSchema , Serialize ) ]
1901+ pub struct BuildTargetDTO {
1902+ pub id : String ,
1903+ pub task_id : String ,
1904+ pub path : String ,
1905+ pub target_state : String ,
1906+ }
1907+
1908+ #[ utoipa:: path(
1909+ post,
1910+ path = "/v2/task-retry/{id}" ,
1911+ params( ( "id" = String , description = "Task ID to retry task" ) ) ,
1912+ responses(
1913+ ( status = 200 , description = "Inserted queque the task" , body = MessageResponse ) ,
1914+ ( status = 400 , description = "ID format error" , body = MessageResponse ) ,
1915+ ( status = 404 , description = "Not found this task ID" , body = MessageResponse ) ,
1916+ )
1917+ ) ]
1918+ pub async fn task_retry_handler (
1919+ State ( _state) : State < AppState > ,
1920+ Path ( _id) : Path < String > ,
1921+ ) -> impl IntoResponse {
1922+ let result_message = MessageResponse {
1923+ message : "todo" . to_string ( ) ,
1924+ } ;
1925+ (
1926+ StatusCode :: BAD_REQUEST ,
1927+ serde_json:: to_string ( & result_message) . unwrap ( ) ,
1928+ )
1929+ }
1930+
1931+ #[ utoipa:: path(
1932+ get,
1933+ path = "v2/task/{cl}" ,
1934+ params( ( "cl" = String , Path , description = "cl" ) ) ,
1935+ responses(
1936+ ( status = 200 , description = "Get task successfully" , body = OrionTaskDTO ) ,
1937+ ( status = 404 , description = "Not found task" , body = MessageResponse ) ,
1938+ )
1939+ ) ]
1940+ pub async fn task_get_handler (
1941+ State ( _state) : State < AppState > ,
1942+ Path ( _cl) : Path < String > ,
1943+ ) -> impl IntoResponse {
1944+ let result_message = MessageResponse {
1945+ message : "todo" . to_string ( ) ,
1946+ } ;
1947+ (
1948+ StatusCode :: NOT_IMPLEMENTED ,
1949+ serde_json:: to_string ( & result_message) . unwrap ( ) ,
1950+ )
1951+ }
1952+
1953+ #[ utoipa:: path(
1954+ get,
1955+ path = "v2/build-event/{task-id}" ,
1956+ params( ( "task-id" = String , Path , description = "Task ID" ) ) ,
1957+ responses(
1958+ ( status = 200 , description = "Get build event successfully" , body = BuildEventDTO ) ,
1959+ ( status = 404 , description = "Not found task" , body = MessageResponse ) ,
1960+ )
1961+ ) ]
1962+ pub async fn build_event_get_handler (
1963+ State ( _state) : State < AppState > ,
1964+ Path ( _cl) : Path < String > ,
1965+ ) -> impl IntoResponse {
1966+ let result_message = MessageResponse {
1967+ message : "todo" . to_string ( ) ,
1968+ } ;
1969+ (
1970+ StatusCode :: NOT_IMPLEMENTED ,
1971+ serde_json:: to_string ( & result_message) . unwrap ( ) ,
1972+ )
1973+ }
1974+
1975+ #[ utoipa:: path(
1976+ get,
1977+ path = "v2/target/{task-id}" ,
1978+ params( ( "task-id" = String , Path , description = "Task ID" ) ) ,
1979+ responses(
1980+ ( status = 200 , description = "Get target successfully" , body = BuildTargetDTO ) ,
1981+ ( status = 404 , description = "Not found task" , body = MessageResponse ) ,
1982+ )
1983+ ) ]
1984+ pub async fn target_get_handler (
1985+ State ( _state) : State < AppState > ,
1986+ Path ( _task_id) : Path < String > ,
1987+ ) -> impl IntoResponse {
1988+ let result_message = MessageResponse {
1989+ message : "todo" . to_string ( ) ,
1990+ } ;
1991+ (
1992+ StatusCode :: NOT_IMPLEMENTED ,
1993+ serde_json:: to_string ( & result_message) . unwrap ( ) ,
1994+ )
1995+ }
1996+
18701997#[ cfg( test) ]
18711998mod tests {
18721999 /// Test random number generation for worker selection
0 commit comments