- .github
- devel
- doc
-
examples
-
dynamic-client
-
notebooks
-
watch
-
yaml_dir
- README.md
- __init__.py
- annotate_deployment.py
- api_discovery.py
- apply_from_dict.py
- apply_from_directory.py
- apply_from_single_file.py
- cluster_scoped_custom_object.py
- cronjob_crud.py
- deployment_create.py
- deployment_crud.py
- duration-gep2257.py
- in_cluster_config.py
- ingress_create.py
- job_crud.py
- multiple_clusters.py
- namespaced_custom_object.py
- node_labels.py
- out_of_cluster_config.py
- pick_kube_config_context.py
- pod_config_list.py
- pod_exec.py
- pod_portforward.py
- remote_cluster.py
- rollout-daemonset.py
- rollout-statefulset.py
-
dynamic-client
- kubernetes
- scripts
- .gitignore
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- MANIFEST.in
- OWNERS
- README.md
- SECURITY_CONTACTS
- code-of-conduct.md
- codecov.yml
- requirements.txt
- setup.cfg
- setup.py
- test-requirements.txt
- tox.ini
Explanation
This code defines a Python class ApiextensionsApi
that provides a way to interact with the Kubernetes API for the apiextensions.k8s.io
group. The code is generated from an OpenAPI spec and allows developers to work with custom resource definitions (CRDs) in Kubernetes.
Here’s a breakdown of the code:
1. Initialization:
- The
__init__
method initializes an instance of theApiextensionsApi
class, taking an optionalApiClient
object. If no client is provided, it creates a default one.
2. get_api_group()
method:
- This method is responsible for retrieving information about the
apiextensions.k8s.io
API group. - It performs a GET request to the
/apis/apiextensions.k8s.io/
endpoint. - The method accepts optional keyword arguments, including:
async_req
: Determines if the request should be executed asynchronously (returns a thread object)._preload_content
: Specifies whether to return the raw response data or decoded content._request_timeout
: Sets a timeout for the request.- The method returns a
V1APIGroup
object representing the API group information or the request thread ifasync_req
is True.
3. get_api_group_with_http_info()
method:
- This method is similar to
get_api_group()
, but it returns a tuple containing: - The
V1APIGroup
object. - The HTTP status code of the response.
- The HTTP headers of the response.
- It provides more detailed information about the API request and response.
Key points about the code:
- The
ApiClient
class, used to handle HTTP requests, is imported from thekubernetes.client.api_client
module. - The code leverages the
six
library for Python 2 and Python 3 compatibility. - The
ApiTypeError
andApiValueError
exceptions are raised if invalid input is provided. - The
get_api_group()
andget_api_group_with_http_info()
methods demonstrate a common pattern for working with the Kubernetes API through this library.
Example usage:
from kubernetes.client.api.apiextensions_api import ApiextensionsApi
api_instance = ApiextensionsApi()
api_group = api_instance.get_api_group()
# Access API group information
print(api_group.name)
print(api_group.version)
This code would fetch the API group information, print its name and version. This is just a basic example; the ApiextensionsApi
class offers various other methods for managing custom resource definitions within Kubernetes.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph