Kaydet (Commit) 32f57c4b authored tarafından Joffrey F's avatar Joffrey F

Add df method

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 745edc80
...@@ -7,6 +7,22 @@ from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING ...@@ -7,6 +7,22 @@ from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
class DaemonApiMixin(object): 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): def events(self, since=None, until=None, filters=None, decode=None):
""" """
Get real-time events from the server. Similar to the ``docker events`` Get real-time events from the server. Similar to the ``docker events``
......
...@@ -155,6 +155,10 @@ class DockerClient(object): ...@@ -155,6 +155,10 @@ class DockerClient(object):
return self.api.events(*args, **kwargs) return self.api.events(*args, **kwargs)
events.__doc__ = APIClient.events.__doc__ events.__doc__ = APIClient.events.__doc__
def df(self):
return self.api.df()
df.__doc__ = APIClient.df.__doc__
def info(self, *args, **kwargs): def info(self, *args, **kwargs):
return self.api.info(*args, **kwargs) return self.api.info(*args, **kwargs)
info.__doc__ = APIClient.info.__doc__ info.__doc__ = APIClient.info.__doc__
......
...@@ -25,6 +25,7 @@ Client reference ...@@ -25,6 +25,7 @@ Client reference
.. autoattribute:: swarm .. autoattribute:: swarm
.. autoattribute:: volumes .. autoattribute:: volumes
.. automethod:: df()
.. automethod:: events() .. automethod:: events()
.. automethod:: info() .. automethod:: info()
.. automethod:: login() .. automethod:: login()
......
...@@ -2,21 +2,28 @@ import unittest ...@@ -2,21 +2,28 @@ import unittest
import docker import docker
from ..helpers import requires_api_version
from .base import TEST_API_VERSION from .base import TEST_API_VERSION
class ClientTest(unittest.TestCase): class ClientTest(unittest.TestCase):
client = docker.from_env(version=TEST_API_VERSION)
def test_info(self): def test_info(self):
client = docker.from_env(version=TEST_API_VERSION) info = self.client.info()
info = client.info()
assert 'ID' in info assert 'ID' in info
assert 'Name' in info assert 'Name' in info
def test_ping(self): def test_ping(self):
client = docker.from_env(version=TEST_API_VERSION) assert self.client.ping() is True
assert client.ping() is True
def test_version(self): def test_version(self):
client = docker.from_env(version=TEST_API_VERSION) assert 'Version' in self.client.version()
assert 'Version' in 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
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