39 lines
1.1 KiB
Java
39 lines
1.1 KiB
Java
package dev.dinauer;
|
|
|
|
import dev.dinauer.utils.ClientProvider;
|
|
import io.fabric8.kubernetes.api.model.Pod;
|
|
import io.fabric8.kubernetes.api.model.Service;
|
|
import io.fabric8.kubernetes.client.KubernetesClient;
|
|
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
|
|
import io.quarkus.runtime.Startup;
|
|
import io.quarkus.security.Authenticated;
|
|
import jakarta.annotation.PostConstruct;
|
|
import jakarta.enterprise.context.ApplicationScoped;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.ws.rs.GET;
|
|
import jakarta.ws.rs.Path;
|
|
import jakarta.ws.rs.Produces;
|
|
import jakarta.ws.rs.QueryParam;
|
|
import jakarta.ws.rs.core.MediaType;
|
|
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
@Path("/services")
|
|
@Startup
|
|
@ApplicationScoped
|
|
@Authenticated
|
|
public class ServiceResource
|
|
{
|
|
@GET
|
|
@Produces(MediaType.APPLICATION_JSON)
|
|
public List<Service> getServices(@QueryParam("namespace") Optional<String> namespace)
|
|
{
|
|
if(namespace.isPresent())
|
|
{
|
|
return ClientProvider.getClient().services().inNamespace(namespace.get()).list().getItems();
|
|
}
|
|
return ClientProvider.getClient().services().list().getItems();
|
|
}
|
|
}
|