using ContainerDashboard.Services; using Microsoft.AspNetCore.Mvc; namespace ContainerDashboard; [ApiController] [Route("[controller]")] public class ServiceController : ControllerBase { private ILogger _logger; private IContainerService _service; public ServiceController(ILogger logger, IContainerService service) { _logger = logger; _service = service; } [HttpGet()] public async Task GetContainerList() { var containers = await _service.GetContainers(); return Ok(containers); } [HttpPost()] public async Task ToggleContainer([FromQuery] string containerName, string? containerNamespace, string action) { if (containerName == string.Empty || action == string.Empty) { return BadRequest("Missing required parameter"); } switch (action) { case "START": await _service.StartContainer(containerName, containerNamespace); break; case "STOP": await _service.StopContainer(containerName, containerNamespace); break; default: return BadRequest("Incorrect action"); } return Ok(); } }