{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker-py/issues/1052","repository_url":"https://api.github.com/repos/docker/docker-py","labels_url":"https://api.github.com/repos/docker/docker-py/issues/1052/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker-py/issues/1052/comments","events_url":"https://api.github.com/repos/docker/docker-py/issues/1052/events","html_url":"https://github.com/docker/docker-py/issues/1052","id":151780963,"number":1052,"title":"Feature Request: Ability to dry-run an API call (that returns the JSON payload that would have been sent out to the host) ","user":{"login":"SakuraSound","id":1021121,"avatar_url":"https://avatars.githubusercontent.com/u/1021121?v=3","gravatar_id":"","url":"https://api.github.com/users/SakuraSound","html_url":"https://github.com/SakuraSound","followers_url":"https://api.github.com/users/SakuraSound/followers","following_url":"https://api.github.com/users/SakuraSound/following{/other_user}","gists_url":"https://api.github.com/users/SakuraSound/gists{/gist_id}","starred_url":"https://api.github.com/users/SakuraSound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SakuraSound/subscriptions","organizations_url":"https://api.github.com/users/SakuraSound/orgs","repos_url":"https://api.github.com/users/SakuraSound/repos","events_url":"https://api.github.com/users/SakuraSound/events{/privacy}","received_events_url":"https://api.github.com/users/SakuraSound/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-29T02:13:43Z","updated_at":"2016-04-29T19:55:40Z","closed_at":null,"body":"It would be nice to have the ability to see the payload generated from a call to a (remote) docker host, with the option of performing either a dry-run of the request, or as a return value from the call. Scenarios where you are doing analysis of the payload (for error reporting, bug tracking), auditing requests that get sent to docker from a remote source (i.e. auditing a service that communicates with docker), or for testing purposes (or other purposes that I can not think of at this time). \r\n\r\nConsidering this seems to use requests to send payloads, [requests PreparedRequest](http://docs.python-requests.org/en/master/api/#requests.PreparedRequest) could be an area to look at for providing said functionality.\r\n\r\nI can take a look at ways this could be implemented, and would love some feedback as to the feasibility and usefulness (maybe I am crazy...)"},"comment":{"url":"https://api.github.com/repos/docker/docker-py/issues/comments/215862385","html_url":"https://github.com/docker/docker-py/issues/1052#issuecomment-215862385","issue_url":"https://api.github.com/repos/docker/docker-py/issues/1052","id":215862385,"user":{"login":"shin-","id":1086876,"avatar_url":"https://avatars.githubusercontent.com/u/1086876?v=3","gravatar_id":"","url":"https://api.github.com/users/shin-","html_url":"https://github.com/shin-","followers_url":"https://api.github.com/users/shin-/followers","following_url":"https://api.github.com/users/shin-/following{/other_user}","gists_url":"https://api.github.com/users/shin-/gists{/gist_id}","starred_url":"https://api.github.com/users/shin-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shin-/subscriptions","organizations_url":"https://api.github.com/users/shin-/orgs","repos_url":"https://api.github.com/users/shin-/repos","events_url":"https://api.github.com/users/shin-/events{/privacy}","received_events_url":"https://api.github.com/users/shin-/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T19:55:40Z","updated_at":"2016-04-29T19:55:40Z","body":"I think this covers most use-cases:\r\n\r\n```python\r\nimport docker\r\n\r\n\r\nclass DryRunClient(docker.Client):\r\n    def request(self, method, url, params=None, data=None, headers=None,\r\n                *args, **kwargs):\r\n        return {\r\n            'method': method,\r\n            'url': url,\r\n            'params': params,\r\n            'data': data,\r\n            'headers': headers\r\n        }\r\n\r\n    def _result(self, response, *args, **kwargs):\r\n        return response\r\n\r\n    def _raise_for_status(self, *args, **kwargs):\r\n        pass\r\n\r\n    def _stream_helper(self, response, *args, **kwargs):\r\n        return response\r\n\r\n    def _get_result(self, container, stream, response):\r\n        return response\r\n\r\n    def _get_result_tty(self, stream, response, is_tty):\r\n        return response\r\n```\r\n\r\nSome methods like `stop`, `pause` or `rename` will not return any value regardless (because the API provides an empty response when those operations are successful) so if you're interested in those as well, you would need to tweak them manually."}}