schema: remove redundant information

Remove the `autofill` kwarg from param schema. On the server, include
default value only if autofill is set. On the client, set autofill if param
has a default value.

Remove the `deprecated_cli_aliases`, `hint` and `sortorder` kwargs, and the
`dnsrecord_extra`, `dnsrecord_part` and `suppress_empty` flags from param
schema, as they are now handled exclusively on the client.

Replace the `no_option` and `no_output` flags in param schema with
exclusion of the param in 'cli' and 'webui' contexts.

Remove the `no_display` flag from output schema, as it is now handled
exclusively on the client.

https://fedorahosted.org/freeipa/ticket/4739

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Jan Cholasta
2016-06-08 16:24:45 +02:00
parent d0cfe37a7e
commit cbe73c6d28
3 changed files with 23 additions and 90 deletions

View File

@@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
# # # #
######################################################## ########################################################
IPA_API_VERSION_MAJOR=2 IPA_API_VERSION_MAJOR=2
IPA_API_VERSION_MINOR=191 IPA_API_VERSION_MINOR=192
# Last change: schema: merge command args and options # Last change: schema: remove redundant information

View File

@@ -223,25 +223,20 @@ def _create_param(meta):
'sortorder'): 'sortorder'):
kwargs[key] = value kwargs[key] = value
elif key in ('cli_metavar', elif key in ('cli_metavar',
'cli_name', 'cli_name'):
'hint'):
kwargs[key] = str(value) kwargs[key] = str(value)
elif key == 'confirm' and issubclass(cls, parameters.Password): elif key == 'confirm' and issubclass(cls, parameters.Password):
kwargs[key] = value kwargs[key] = value
elif key == 'default': elif key == 'default':
default = value default = value
kwargs['autofill'] = True
elif key == 'default_from_param': elif key == 'default_from_param':
kwargs['default_from'] = DefaultFrom(_nope, kwargs['default_from'] = DefaultFrom(_nope,
*(str(k) for k in value)) *(str(k) for k in value))
elif key in ('deprecated_cli_aliases', kwargs['autofill'] = True
'exclude', elif key in ('exclude',
'include'): 'include'):
kwargs[key] = tuple(str(v) for v in value) kwargs[key] = tuple(str(v) for v in value)
elif key in ('dnsrecord_extra',
'dnsrecord_part',
'no_option',
'suppress_empty') and value:
kwargs.setdefault('flags', set()).add(key)
if default is not None: if default is not None:
tmp = cls(str(meta['name']), **dict(kwargs, no_convert=False)) tmp = cls(str(meta['name']), **dict(kwargs, no_convert=False))

View File

@@ -13,7 +13,7 @@ from ipalib import errors
from ipalib.crud import PKQuery, Retrieve, Search from ipalib.crud import PKQuery, Retrieve, Search
from ipalib.frontend import Command, Local, Method, Object from ipalib.frontend import Command, Local, Method, Object
from ipalib.output import Entry, ListOfEntries, ListOfPrimaryKeys, PrimaryKey from ipalib.output import Entry, ListOfEntries, ListOfPrimaryKeys, PrimaryKey
from ipalib.parameters import Bool, Dict, Flag, Int, Str from ipalib.parameters import Bool, Dict, Flag, Str
from ipalib.plugable import Registry from ipalib.plugable import Registry
from ipalib.text import _ from ipalib.text import _
from ipapython.version import API_VERSION from ipapython.version import API_VERSION
@@ -443,11 +443,6 @@ class param(BaseParam):
label=_("Always ask"), label=_("Always ask"),
flags={'no_search'}, flags={'no_search'},
), ),
Bool(
'autofill?',
label=_("Autofill"),
flags={'no_search'},
),
Str( Str(
'cli_metavar?', 'cli_metavar?',
label=_("CLI metavar"), label=_("CLI metavar"),
@@ -473,21 +468,11 @@ class param(BaseParam):
label=_("Default from"), label=_("Default from"),
flags={'no_search'}, flags={'no_search'},
), ),
Str(
'deprecated_cli_aliases*',
label=_("Deprecated CLI aliases"),
flags={'no_search'},
),
Str( Str(
'exclude*', 'exclude*',
label=_("Exclude from"), label=_("Exclude from"),
flags={'no_search'}, flags={'no_search'},
), ),
Str(
'hint?',
label=_("Hint"),
flags={'no_search'},
),
Str( Str(
'include*', 'include*',
label=_("Include in"), label=_("Include in"),
@@ -508,36 +493,6 @@ class param(BaseParam):
label=_("Option group"), label=_("Option group"),
flags={'no_search'}, flags={'no_search'},
), ),
Int(
'sortorder?',
label=_("Sort order"),
flags={'no_search'},
),
Bool(
'dnsrecord_extra?',
label=_("Extra field (DNS record)"),
flags={'no_search'},
),
Bool(
'dnsrecord_part?',
label=_("Part (DNS record)"),
flags={'no_search'},
),
Bool(
'no_option?',
label=_("No option"),
flags={'no_search'},
),
Bool(
'no_output?',
label=_("No output"),
flags={'no_search'},
),
Bool(
'suppress_empty?',
label=_("Suppress empty"),
flags={'no_search'},
),
Bool( Bool(
'sensitive?', 'sensitive?',
label=_("Sensitive"), label=_("Sensitive"),
@@ -588,40 +543,35 @@ class param(BaseParam):
obj[key] = list(unicode(v) for v in value) obj[key] = list(unicode(v) for v in value)
if isinstance(metaobj, Command): if isinstance(metaobj, Command):
if key in ('alwaysask', if key in ('alwaysask',
'autofill', 'confirm'):
'confirm',
'sortorder'):
obj[key] = value obj[key] = value
elif key in ('cli_metavar', elif key in ('cli_metavar',
'cli_name', 'cli_name',
'hint',
'option_group'): 'option_group'):
obj[key] = unicode(value) obj[key] = unicode(value)
elif key == 'default': elif key == 'default':
if param.multivalue: if param.autofill:
obj[key] = [unicode(v) for v in value] if param.multivalue:
else: obj[key] = [unicode(v) for v in value]
obj[key] = [unicode(value)] else:
obj[key] = [unicode(value)]
elif key == 'default_from': elif key == 'default_from':
obj['default_from_param'] = list(unicode(k) if param.autofill:
for k in value.keys) obj['default_from_param'] = list(unicode(k)
elif key == 'deprecated_cli_aliases': for k in value.keys)
obj[key] = list(unicode(v) for v in value)
elif key in ('exponential', elif key in ('exponential',
'normalizer', 'normalizer',
'only_absolute', 'only_absolute',
'precision'): 'precision'):
obj['no_convert'] = True obj['no_convert'] = True
for flag in (param.flags or []): if ((isinstance(metaobj, Command) and 'no_option' in param.flags) or
if flag in ('no_output', (isinstance(metaobj, Object) and 'no_output' in param.flags)):
'suppress_empty'): value = obj.setdefault('exclude', [])
obj[flag] = True if u'cli' not in value:
if isinstance(metaobj, Command): value.append(u'cli')
if flag in ('dnsrecord_extra', if u'webui' not in value:
'dnsrecord_part', value.append(u'webui')
'no_option'):
obj[flag] = True
return obj return obj
@@ -666,14 +616,6 @@ class param_find(BaseParamSearch):
@register() @register()
class output(BaseParam): class output(BaseParam):
takes_params = BaseParam.takes_params + (
Bool(
'no_display?',
label=_("Do not display"),
flags={'no_search'},
),
)
@property @property
def parent(self): def parent(self):
return self.api.Object.command return self.api.Object.command
@@ -721,10 +663,6 @@ class output(BaseParam):
if 'doc' in output.__dict__: if 'doc' in output.__dict__:
obj['doc'] = unicode(output.doc) obj['doc'] = unicode(output.doc)
if 'flags' in output.__dict__:
if 'no_display' in output.flags:
obj['no_display'] = True
return obj return obj
def _retrieve(self, commandname, name, **kwargs): def _retrieve(self, commandname, name, **kwargs):