{"action":"created","issue":{"url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/326","repository_url":"https://api.github.com/repos/SatelliteQE/nailgun","labels_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/326/labels{/name}","comments_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/326/comments","events_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/326/events","html_url":"https://github.com/SatelliteQE/nailgun/pull/326","id":184060380,"number":326,"title":"Added json method to Entity","user":{"login":"renzon","id":3457115,"avatar_url":"https://avatars.githubusercontent.com/u/3457115?v=3","gravatar_id":"","url":"https://api.github.com/users/renzon","html_url":"https://github.com/renzon","followers_url":"https://api.github.com/users/renzon/followers","following_url":"https://api.github.com/users/renzon/following{/other_user}","gists_url":"https://api.github.com/users/renzon/gists{/gist_id}","starred_url":"https://api.github.com/users/renzon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renzon/subscriptions","organizations_url":"https://api.github.com/users/renzon/orgs","repos_url":"https://api.github.com/users/renzon/repos","events_url":"https://api.github.com/users/renzon/events{/privacy}","received_events_url":"https://api.github.com/users/renzon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SatelliteQE/nailgun/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-19T20:04:53Z","updated_at":"2016-10-20T17:58:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/nailgun/pulls/326","html_url":"https://github.com/SatelliteQE/nailgun/pull/326","diff_url":"https://github.com/SatelliteQE/nailgun/pull/326.diff","patch_url":"https://github.com/SatelliteQE/nailgun/pull/326.patch"},"body":"close #323\r\n\r\nOnce the methods uses _payload, some Entities maybe need\r\n override this to match names expected on API\r\n\r\nI followed @elyezer tip and made a this POC that worked for simple properties: https://github.com/renzon/nailgun/commit/d092468853d49239fa909ceba1da8af0e3271ba0.\r\n\r\nThe problem is when the default naming mapping is not correct with the expected for API. But in this case Subclasses can override _to_json_dict for the exceptions.\r\n\r\n@ehelms and @rochacbruno could give it a try to check exceptions as they use it and creating issues here for them. What you guys think?"},"comment":{"url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/comments/255180504","html_url":"https://github.com/SatelliteQE/nailgun/pull/326#issuecomment-255180504","issue_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/326","id":255180504,"user":{"login":"ehelms","id":293363,"avatar_url":"https://avatars.githubusercontent.com/u/293363?v=3","gravatar_id":"","url":"https://api.github.com/users/ehelms","html_url":"https://github.com/ehelms","followers_url":"https://api.github.com/users/ehelms/followers","following_url":"https://api.github.com/users/ehelms/following{/other_user}","gists_url":"https://api.github.com/users/ehelms/gists{/gist_id}","starred_url":"https://api.github.com/users/ehelms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehelms/subscriptions","organizations_url":"https://api.github.com/users/ehelms/orgs","repos_url":"https://api.github.com/users/ehelms/repos","events_url":"https://api.github.com/users/ehelms/events{/privacy}","received_events_url":"https://api.github.com/users/ehelms/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T17:58:16Z","updated_at":"2016-10-20T17:58:16Z","body":"I think, based on the output below, I will also need `json.dumps` to work for taking a large data structure containing Nailgun classes and turning them into JSON.\r\n\r\n```\r\n  File \"/tmp/ansible_Xv6fUt/ansible_module_katello.py\", line 451, in compare\r\n    return json.dumps(reports)\r\n  File \"/usr/lib64/python2.7/json/__init__.py\", line 244, in dumps\r\n    return _default_encoder.encode(obj)\r\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 207, in encode\r\n    chunks = self.iterencode(o, _one_shot=True)\r\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 270, in iterencode\r\n    return _iterencode(o, 0)\r\n  File \"/usr/lib64/python2.7/json/encoder.py\", line 184, in default\r\n    raise TypeError(repr(o) + \" is not JSON serializable\")\r\nTypeError: nailgun.entities.Package(nailgun.config.ServerConfig(url='https://sat-r220-02.lab.eng.rdu2.redhat.com/', verify=False, auth=('admin', 'changeme')), nvrea=u'sclo-git25-1.0-2.el7.x86_64', checksum=u'751e639a0b8add0adc0c5cf0bf77693b3197b17533037ce2e7b9daa618898b99', summary=u'Package that installs sclo-git25', filename=u'sclo-git25-1.0-2.el7.x86_64.rpm', epoch=u'0', version=u'1.0', nvra=u'sclo-git25-1.0-2.el7.x86_64', release=u'2.el7', sourcerpm=u'sclo-git25-1.0-2.el7.src.rpm', arch=u'x86_64', id=64529, name=u'sclo-git25') is not JSON serializable\r\n```"}}
{"actor":{"display_login":"ehelms"}}