@@ -94,8 +94,11 @@ def api_kwargs(self, **kwargs):
94
94
if obj_list :
95
95
kw ["url" ] = self .endpoint
96
96
else :
97
+ subresource = kwargs .pop ("subresource" , None ) or ""
97
98
operation = kwargs .pop ("operation" , "" )
98
- kw ["url" ] = op .normpath (op .join (self .endpoint , self .name , operation ))
99
+ kw ["url" ] = op .normpath (
100
+ op .join (self .endpoint , self .name , subresource , operation )
101
+ )
99
102
params = kwargs .pop ("params" , None )
100
103
if params is not None :
101
104
query_string = urlencode (params )
@@ -138,25 +141,26 @@ def watch(self):
138
141
.watch ()
139
142
)
140
143
141
- def patch (self , strategic_merge_patch ):
144
+ def patch (self , strategic_merge_patch , * , subresource = None ):
142
145
"""
143
146
Patch the Kubernetes resource by calling the API with a "strategic merge" patch.
144
147
"""
145
148
r = self .api .patch (
146
149
** self .api_kwargs (
150
+ subresource = subresource ,
147
151
headers = {"Content-Type" : "application/merge-patch+json" },
148
152
data = json .dumps (strategic_merge_patch ),
149
153
)
150
154
)
151
155
self .api .raise_for_status (r )
152
156
self .set_obj (r .json ())
153
157
154
- def update (self , is_strategic = True ):
158
+ def update (self , is_strategic = True , * , subresource = None ):
155
159
"""
156
160
Update the Kubernetes resource by calling the API (patch)
157
161
"""
158
162
self .obj = obj_merge (self .obj , self ._original_obj , is_strategic )
159
- self .patch (self .obj )
163
+ self .patch (self .obj , subresource = subresource )
160
164
161
165
def delete (self , propagation_policy : str = None ):
162
166
"""
0 commit comments