`Delete unused networks` method is missed
SergeyTsaplin opened this issue · comments
Prune networks method is missed
- Expected behaviour: I expect that the library provides
/network/prune
endpoint support (https://docs.docker.com/engine/api/v1.41/#operation/NetworkPrune) - Actual behaviour: There is no
/networks/prune
endpoint support in the library.
Possible Implementation:
aiodocker/networks.py
class DockerNetworks:
...
async def prune(self, *, filters: Mapping = None) -> List[str]:
"""
Delete unused networks and return the list of the deleted networks.
Args:
filters: a dict with a list of filters
Available filters:
until=<timestamp> Prune networks created before this timestamp. The <timestamp> can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the daemon machine’s time.
label (label=<key>, label=<key>=<value>, label!=<key>, or label!=<key>=<value>) Prune networks with (or without, in case label!=... is used) the specified labels.
"""
data = {} if filters is None else {"filters": clean_filters(filters)}
data = await self.docker._query_json("networks/prune", method="POST", data=data)
return data.get("NetworksDeleted") or []
Other missing thing is to prune the volume as well.