package dev.lions.unionflow.client.service;

import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@RegisterRestClient(configKey = "unionflow-api")
@RegisterClientHeaders(dev.lions.unionflow.client.security.AuthHeaderFactory.class)
@Path("/api")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface LogsService {

    @GET
    @Path("/logs/search")
    List<Map<String, Object>> rechercherLogs(
        @QueryParam("level") String level,
        @QueryParam("source") String source,
        @QueryParam("userId") String userId,
        @QueryParam("startDate") String startDate,
        @QueryParam("endDate") String endDate,
        @QueryParam("keyword") String keyword,
        @QueryParam("page") @DefaultValue("0") int page,
        @QueryParam("size") @DefaultValue("50") int size
    );

    @GET
    @Path("/finance/audit-logs")
    List<Map<String, Object>> obtenirLogsAuditFinance(
        @QueryParam("organizationId") UUID organizationId,
        @QueryParam("startDate") String startDate,
        @QueryParam("endDate") String endDate,
        @QueryParam("operation") String operation,
        @QueryParam("entityType") String entityType,
        @QueryParam("severity") String severity,
        @QueryParam("limit") @DefaultValue("100") int limit
    );

    @GET
    @Path("/finance/audit-logs/anomalies")
    List<Map<String, Object>> obtenirAnomalies(
        @QueryParam("organizationId") UUID organizationId,
        @QueryParam("startDate") String startDate,
        @QueryParam("endDate") String endDate
    );

    @POST
    @Path("/finance/audit-logs/export")
    byte[] exporterLogsAudit(Map<String, Object> request);

    @GET
    @Path("/monitoring/metrics")
    Map<String, Object> obtenirMetriques();

    @GET
    @Path("/v1/dashboard/health")
    Map<String, Object> obtenirSanteSysteme();
}
