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

[DO NOT MERGE] Switch to openapi-generator #926

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion examples/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from kubernetes import config
from kubernetes.client import Configuration
from kubernetes.client.apis import core_v1_api
from kubernetes.client.api import core_v1_api
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? I get an error: ModuleNotFoundError: No module named 'kubernetes.client.api'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you print the package info in your code, to see if it's using the updated code from this pull? I suspect you have official kubernetes package installed in your env and the code is using that by default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also try modifying your PYTHONPATH variable if you’re under Linux and prioritize searching for the k8s package locally.

from kubernetes.client.rest import ApiException
from kubernetes.stream import stream

Expand Down
2 changes: 2 additions & 0 deletions kubernetes/.openapi-generator/COMMIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Requested Commit: v3.3.4
Actual Commit: 2353d71d4b02be6dbabe25aac1a9e56eb3b812a2
1 change: 1 addition & 0 deletions kubernetes/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.4
1 change: 1 addition & 0 deletions kubernetes/.openapi-generator/swagger.json.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
393337ecad1a5cbe41ea480529ec8bb4c1f3b378703b4dcd2dbaf3a4ec68a3ba
23 changes: 13 additions & 10 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# kubernetes.client
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: v1.14.4
- API version: v1.14.6
- Package version: 10.0.0-snapshot
- Build package: io.swagger.codegen.languages.PythonClientCodegen
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

## Requirements.

Expand All @@ -17,9 +17,9 @@ Python 2.7 and 3.4+
If the python package is hosted on Github, you can install directly from Github

```sh
pip install git+https://github.com/kubernetes-client/python.git
pip install git+https://github.com/kubernetes-kubernetes.client/python.git
roycaihw marked this conversation as resolved.
Show resolved Hide resolved
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/kubernetes-client/python.git`)
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/kubernetes-kubernetes.client/python.git`)
roycaihw marked this conversation as resolved.
Show resolved Hide resolved

Then import the package:
```python
Expand Down Expand Up @@ -52,11 +52,13 @@ from kubernetes.client.rest import ApiException
from pprint import pprint

# Configure API key authorization: BearerToken
kubernetes.client.configuration.api_key['authorization'] = 'YOUR_API_KEY'
configuration = kubernetes.client.Configuration()
configuration.api_key['authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# kubernetes.client.configuration.api_key_prefix['authorization'] = 'Bearer'
# configuration.api_key_prefix['authorization'] = 'Bearer'

# create an instance of the API class
api_instance = kubernetes.client.AdmissionregistrationApi()
api_instance = kubernetes.client.AdmissionregistrationApi(kubernetes.client.ApiClient(configuration))

try:
api_response = api_instance.get_api_group()
Expand All @@ -68,7 +70,7 @@ except ApiException as e:

## Documentation for API Endpoints

All URIs are relative to *https://localhost*
All URIs are relative to *http://localhost*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https -> http?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the code generator. The documentation change looks reasonable to me, since by default the generated client doesn't have TLS set up


Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
Expand Down Expand Up @@ -1589,3 +1591,4 @@ Class | Method | HTTP request | Description




1,345 changes: 673 additions & 672 deletions kubernetes/client/__init__.py

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions kubernetes/client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from __future__ import absolute_import

# flake8: noqa

# import apis into api package
from kubernetes.client.api.admissionregistration_api import AdmissionregistrationApi
from kubernetes.client.api.admissionregistration_v1beta1_api import AdmissionregistrationV1beta1Api
from kubernetes.client.api.apiextensions_api import ApiextensionsApi
from kubernetes.client.api.apiextensions_v1beta1_api import ApiextensionsV1beta1Api
from kubernetes.client.api.apiregistration_api import ApiregistrationApi
from kubernetes.client.api.apiregistration_v1_api import ApiregistrationV1Api
from kubernetes.client.api.apiregistration_v1beta1_api import ApiregistrationV1beta1Api
from kubernetes.client.api.apis_api import ApisApi
from kubernetes.client.api.apps_api import AppsApi
from kubernetes.client.api.apps_v1_api import AppsV1Api
from kubernetes.client.api.apps_v1beta1_api import AppsV1beta1Api
from kubernetes.client.api.apps_v1beta2_api import AppsV1beta2Api
from kubernetes.client.api.auditregistration_api import AuditregistrationApi
from kubernetes.client.api.auditregistration_v1alpha1_api import AuditregistrationV1alpha1Api
from kubernetes.client.api.authentication_api import AuthenticationApi
from kubernetes.client.api.authentication_v1_api import AuthenticationV1Api
from kubernetes.client.api.authentication_v1beta1_api import AuthenticationV1beta1Api
from kubernetes.client.api.authorization_api import AuthorizationApi
from kubernetes.client.api.authorization_v1_api import AuthorizationV1Api
from kubernetes.client.api.authorization_v1beta1_api import AuthorizationV1beta1Api
from kubernetes.client.api.autoscaling_api import AutoscalingApi
from kubernetes.client.api.autoscaling_v1_api import AutoscalingV1Api
from kubernetes.client.api.autoscaling_v2beta1_api import AutoscalingV2beta1Api
from kubernetes.client.api.autoscaling_v2beta2_api import AutoscalingV2beta2Api
from kubernetes.client.api.batch_api import BatchApi
from kubernetes.client.api.batch_v1_api import BatchV1Api
from kubernetes.client.api.batch_v1beta1_api import BatchV1beta1Api
from kubernetes.client.api.batch_v2alpha1_api import BatchV2alpha1Api
from kubernetes.client.api.certificates_api import CertificatesApi
from kubernetes.client.api.certificates_v1beta1_api import CertificatesV1beta1Api
from kubernetes.client.api.coordination_api import CoordinationApi
from kubernetes.client.api.coordination_v1_api import CoordinationV1Api
from kubernetes.client.api.coordination_v1beta1_api import CoordinationV1beta1Api
from kubernetes.client.api.core_api import CoreApi
from kubernetes.client.api.core_v1_api import CoreV1Api
from kubernetes.client.api.custom_objects_api import CustomObjectsApi
from kubernetes.client.api.events_api import EventsApi
from kubernetes.client.api.events_v1beta1_api import EventsV1beta1Api
from kubernetes.client.api.extensions_api import ExtensionsApi
from kubernetes.client.api.extensions_v1beta1_api import ExtensionsV1beta1Api
from kubernetes.client.api.logs_api import LogsApi
from kubernetes.client.api.networking_api import NetworkingApi
from kubernetes.client.api.networking_v1_api import NetworkingV1Api
from kubernetes.client.api.networking_v1beta1_api import NetworkingV1beta1Api
from kubernetes.client.api.node_api import NodeApi
from kubernetes.client.api.node_v1alpha1_api import NodeV1alpha1Api
from kubernetes.client.api.node_v1beta1_api import NodeV1beta1Api
from kubernetes.client.api.policy_api import PolicyApi
from kubernetes.client.api.policy_v1beta1_api import PolicyV1beta1Api
from kubernetes.client.api.rbac_authorization_api import RbacAuthorizationApi
from kubernetes.client.api.rbac_authorization_v1_api import RbacAuthorizationV1Api
from kubernetes.client.api.rbac_authorization_v1alpha1_api import RbacAuthorizationV1alpha1Api
from kubernetes.client.api.rbac_authorization_v1beta1_api import RbacAuthorizationV1beta1Api
from kubernetes.client.api.scheduling_api import SchedulingApi
from kubernetes.client.api.scheduling_v1_api import SchedulingV1Api
from kubernetes.client.api.scheduling_v1alpha1_api import SchedulingV1alpha1Api
from kubernetes.client.api.scheduling_v1beta1_api import SchedulingV1beta1Api
from kubernetes.client.api.settings_api import SettingsApi
from kubernetes.client.api.settings_v1alpha1_api import SettingsV1alpha1Api
from kubernetes.client.api.storage_api import StorageApi
from kubernetes.client.api.storage_v1_api import StorageV1Api
from kubernetes.client.api.storage_v1alpha1_api import StorageV1alpha1Api
from kubernetes.client.api.storage_v1beta1_api import StorageV1beta1Api
from kubernetes.client.api.version_api import VersionApi
121 changes: 121 additions & 0 deletions kubernetes/client/api/admissionregistration_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# coding: utf-8

"""
Kubernetes

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

OpenAPI spec version: v1.14.6
Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re # noqa: F401

# python 2 and python 3 compatibility library
import six

from kubernetes.client.api_client import ApiClient


class AdmissionregistrationApi(object):
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech

Do not edit the class manually.
"""

def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client

def get_api_group(self, **kwargs): # noqa: E501
"""get_api_group # noqa: E501

get information of a group # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_api_group(async_req=True)
>>> result = thread.get()

:param async_req bool
:return: V1APIGroup
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_api_group_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_api_group_with_http_info(**kwargs) # noqa: E501
return data

def get_api_group_with_http_info(self, **kwargs): # noqa: E501
"""get_api_group # noqa: E501

get information of a group # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_api_group_with_http_info(async_req=True)
>>> result = thread.get()

:param async_req bool
:return: V1APIGroup
If the method is called asynchronously,
returns the request thread.
"""

local_var_params = locals()

all_params = [] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')

for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_api_group" % key
)
local_var_params[key] = val
del local_var_params['kwargs']

collection_formats = {}

path_params = {}

query_params = []

header_params = {}

form_params = []
local_var_files = {}

body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json', 'application/yaml', 'application/vnd.kubernetes.protobuf']) # noqa: E501

# Authentication setting
auth_settings = ['BearerToken'] # noqa: E501

return self.api_client.call_api(
'/apis/admissionregistration.k8s.io/', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='V1APIGroup', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
Loading