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

kubernetes/client/apis/custom_objects_api.py is missing an update (PATCH) method #453

Closed
tommyvn opened this issue Feb 6, 2018 · 5 comments

Comments

@tommyvn
Copy link

tommyvn commented Feb 6, 2018

Short of monkey-patching kubernetes.client.CustomObjectsApi there appears to be no way to PATCH a Custom Resource.

I'd expect to see something similar to other APIs in the library, like

def patch_custom_resource_definition(self, name, body, **kwargs):
"""
partially update the specified CustomResourceDefinition
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.patch_custom_resource_definition(name, body, async=True)
>>> result = thread.get()
:param async bool
:param str name: name of the CustomResourceDefinition (required)
:param object body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:return: V1beta1CustomResourceDefinition
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return self.patch_custom_resource_definition_with_http_info(name, body, **kwargs)
else:
(data) = self.patch_custom_resource_definition_with_http_info(name, body, **kwargs)
return data
def patch_custom_resource_definition_with_http_info(self, name, body, **kwargs):
"""
partially update the specified CustomResourceDefinition
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.patch_custom_resource_definition_with_http_info(name, body, async=True)
>>> result = thread.get()
:param async bool
:param str name: name of the CustomResourceDefinition (required)
:param object body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:return: V1beta1CustomResourceDefinition
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['name', 'body', 'pretty']
all_params.append('async')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method patch_custom_resource_definition" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'name' is set
if ('name' not in params) or (params['name'] is None):
raise ValueError("Missing the required parameter `name` when calling `patch_custom_resource_definition`")
# verify the required parameter 'body' is set
if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `patch_custom_resource_definition`")
collection_formats = {}
path_params = {}
if 'name' in params:
path_params['name'] = params['name']
query_params = []
if 'pretty' in params:
query_params.append(('pretty', params['pretty']))
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', 'application/yaml', 'application/vnd.kubernetes.protobuf'])
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json-patch+json', 'application/merge-patch+json', 'application/strategic-merge-patch+json'])
# Authentication setting
auth_settings = ['BearerToken']
return self.api_client.call_api('/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/{name}', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='V1beta1CustomResourceDefinition',
auth_settings=auth_settings,
async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
does for deployments, but there are no methods in the custom objects API that enable a partial PATCH to the Kubernetes API :( #

@craigtracey
Copy link

I am encountering this as well. Not sure how this can be, as this code should have been auto-generated by swagger and PATCH is in the API specification.

@roycaihw
Copy link
Member

CustomObjectsApi is generated from spec in gen repo. PR is welcome :)

@craigtracey
Copy link

@roycaihw yes, I noticed this after I posted this comment. I have changes that I am testing now.

@craigtracey
Copy link

I have opened kubernetes-client/gen#53 to address this issue.

@roycaihw
Copy link
Member

kubernetes-client/gen#53 is merged. Closing this one

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