Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover api classes #871

Closed
caruccio opened this issue Jul 10, 2019 · 4 comments
Closed

Discover api classes #871

caruccio opened this issue Jul 10, 2019 · 4 comments
Assignees

Comments

@caruccio
Copy link

Hi.

There are an canonical way to use client.ApisApi().get_api_versions().preferred_version to import kubernetes.client.*Api?

Something in this line:

apis = kubernetes.client.ApisApi(kubernetes.client.ApiClient())
for group in apis.get_api_versions().groups:
    api_class = api_class_from_preferred_version(group.preferred_version)
@roycaihw
Copy link
Member

cc @yliaog

@yliaog
Copy link
Contributor

yliaog commented Jul 16, 2019

what problem do you see in the sample code provided?

@yliaog yliaog self-assigned this Jul 16, 2019
@roycaihw
Copy link
Member

sounds like you want to create API class objects from the discovery API. Currently the discovery API gives you the basic API group version info:

$ python examples/example3.py 
Supported APIs (* is preferred version):
core                 v1
apiregistration.k8s.io                   *v1,v1beta1
extensions                               v1beta1
apps                                     v1
events.k8s.io                            v1beta1
authentication.k8s.io                    *v1,v1beta1
authorization.k8s.io                     *v1,v1beta1
autoscaling                              *v1,v2beta1,v2beta2
batch                                    *v1,v1beta1
certificates.k8s.io                      v1beta1
networking.k8s.io                        *v1,v1beta1
policy                                   v1beta1
rbac.authorization.k8s.io                *v1,v1beta1
storage.k8s.io                           *v1,v1beta1
admissionregistration.k8s.io             *v1,v1beta1
apiextensions.k8s.io                     v1beta1
scheduling.k8s.io                        *v1,v1beta1
coordination.k8s.io                      *v1,v1beta1
node.k8s.io                              v1beta1

and you want to map them to e.g.

from kubernetes import client
    # given "extensions, v1beta1"
    api_class = client.ExtensionsV1beta1Api()

the upcoming dynamic client could be one way if you want to talk to all the APIs from a live discovery doc dynamically

@caruccio
Copy link
Author

@roycaihw dynamic client is exactly what I'm looking for. Just subscribed to it.

Closing this one for now.
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants