package dev.lions.user.manager.client.service;

import dev.lions.user.manager.dto.sync.HealthStatusDTO;
import dev.lions.user.manager.dto.sync.SyncResultDTO;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

/**
 * REST Client pour le service de synchronisation
 */
@Path("/api/sync")
@RegisterRestClient(configKey = "lions-user-manager-api")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface SyncServiceClient {

    @GET
    @Path("/health")
    HealthStatusDTO checkHealth(@QueryParam("realm") String realmName);

    @GET
    @Path("/health/keycloak")
    HealthStatusDTO checkKeycloakHealth();

    @POST
    @Path("/users")
    SyncResultDTO syncUsers(@QueryParam("realm") String realmName);

    @POST
    @Path("/roles")
    SyncResultDTO syncRoles(
        @QueryParam("realm") String realmName,
        @QueryParam("clientName") String clientName
    );

    @GET
    @Path("/exists/user/{username}")
    Boolean userExists(
        @PathParam("username") String username,
        @QueryParam("realm") String realmName
    );

    @GET
    @Path("/exists/role/{roleName}")
    Boolean roleExists(
        @PathParam("roleName") String roleName,
        @QueryParam("realm") String realmName,
        @QueryParam("typeRole") String typeRole,
        @QueryParam("clientName") String clientName
    );
}

