package dev.lions.unionflow.client.service;

import dev.lions.unionflow.client.security.AuthHeaderFactory;
import dev.lions.unionflow.server.api.dto.delegation.request.CreateRoleDelegationRequest;
import dev.lions.unionflow.server.api.dto.delegation.response.RoleDelegationResponse;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import java.util.List;
import java.util.UUID;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

/**
 * Client REST des délégations de rôle (Sprint 11 ⇄ backend Sprint 10).
 */
@RegisterRestClient(configKey = "unionflow-api")
@RegisterClientHeaders(AuthHeaderFactory.class)
@Path("/api/role-delegations")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface RoleDelegationRestClient {

  @GET
  @Path("/organisation/{orgId}")
  List<RoleDelegationResponse> listerParOrganisation(@PathParam("orgId") UUID orgId);

  @POST
  RoleDelegationResponse creer(
      CreateRoleDelegationRequest request,
      @QueryParam("rolesDelegataire") String rolesDelegataireCsv);

  @DELETE
  @Path("/{id}")
  RoleDelegationResponse revoquer(@PathParam("id") UUID id);
}
