summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2015-06-05 15:11:54 +0200
committerTomas Babej <tbabej@redhat.com>2015-07-03 10:42:16 +0200
commitba0a1c6b33e2519a48754602413c8379fb1f0ff1 (patch)
treec9229fb3174ec5a0c76425746db199ada986e943 /ipalib/frontend.py
parent884afb5d38480e23c91ec14876bcf39151a2c2ed (diff)
downloadfreeipa-ba0a1c6b33e2519a48754602413c8379fb1f0ff1.tar.gz
freeipa-ba0a1c6b33e2519a48754602413c8379fb1f0ff1.tar.xz
freeipa-ba0a1c6b33e2519a48754602413c8379fb1f0ff1.zip
include more information in metadata
added to commands: doc, proper args, NO_CLI added to options: default_from, cli_name, cli_short_name and others https://fedorahosted.org/freeipa/ticket/3129 Reviewed-By: Martin Kosek <mkosek@redhat.com> Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index af201fc9a..81bf6d90b 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -35,6 +35,7 @@ from errors import (ZeroArgumentError, MaxArgumentError, OverlapError,
VersionError, OptionError, InvocationError,
ValidationError, ConversionError)
from ipalib import messages
+from ipalib.util import json_serialize
from textwrap import wrap
@@ -1046,31 +1047,16 @@ class Command(HasParam):
# list of attributes we want exported to JSON
json_friendly_attributes = (
- 'name', 'takes_args',
+ 'name', 'doc', 'NO_CLI'
)
- # list of options we want only to mention their presence and not to write
- # their attributes
- json_only_presence_options = (
- 'all', 'raw', 'attrs', 'addattr', 'delattr', 'setattr', 'version',
- )
-
- def get_json_options(self):
- """
- Get only options we want exported to JSON
- """
- for option in self.get_options():
- if option.name not in self.json_only_presence_options:
- yield option
- else:
- yield { 'name': option.name }
-
def __json__(self):
json_dict = dict(
(a, getattr(self, a)) for a in self.json_friendly_attributes
)
- json_dict['takes_options'] = list(self.get_json_options())
+ json_dict['takes_args'] = list(self.get_args())
+ json_dict['takes_options'] = list(self.get_options())
return json_dict
@@ -1206,6 +1192,20 @@ class Object(HasParam):
return 1
return 2
+ json_friendly_attributes = (
+ 'name', 'takes_params',
+ )
+
+ def __json__(self):
+ json_dict = dict(
+ (a, json_serialize(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
+
class Attribute(Plugin):
"""