aio-libs / aiodocker

Python Docker API client based on asyncio and aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Delete unused networks` method is missed

SergeyTsaplin opened this issue · comments

Prune networks method is missed

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.