55 lines
1.2 KiB
Java
55 lines
1.2 KiB
Java
package de.tavolio.realm.client;
|
|
|
|
import de.tavolio.realm.RealmEntity;
|
|
import de.tavolio.realm.RealmService;
|
|
import jakarta.enterprise.context.RequestScoped;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.ws.rs.*;
|
|
import jakarta.ws.rs.core.MediaType;
|
|
|
|
import java.util.List;
|
|
|
|
@RequestScoped
|
|
@Consumes(MediaType.APPLICATION_JSON)
|
|
public class ClientResource
|
|
{
|
|
@PathParam("realm-key")
|
|
String realmKey;
|
|
|
|
@Inject
|
|
ClientRepo repo;
|
|
|
|
@Inject
|
|
ClientService clientService;
|
|
|
|
@Inject
|
|
RealmService realmService;
|
|
|
|
@GET
|
|
public List<Client> get()
|
|
{
|
|
RealmEntity realm = realmService.requireByKey(realmKey);
|
|
return ClientMapper.map(repo.findByRealm(realm));
|
|
}
|
|
|
|
@POST
|
|
public Client post(ClientCreation creation)
|
|
{
|
|
return clientService.create(realmKey, creation);
|
|
}
|
|
|
|
@Path("/{client-name}")
|
|
@PUT
|
|
public Client put(@PathParam("client-name") String clientName, Client client)
|
|
{
|
|
return clientService.update(realmKey, clientName, client);
|
|
}
|
|
|
|
@Path("/{client-name}")
|
|
@DELETE
|
|
public void delete(@PathParam("client-name") String clientName)
|
|
{
|
|
clientService.delete(realmKey, clientName);
|
|
}
|
|
}
|