package dev.lions.user.manager.api;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

import java.util.List;

/**
 * Interface JAX-RS pour la gestion des realms Keycloak.
 */
@Path("/api/realms")
@Produces(MediaType.APPLICATION_JSON)
@Tag(name = "Realms", description = "Gestion des realms Keycloak")
public interface RealmResourceApi {

    @GET
    @Path("/list")
    @Operation(summary = "Lister tous les realms", description = "Récupère la liste de tous les realms disponibles dans Keycloak")
    @APIResponses({
            @APIResponse(responseCode = "200", description = "Liste des realms", content = @Content(schema = @Schema(type = org.eclipse.microprofile.openapi.annotations.enums.SchemaType.ARRAY, implementation = String.class))),
            @APIResponse(responseCode = "500", description = "Erreur serveur")
    })
    List<String> getAllRealms();

    @GET
    @Path("/{realm}/clients")
    @Operation(summary = "Lister les clients d'un realm", description = "Récupère la liste des clientId de tous les clients d'un realm")
    @APIResponses({
            @APIResponse(responseCode = "200", description = "Liste des clients"),
            @APIResponse(responseCode = "500", description = "Erreur serveur")
    })
    List<String> getRealmClients(
            @Parameter(description = "Nom du realm") @PathParam("realm") String realmName);
}
