summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 57b8e14..c03e77e 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -34,9 +34,7 @@ from gitlab.exceptions import * # noqa
class jsonEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, GitlabObject):
- return {k: v for k, v in six.iteritems(obj.__dict__)
- if (not isinstance(v, BaseManager)
- and not k[0] == '_')}
+ return obj.as_dict()
elif isinstance(obj, gitlab.Gitlab):
return {'url': obj._url}
return json.JSONEncoder.default(self, obj)
@@ -488,6 +486,11 @@ class GitlabObject(object):
"""
return json.dumps(self, cls=jsonEncoder)
+ def as_dict(self):
+ """Dump the object as a dict."""
+ return {k: v for k, v in six.iteritems(self.__dict__)
+ if (not isinstance(v, BaseManager) and not k[0] == '_')}
+
class UserKey(GitlabObject):
_url = '/users/%(user_id)s/keys'