Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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
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
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