@@ -169,39 +169,41 @@ def patch(self, resource, body=None, name=None, namespace=None, **kwargs):
169
169
if resource .namespaced :
170
170
namespace = self .ensure_namespace (resource , namespace , body )
171
171
172
- path = resource .path (name = name , namespace = namespace , ** kwargs )
172
+ path = resource .path (name = name , namespace = namespace )
173
173
174
174
content_type = self .client .\
175
175
select_header_content_type (['application/json-patch+json' , 'application/merge-patch+json' , 'application/strategic-merge-patch+json' ])
176
176
177
- return self .request ('patch' , path , body = body , content_type = content_type )
178
-
177
+ return self .request ('patch' , path , body = body , content_type = content_type , ** kwargs )
178
+
179
+ def extract_query_params (self , params ):
180
+ valid_params = {
181
+ 'watch' : 'watch' ,
182
+ 'limit' : 'limit' ,
183
+ 'pretty' : 'pretty' ,
184
+ '_continue' : 'continue' ,
185
+ 'field_selector' : 'fieldSelector' ,
186
+ 'label_selector' : 'labelSelector' ,
187
+ 'timeout_seconds' : 'timeoutSeconds' ,
188
+ 'resource_version' : 'resourceVersion' ,
189
+ 'orphan_dependents' : 'orphanDependents' ,
190
+ 'propagation_policy' : 'propagationPolicy' ,
191
+ 'grace_period_seconds' : 'gracePeriodSeconds' ,
192
+ 'include_uninitialized' : 'includeUninitialized' ,
193
+ }
194
+ return [
195
+ (query_param , params [name ])
196
+ for name , query_param in valid_params .items () if params .get (name )
197
+ ]
179
198
180
199
def request (self , method , path , body = None , ** params ):
181
200
182
201
if not path .startswith ('/' ):
183
202
path = '/' + path
184
203
185
204
path_params = params .get ('path_params' , {})
186
- query_params = params .get ('query_params' , [])
187
- if params .get ('pretty' ):
188
- query_params .append (('pretty' , params ['pretty' ]))
189
- if params .get ('_continue' ):
190
- query_params .append (('continue' , params ['_continue' ]))
191
- if params .get ('include_uninitialized' ):
192
- query_params .append (('includeUninitialized' , params ['include_uninitialized' ]))
193
- if params .get ('field_selector' ):
194
- query_params .append (('fieldSelector' , params ['field_selector' ]))
195
- if params .get ('label_selector' ):
196
- query_params .append (('labelSelector' , params ['label_selector' ]))
197
- if params .get ('limit' ):
198
- query_params .append (('limit' , params ['limit' ]))
199
- if params .get ('resource_version' ):
200
- query_params .append (('resourceVersion' , params ['resource_version' ]))
201
- if params .get ('timeout_seconds' ):
202
- query_params .append (('timeoutSeconds' , params ['timeout_seconds' ]))
203
- if params .get ('watch' ):
204
- query_params .append (('watch' , params ['watch' ]))
205
+ query_params = self .extract_query_params (params )
206
+ query_params .extend (params .get ('query_params' , []))
205
207
206
208
header_params = params .get ('header_params' , {})
207
209
form_params = []
@@ -268,9 +270,7 @@ def __init__(self, prefix=None, group=None, api_version=None, kind=None,
268
270
269
271
@property
270
272
def group_version (self ):
271
- if self .group :
272
- return '{}/{}' .format (self .group , self .api_version )
273
- return self .api_version
273
+ return '/' .join (filter (None , [self .group , self .api_version ]))
274
274
275
275
def __repr__ (self ):
276
276
return '<{}({}/{}>)' .format (self .__class__ .__name__ , self .group_version , self .name )
@@ -372,7 +372,7 @@ def search(self, **kwargs):
372
372
kind: The kind of the resource
373
373
arbitrary arguments (see below), in random order
374
374
375
- The arbitrary arguments can be any valid attribute for a kubernetes.dynamic. Resource object
375
+ The arbitrary arguments can be any valid attribute for a Resource object
376
376
"""
377
377
return self .__search (self .__build_search (** kwargs ), self .__resources )
378
378
0 commit comments