@@ -64,6 +64,7 @@ func WorkloadRouter(
64
64
r .Post ("/{name}/edit" , routes .updateWorkload )
65
65
r .Post ("/{name}/stop" , routes .stopWorkload )
66
66
r .Post ("/{name}/restart" , routes .restartWorkload )
67
+ r .Get ("/{name}/status" , routes .getWorkloadStatus )
67
68
r .Get ("/{name}/logs" , routes .getLogsForWorkload )
68
69
r .Get ("/{name}/export" , routes .exportWorkload )
69
70
r .Delete ("/{name}" , routes .deleteWorkload )
@@ -558,6 +559,45 @@ func (s *WorkloadRoutes) getLogsForWorkload(w http.ResponseWriter, r *http.Reque
558
559
}
559
560
}
560
561
562
+ // getWorkloadStatus
563
+ //
564
+ // @Summary Get workload status
565
+ // @Description Get the current status of a specific workload
566
+ // @Tags workloads
567
+ // @Produce json
568
+ // @Param name path string true "Workload name"
569
+ // @Success 200 {object} workloadStatusResponse
570
+ // @Failure 404 {string} string "Not Found"
571
+ // @Router /api/v1beta/workloads/{name}/status [get]
572
+ func (s * WorkloadRoutes ) getWorkloadStatus (w http.ResponseWriter , r * http.Request ) {
573
+ ctx := r .Context ()
574
+ name := chi .URLParam (r , "name" )
575
+
576
+ workload , err := s .workloadManager .GetWorkload (ctx , name )
577
+ if err != nil {
578
+ if errors .Is (err , runtime .ErrWorkloadNotFound ) {
579
+ http .Error (w , "Workload not found" , http .StatusNotFound )
580
+ return
581
+ } else if errors .Is (err , wt .ErrInvalidWorkloadName ) {
582
+ http .Error (w , "Invalid workload name: " + err .Error (), http .StatusBadRequest )
583
+ return
584
+ }
585
+ logger .Errorf ("Failed to get workload: %v" , err )
586
+ http .Error (w , "Failed to get workload" , http .StatusInternalServerError )
587
+ return
588
+ }
589
+
590
+ response := workloadStatusResponse {
591
+ Status : workload .Status ,
592
+ }
593
+
594
+ w .Header ().Set ("Content-Type" , "application/json" )
595
+ if err := json .NewEncoder (w ).Encode (response ); err != nil {
596
+ http .Error (w , "Failed to marshal workload status" , http .StatusInternalServerError )
597
+ return
598
+ }
599
+ }
600
+
561
601
// exportWorkload
562
602
//
563
603
// @Summary Export workload configuration
@@ -603,6 +643,14 @@ type workloadListResponse struct {
603
643
Workloads []core.Workload `json:"workloads"`
604
644
}
605
645
646
+ // workloadStatusResponse represents the response for getting workload status
647
+ //
648
+ // @Description Response containing workload status information
649
+ type workloadStatusResponse struct {
650
+ // Current status of the workload
651
+ Status runtime.WorkloadStatus `json:"status"`
652
+ }
653
+
606
654
// updateRequest represents the request to update an existing workload
607
655
//
608
656
// @Description Request to update an existing workload (name cannot be changed)
0 commit comments