Disallow incompatible combination stats(decode=True, stream=False)

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-11-08 17:13:19 -08:00
parent ebfba8d4c3
commit d9e08aedc3
2 changed files with 8 additions and 2 deletions

View File

@ -1071,7 +1071,8 @@ class ContainerApiMixin(object):
Args: Args:
container (str): The container to stream statistics from container (str): The container to stream statistics from
decode (bool): If set to true, stream will be decoded into dicts decode (bool): If set to true, stream will be decoded into dicts
on the fly. False by default. on the fly. Only applicable if ``stream`` is True.
False by default.
stream (bool): If set to false, only the current stats will be stream (bool): If set to false, only the current stats will be
returned instead of a stream. True by default. returned instead of a stream. True by default.
@ -1085,6 +1086,10 @@ class ContainerApiMixin(object):
return self._stream_helper(self._get(url, stream=True), return self._stream_helper(self._get(url, stream=True),
decode=decode) decode=decode)
else: else:
if decode:
raise errors.InvalidArgument(
"decode is only available in conjuction with stream=True"
)
return self._result(self._get(url, params={'stream': False}), return self._result(self._get(url, params={'stream': False}),
json=True) json=True)

View File

@ -385,7 +385,8 @@ class Container(Model):
Args: Args:
decode (bool): If set to true, stream will be decoded into dicts decode (bool): If set to true, stream will be decoded into dicts
on the fly. False by default. on the fly. Only applicable if ``stream`` is True.
False by default.
stream (bool): If set to false, only the current stats will be stream (bool): If set to false, only the current stats will be
returned instead of a stream. True by default. returned instead of a stream. True by default.