diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 85a0d8225..77bec45f1 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -187,6 +187,21 @@ class dns(Object): ), ) + default_attributes = _zone_default_attributes + + json_friendly_attributes = ( + 'default_attributes', 'label', 'name', 'takes_params' ) + + def __json__(self): + json_dict = dict( + (a, getattr(self, a)) for a in self.json_friendly_attributes + ) + if self.primary_key: + json_dict['primary_key'] = self.primary_key.name + json_dict['methods'] = [m for m in self.methods] + return json_dict + + api.register(dns) diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index 096da18d8..e950796b5 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -73,16 +73,23 @@ class json_metadata(Command): ) def execute(self, objname): + if objname and objname in self.api.Object: - return dict( + + meta = dict( result=dict( ((objname, json_serialize(self.api.Object[objname])), ) ) ) - result=dict( - (o.name, json_serialize(o)) for o in self.api.Object() - ) - retval= dict([("metadata",result),("messages",json_serialize(self.messages))]) + retval= dict([("metadata",meta), ("messages",dict())]) + + else: + meta=dict( + (o.name, json_serialize(o)) for o in self.api.Object() + ) + + retval= dict([("metadata",meta), + ("messages",json_serialize(self.messages))]) return retval