How to use the aiodocker.utils.clean_filters function in aiodocker

To help you get started, we’ve selected a few aiodocker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiodocker / tests / test_utils.py View on Github external
def test_clean_filters():
    filters = {"a": ["1", "2", "3", "4"], "b": "string"}
    result = {"a": ["1", "2", "3", "4"], "b": ["string"]}
    assert utils.clean_filters(filters=filters) == json.dumps(result)

    filters = ()
    result = {"a": ["1", "2", "3", "4"], "b": ["string"]}
    utils.clean_filters(filters=filters) == json.dumps(result)
github aio-libs / aiodocker / aiodocker / nodes.py View on Github external
async def list(self, *, filters: Mapping = None) -> List[Mapping]:
        """
        Return a list of swarm's nodes.

        Args:
            filters: a dict with a list of filters

        Available filters:
            id=
            label=
            membership=(accepted|pending)`
            name=
            role=(manager|worker)`
        """

        params = {"filters": clean_filters(filters)}

        response = await self.docker._query_json("nodes", method="GET", params=params)

        return response
github aio-libs / aiodocker / aiodocker / services.py View on Github external
async def list(self, *, filters: Mapping = None) -> List[Mapping]:
        """
        Return a list of services

        Args:
            filters: a dict with a list of filters

        Available filters:
            id=
            label=
            mode=["replicated"|"global"]
            name=
        """

        params = {"filters": clean_filters(filters)}

        response = await self.docker._query_json(
            "services", method="GET", params=params
        )
        return response
github aio-libs / aiodocker / aiodocker / tasks.py View on Github external
Return a list of tasks

        Args:
            filters: a collection of filters

        Available filters:
        desired-state=(running | shutdown | accepted)
        id=
        label=key or label="key=value"
        name=
        node=
        service=

        """

        params = {"filters": clean_filters(filters)}

        response = await self.docker._query_json("tasks", method="GET", params=params)
        return response