diff options
author | Viacheslav Boiko <v.e.boyko@gmail.com> | 2015-10-01 10:06:55 +0000 |
---|---|---|
committer | Viacheslav Boiko <v.e.boyko@gmail.com> | 2015-10-02 06:19:06 +0000 |
commit | 4a2db828b4ca02517afb6e5b33da33e2146d8b83 (patch) | |
tree | 8aa1c4234764302dccecdee837e1bbcd9ccbbf39 /docker/api/container.py | |
parent | 7884ab9fe2c3b36209727821f81d322f2ade1b60 (diff) | |
download | docker-py-4a2db828b4ca02517afb6e5b33da33e2146d8b83.tar.gz |
Support the 'since' option in the 'containers/<id>/logs' endpoint
Signed-off-by: Viacheslav Boiko <v.e.boyko@gmail.com>
Diffstat (limited to 'docker/api/container.py')
-rw-r--r-- | docker/api/container.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index 94889e9..764a0ec 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -1,5 +1,6 @@ import six import warnings +from datetime import datetime from .. import errors from .. import utils @@ -163,7 +164,7 @@ class ContainerApiMixin(object): @utils.check_resource def logs(self, container, stdout=True, stderr=True, stream=False, - timestamps=False, tail='all'): + timestamps=False, tail='all', since=None): if utils.compare_version('1.11', self._version) >= 0: params = {'stderr': stderr and 1 or 0, 'stdout': stdout and 1 or 0, @@ -174,6 +175,17 @@ class ContainerApiMixin(object): if tail != 'all' and (not isinstance(tail, int) or tail <= 0): tail = 'all' params['tail'] = tail + + if since is not None: + if utils.compare_version('1.19', self._version) < 0: + raise errors.InvalidVersion( + 'since is not supported in API < 1.19' + ) + else: + if isinstance(since, datetime): + params['since'] = utils.datetime_to_timestamp(since) + elif (isinstance(since, int) and since > 0): + params['since'] = since url = self._url("/containers/{0}/logs", container) res = self._get(url, params=params, stream=stream) return self._get_result(container, stream, res) |