<p>I am trying to get a list of all possible resources of a given cluster using the fabric8 openshift-client (or kubernetes-client), so trying to obtain same as command <code>oc api-resources</code>. So far I am able to get the list of apiGroups with a code like this</p>
<pre class="lang-java prettyprint-override"><code>OpenShiftClient client = new DefaultOpenshiftClient();
List&lt;APIService&gt; apiservices = client.apiServices().list().getItems();
for (APIService apiservice : apiservices){
  System.out.println(apiservice.getSpec().getGroup());
}
</code></pre>
<p>Now I am looking how to obtain a list of Resources (and I see in the code there is a class names APIResource) belonging to a particular group, but I am not able to find it.</p>
<p>EDIT:</p>
<p>While I see in code there is a getApiResources() method, for some reason this is not shipped with the quarkus-kubernetes-client (or quarkus-openshift-client) on Quarkus 2.3</p>
<p>As a workaround I have used kubernetes API using RestClient to access /apis/{group}/{version} and /api/v1</p>

<p>Fabric8 Kubernetes Client has <code>client.getApiGroups()</code> method to get a list of all available api groups. You can then get api resource for each version using <code>client.getApiResources()</code> to get output like <code>kubectl api-resources</code>.</p>
<p>I was able to do it with something like this. I am using Fabric8 Kubernetes Client v5.9.0:</p>
<pre class="lang-java prettyprint-override"><code>try (KubernetesClient client = new DefaultKubernetesClient()) {
  APIGroupList apiGroupList = client.getApiGroups();

  apiGroupList.getGroups()
    .forEach(group -&gt; group.getVersions().forEach(gv -&gt; {
      APIResourceList apiResourceList = client.getApiResources(gv.getGroupVersion());
      apiResourceList.getResources()
        .stream()
        .filter(r -&gt; !r.getName().contains(&quot;/&quot;))
        .forEach(r -&gt; System.out.printf(&quot;%s  %s   %s   %s   %s%n&quot;, r.getName(), String.join( &quot;,&quot;, r.getShortNames()), 
          gv.getGroupVersion(), r.getNamespaced(), r.getKind()));
    }));
}
</code></pre>
