@@ -282,6 +282,53 @@ async def prune(
282282 response = await self .docker ._query_json ("images/prune" , "POST" , params = params )
283283 return response
284284
285+ async def prune_builds (
286+ self ,
287+ * ,
288+ reserved_space : Optional [int ] = None ,
289+ max_used_space : Optional [int ] = None ,
290+ min_free_space : Optional [int ] = None ,
291+ all_builds : Optional [bool ] = None ,
292+ filters : Optional [Mapping [str , Any ]] = None ,
293+ ) -> Dict [str , Any ]:
294+ """
295+ Delete builder cache
296+
297+ Args:
298+ reserved_space: Amount of disk space in bytes to keep for cache.
299+ max_used_space: Maximum amount of disk space allowed to keep for cache.
300+ min_free_space: Target amount of free disk space after pruning.
301+ all_builds: When true, consider all unused build cache objects for pruning.
302+ When false, only consider dangling build cache objects for pruning.
303+ filters: Filter expressions to limit what types of build cache objects are pruned.
304+ Available filters:
305+ - until: Only remove build cache objects created before given timestamp.
306+ - id: id=<id>
307+ - parent: parent=<id>
308+ - type: type=<string>
309+ - description: description=<string>
310+ - inuse
311+ - shared
312+ - private
313+
314+ Returns:
315+ Dictionary containing information about deleted caches and space reclaimed
316+ """
317+ params : Dict [str , Any ] = {}
318+ if reserved_space is not None :
319+ params ["reserved-space" ] = reserved_space
320+ if max_used_space is not None :
321+ params ["max-used-space" ] = max_used_space
322+ if min_free_space is not None :
323+ params ["min-free-space" ] = min_free_space
324+ if all_builds is not None :
325+ params ["all" ] = all_builds
326+ if filters is not None :
327+ params ["filters" ] = clean_filters (filters )
328+
329+ response = await self .docker ._query_json ("build/prune" , "POST" , params = params )
330+ return response
331+
285332 @staticmethod
286333 async def _stream (fileobj : SupportsRead [bytes ]) -> AsyncIterator [bytes ]:
287334 chunk = fileobj .read (io .DEFAULT_BUFFER_SIZE )
0 commit comments