mirror of https://github.com/docker/docker-py.git
Add df method
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
f387ae46d7
commit
cfb14fa78f
|
@ -7,6 +7,22 @@ from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
|
|||
|
||||
|
||||
class DaemonApiMixin(object):
|
||||
@utils.minimum_version('1.25')
|
||||
def df(self):
|
||||
"""
|
||||
Get data usage information.
|
||||
|
||||
Returns:
|
||||
(dict): A dictionary representing different resource categories
|
||||
and their respective data usage.
|
||||
|
||||
Raises:
|
||||
:py:class:`docker.errors.APIError`
|
||||
If the server returns an error.
|
||||
"""
|
||||
url = self._url('/system/df')
|
||||
return self._result(self._get(url), True)
|
||||
|
||||
def events(self, since=None, until=None, filters=None, decode=None):
|
||||
"""
|
||||
Get real-time events from the server. Similar to the ``docker events``
|
||||
|
|
|
@ -155,6 +155,10 @@ class DockerClient(object):
|
|||
return self.api.events(*args, **kwargs)
|
||||
events.__doc__ = APIClient.events.__doc__
|
||||
|
||||
def df(self):
|
||||
return self.api.df()
|
||||
df.__doc__ = APIClient.df.__doc__
|
||||
|
||||
def info(self, *args, **kwargs):
|
||||
return self.api.info(*args, **kwargs)
|
||||
info.__doc__ = APIClient.info.__doc__
|
||||
|
|
|
@ -25,6 +25,7 @@ Client reference
|
|||
.. autoattribute:: swarm
|
||||
.. autoattribute:: volumes
|
||||
|
||||
.. automethod:: df()
|
||||
.. automethod:: events()
|
||||
.. automethod:: info()
|
||||
.. automethod:: login()
|
||||
|
|
|
@ -2,21 +2,28 @@ import unittest
|
|||
|
||||
import docker
|
||||
|
||||
from ..helpers import requires_api_version
|
||||
from .base import TEST_API_VERSION
|
||||
|
||||
|
||||
class ClientTest(unittest.TestCase):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
|
||||
def test_info(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
info = client.info()
|
||||
info = self.client.info()
|
||||
assert 'ID' in info
|
||||
assert 'Name' in info
|
||||
|
||||
def test_ping(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
assert client.ping() is True
|
||||
assert self.client.ping() is True
|
||||
|
||||
def test_version(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
assert 'Version' in client.version()
|
||||
assert 'Version' in self.client.version()
|
||||
|
||||
@requires_api_version('1.25')
|
||||
def test_df(self):
|
||||
data = self.client.df()
|
||||
assert 'LayersSize' in data
|
||||
assert 'Containers' in data
|
||||
assert 'Volumes' in data
|
||||
assert 'Images' in data
|
||||
|
|
Loading…
Reference in New Issue