Some checks failed
Docker Build and Push / setup (push) Successful in 54s
API Docs (Node.js Express) / test (20) (push) Failing after 3m4s
API Docs (Node.js Express) / build (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 2m31s
Integration Tests / performance-tests (push) Has been skipped
API Gateway (Java Spring Boot) / test (21) (push) Failing after 4m18s
API Gateway (Java Spring Boot) / test (17) (push) Failing after 4m19s
API Gateway (Java Spring Boot) / build (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 1m51s
Docker Build and Push / build-push-service-adapters (push) Successful in 1m15s
Service Adapters (Python FastAPI) / test (3.13) (push) Failing after 1m58s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 3m17s
Service Adapters (Python FastAPI) / build (push) Has been skipped
Docker Build and Push / build-push-api-docs (push) Successful in 52s
Docker Build and Push / build-push-frontend (push) Successful in 45s
Docker Build and Push / build-push-api-gateway (push) Successful in 10m4s
74 lines
2.5 KiB
Java
74 lines
2.5 KiB
Java
package com.labfusion.controller;
|
|
|
|
import com.labfusion.model.DeviceState;
|
|
import com.labfusion.model.Event;
|
|
import com.labfusion.repository.DeviceStateRepository;
|
|
import com.labfusion.repository.EventRepository;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/system")
|
|
@CrossOrigin(origins = "*")
|
|
@Tag(name = "System Data", description = "APIs for system events, device states, and metrics")
|
|
public class SystemController {
|
|
|
|
@Autowired
|
|
private EventRepository eventRepository;
|
|
|
|
@Autowired
|
|
private DeviceStateRepository deviceStateRepository;
|
|
|
|
@GetMapping("/events")
|
|
public ResponseEntity<List<Event>> getEvents(
|
|
@RequestParam(required = false) String service,
|
|
@RequestParam(required = false) String eventType,
|
|
@RequestParam(required = false) Integer hours) {
|
|
|
|
List<Event> events;
|
|
|
|
if (service != null && hours != null) {
|
|
LocalDateTime since = LocalDateTime.now().minusHours(hours);
|
|
events = eventRepository.findRecentEventsByService(service, since);
|
|
} else if (service != null) {
|
|
events = eventRepository.findByService(service);
|
|
} else if (eventType != null) {
|
|
events = eventRepository.findByEventType(eventType);
|
|
} else {
|
|
events = eventRepository.findAll();
|
|
}
|
|
|
|
return ResponseEntity.ok(events);
|
|
}
|
|
|
|
@GetMapping("/device-states")
|
|
public ResponseEntity<List<DeviceState>> getDeviceStates(
|
|
@RequestParam(required = false) String entityId,
|
|
@RequestParam(required = false) String service) {
|
|
|
|
List<DeviceState> states;
|
|
|
|
if (entityId != null) {
|
|
states = deviceStateRepository.findByEntityId(entityId);
|
|
} else if (service != null) {
|
|
states = deviceStateRepository.findByService(service);
|
|
} else {
|
|
states = deviceStateRepository.findAll();
|
|
}
|
|
|
|
return ResponseEntity.ok(states);
|
|
}
|
|
|
|
@GetMapping("/metrics")
|
|
public ResponseEntity<Object> getSystemMetrics() {
|
|
// This would integrate with actual system monitoring
|
|
// For now, return a placeholder response
|
|
return ResponseEntity.ok().body("System metrics endpoint - to be implemented");
|
|
}
|
|
}
|