using EntKube.SharedKernel.Contracts; using EntKube.SharedKernel.Domain; using Microsoft.AspNetCore.Mvc; namespace EntKube.Clusters.Features.ClusterSettings; /// /// Maps the cluster settings endpoints: /// GET /api/clusters/{id}/settings — read current settings from the live cluster /// PUT /api/clusters/{id}/settings — update settings on the live cluster /// /// These endpoints let the UI's Settings tab fetch and save cluster-level /// configuration like allowed container registries without going through /// the component configure flow. /// public static class ClusterSettingsEndpoint { public static void Map(IEndpointRouteBuilder app) { app.MapGet("/api/clusters/{id:guid}/settings", async ( Guid id, [FromServices] GetClusterSettingsHandler handler, CancellationToken ct) => { Result result = await handler.HandleAsync(id, ct); if (result.IsFailure) { return Results.BadRequest(ApiResponse.Fail(result.Error!)); } return Results.Ok(ApiResponse.Ok(result.Value!)); }); app.MapPut("/api/clusters/{id:guid}/settings", async ( Guid id, [FromBody] UpdateClusterSettingsRequest request, [FromServices] UpdateClusterSettingsHandler handler, CancellationToken ct) => { Result result = await handler.HandleAsync(id, request, ct); if (result.IsFailure) { return Results.BadRequest(ApiResponse.Fail(result.Error!)); } return Results.Ok(ApiResponse.Ok(new { })); }); } }