@@ -279,10 +279,24 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
279
279
return self ._stream_helper (response , decode = decode )
280
280
281
281
@utils .minimum_version ('1.31' )
282
- def prune_builds (self ):
282
+ def prune_builds (self , filters = None , keep_storage = None , all = None ):
283
283
"""
284
284
Delete the builder cache
285
285
286
+ Args:
287
+ filters (dict): Filters to process on the prune list.
288
+ Needs Docker API v1.39+
289
+ Available filters:
290
+ - dangling (bool): When set to true (or 1), prune only
291
+ unused and untagged images.
292
+ - until (str): Can be Unix timestamps, date formatted
293
+ timestamps, or Go duration strings (e.g. 10m, 1h30m) computed
294
+ relative to the daemon's local time.
295
+ keep_storage (int): Amount of disk space in bytes to keep for cache.
296
+ Needs Docker API v1.39+
297
+ all (bool): Remove all types of build cache.
298
+ Needs Docker API v1.39+
299
+
286
300
Returns:
287
301
(dict): A dictionary containing information about the operation's
288
302
result. The ``SpaceReclaimed`` key indicates the amount of
@@ -293,7 +307,20 @@ def prune_builds(self):
293
307
If the server returns an error.
294
308
"""
295
309
url = self ._url ("/build/prune" )
296
- return self ._result (self ._post (url ), True )
310
+ if (filters , keep_storage , all ) != (None , None , None ) \
311
+ and utils .version_lt (self ._version , '1.39' ):
312
+ raise errors .InvalidVersion (
313
+ '`filters`, `keep_storage`, and `all` args are only available '
314
+ 'for API version > 1.38'
315
+ )
316
+ params = {}
317
+ if filters is not None :
318
+ params ['filters' ] = utils .convert_filters (filters )
319
+ if keep_storage is not None :
320
+ params ['keep-storage' ] = keep_storage
321
+ if all is not None :
322
+ params ['all' ] = all
323
+ return self ._result (self ._post (url , params = params ), True )
297
324
298
325
def _set_auth_headers (self , headers ):
299
326
log .debug ('Looking for auth config' )
0 commit comments