Kaydet (Commit) 726d7f31 authored tarafından Matthieu Nottale's avatar Matthieu Nottale Kaydeden (comit) Joffrey F

Add sparse argument to DockerClient.containers.list().

Signed-off-by: 's avatarMatthieu Nottale <matthieu.nottale@docker.com>
üst 35520ab0
...@@ -833,7 +833,8 @@ class ContainerCollection(Collection): ...@@ -833,7 +833,8 @@ class ContainerCollection(Collection):
resp = self.client.api.inspect_container(container_id) resp = self.client.api.inspect_container(container_id)
return self.prepare_model(resp) return self.prepare_model(resp)
def list(self, all=False, before=None, filters=None, limit=-1, since=None): def list(self, all=False, before=None, filters=None, limit=-1, since=None,
sparse=False):
""" """
List containers. Similar to the ``docker ps`` command. List containers. Similar to the ``docker ps`` command.
...@@ -862,6 +863,9 @@ class ContainerCollection(Collection): ...@@ -862,6 +863,9 @@ class ContainerCollection(Collection):
container. Give the container name or id. container. Give the container name or id.
- `since` (str): Only containers created after a particular - `since` (str): Only containers created after a particular
container. Give container name or id. container. Give container name or id.
sparse (bool): Do not inspect containers. Returns partial
informations, but guaranteed not to block. Use reload() on
each container to get the full list of attributes.
A comprehensive list can be found in the documentation for A comprehensive list can be found in the documentation for
`docker ps `docker ps
...@@ -877,7 +881,10 @@ class ContainerCollection(Collection): ...@@ -877,7 +881,10 @@ class ContainerCollection(Collection):
resp = self.client.api.containers(all=all, before=before, resp = self.client.api.containers(all=all, before=before,
filters=filters, limit=limit, filters=filters, limit=limit,
since=since) since=since)
return [self.get(r['Id']) for r in resp] if sparse:
return [self.prepare_model(r) for r in resp]
else:
return [self.get(r['Id']) for r in resp]
def prune(self, filters=None): def prune(self, filters=None):
return self.client.api.prune_containers(filters=filters) return self.client.api.prune_containers(filters=filters)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment