diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java index f36119e478e..32ec6b52487 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/BaseClient.java @@ -21,6 +21,7 @@ import okhttp3.ConnectionPool; import okhttp3.Dispatcher; import okhttp3.OkHttpClient; +import io.fabric8.kubernetes.api.model.APIGroup; import io.fabric8.kubernetes.api.model.APIGroupList; import io.fabric8.kubernetes.api.model.APIResourceList; import io.fabric8.kubernetes.api.model.RootPaths; @@ -166,6 +167,11 @@ public APIGroupList getApiGroups() { return newBaseOperation(httpClient, configuration).restCall(APIGroupList.class, APIS); } + @Override + public APIGroup getApiGroup(String name) { + return newBaseOperation(httpClient, configuration).restCall(APIGroup.class, APIS, name); + } + @Override public APIResourceList getApiResources(String groupVersion) { return newBaseOperation(httpClient, configuration).restCall(APIResourceList.class, APIS, groupVersion); diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java index 660a6345962..15032dbd753 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/Client.java @@ -16,6 +16,7 @@ package io.fabric8.kubernetes.client; +import io.fabric8.kubernetes.api.model.APIGroup; import io.fabric8.kubernetes.api.model.APIGroupList; import io.fabric8.kubernetes.api.model.APIResourceList; import io.fabric8.kubernetes.api.model.RootPaths; @@ -59,6 +60,12 @@ public interface Client extends ConfigAware, Closeable { */ APIGroupList getApiGroups(); + /** + * Return a single api group + * @return the {@link APIGroup} metadata + */ + APIGroup getApiGroup(String name); + /** * Return the api resource metadata for the given groupVersion * @param the groupVersion - group/version diff --git a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java index 2e551584781..724d2488fa5 100644 --- a/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java +++ b/kubernetes-itests/src/test/java/io/fabric8/kubernetes/ApiGroupResourceListsIT.java @@ -16,6 +16,7 @@ package io.fabric8.kubernetes; +import io.fabric8.kubernetes.api.model.APIGroup; import io.fabric8.kubernetes.api.model.APIGroupList; import io.fabric8.kubernetes.api.model.APIResourceList; import io.fabric8.kubernetes.client.KubernetesClient; @@ -26,6 +27,8 @@ import org.junit.Test; import org.junit.runner.RunWith; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @RunWith(ArquillianConditionalRunner.class) @@ -45,6 +48,17 @@ public void testApiGroups() throws InterruptedException { assertTrue(list.getGroups().stream().anyMatch(g -> "apps".equals(g.getName()))); } + @Test + public void testApiGroup() throws InterruptedException { + APIGroup group = client.getApiGroup("apps"); + + assertNotNull(group); + + group = client.getApiGroup("apps-that-wont-exist"); + + assertNull(group); + } + @Test public void testApiResources() throws InterruptedException { APIResourceList list = client.getApiResources("apps/v1");