mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
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:
parent
d0cfe37a7e
commit
cbe73c6d28
4
VERSION
4
VERSION
@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
|
||||
# #
|
||||
########################################################
|
||||
IPA_API_VERSION_MAJOR=2
|
||||
IPA_API_VERSION_MINOR=191
|
||||
# Last change: schema: merge command args and options
|
||||
IPA_API_VERSION_MINOR=192
|
||||
# Last change: schema: remove redundant information
|
||||
|
@ -223,25 +223,20 @@ def _create_param(meta):
|
||||
'sortorder'):
|
||||
kwargs[key] = value
|
||||
elif key in ('cli_metavar',
|
||||
'cli_name',
|
||||
'hint'):
|
||||
'cli_name'):
|
||||
kwargs[key] = str(value)
|
||||
elif key == 'confirm' and issubclass(cls, parameters.Password):
|
||||
kwargs[key] = value
|
||||
elif key == 'default':
|
||||
default = value
|
||||
kwargs['autofill'] = True
|
||||
elif key == 'default_from_param':
|
||||
kwargs['default_from'] = DefaultFrom(_nope,
|
||||
*(str(k) for k in value))
|
||||
elif key in ('deprecated_cli_aliases',
|
||||
'exclude',
|
||||
kwargs['autofill'] = True
|
||||
elif key in ('exclude',
|
||||
'include'):
|
||||
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:
|
||||
tmp = cls(str(meta['name']), **dict(kwargs, no_convert=False))
|
||||
|
@ -13,7 +13,7 @@ from ipalib import errors
|
||||
from ipalib.crud import PKQuery, Retrieve, Search
|
||||
from ipalib.frontend import Command, Local, Method, Object
|
||||
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.text import _
|
||||
from ipapython.version import API_VERSION
|
||||
@ -443,11 +443,6 @@ class param(BaseParam):
|
||||
label=_("Always ask"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Bool(
|
||||
'autofill?',
|
||||
label=_("Autofill"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Str(
|
||||
'cli_metavar?',
|
||||
label=_("CLI metavar"),
|
||||
@ -473,21 +468,11 @@ class param(BaseParam):
|
||||
label=_("Default from"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Str(
|
||||
'deprecated_cli_aliases*',
|
||||
label=_("Deprecated CLI aliases"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Str(
|
||||
'exclude*',
|
||||
label=_("Exclude from"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Str(
|
||||
'hint?',
|
||||
label=_("Hint"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
Str(
|
||||
'include*',
|
||||
label=_("Include in"),
|
||||
@ -508,36 +493,6 @@ class param(BaseParam):
|
||||
label=_("Option group"),
|
||||
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(
|
||||
'sensitive?',
|
||||
label=_("Sensitive"),
|
||||
@ -588,40 +543,35 @@ class param(BaseParam):
|
||||
obj[key] = list(unicode(v) for v in value)
|
||||
if isinstance(metaobj, Command):
|
||||
if key in ('alwaysask',
|
||||
'autofill',
|
||||
'confirm',
|
||||
'sortorder'):
|
||||
'confirm'):
|
||||
obj[key] = value
|
||||
elif key in ('cli_metavar',
|
||||
'cli_name',
|
||||
'hint',
|
||||
'option_group'):
|
||||
obj[key] = unicode(value)
|
||||
elif key == 'default':
|
||||
if param.multivalue:
|
||||
obj[key] = [unicode(v) for v in value]
|
||||
else:
|
||||
obj[key] = [unicode(value)]
|
||||
if param.autofill:
|
||||
if param.multivalue:
|
||||
obj[key] = [unicode(v) for v in value]
|
||||
else:
|
||||
obj[key] = [unicode(value)]
|
||||
elif key == 'default_from':
|
||||
obj['default_from_param'] = list(unicode(k)
|
||||
for k in value.keys)
|
||||
elif key == 'deprecated_cli_aliases':
|
||||
obj[key] = list(unicode(v) for v in value)
|
||||
if param.autofill:
|
||||
obj['default_from_param'] = list(unicode(k)
|
||||
for k in value.keys)
|
||||
elif key in ('exponential',
|
||||
'normalizer',
|
||||
'only_absolute',
|
||||
'precision'):
|
||||
obj['no_convert'] = True
|
||||
|
||||
for flag in (param.flags or []):
|
||||
if flag in ('no_output',
|
||||
'suppress_empty'):
|
||||
obj[flag] = True
|
||||
if isinstance(metaobj, Command):
|
||||
if flag in ('dnsrecord_extra',
|
||||
'dnsrecord_part',
|
||||
'no_option'):
|
||||
obj[flag] = True
|
||||
if ((isinstance(metaobj, Command) and 'no_option' in param.flags) or
|
||||
(isinstance(metaobj, Object) and 'no_output' in param.flags)):
|
||||
value = obj.setdefault('exclude', [])
|
||||
if u'cli' not in value:
|
||||
value.append(u'cli')
|
||||
if u'webui' not in value:
|
||||
value.append(u'webui')
|
||||
|
||||
return obj
|
||||
|
||||
@ -666,14 +616,6 @@ class param_find(BaseParamSearch):
|
||||
|
||||
@register()
|
||||
class output(BaseParam):
|
||||
takes_params = BaseParam.takes_params + (
|
||||
Bool(
|
||||
'no_display?',
|
||||
label=_("Do not display"),
|
||||
flags={'no_search'},
|
||||
),
|
||||
)
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self.api.Object.command
|
||||
@ -721,10 +663,6 @@ class output(BaseParam):
|
||||
if 'doc' in output.__dict__:
|
||||
obj['doc'] = unicode(output.doc)
|
||||
|
||||
if 'flags' in output.__dict__:
|
||||
if 'no_display' in output.flags:
|
||||
obj['no_display'] = True
|
||||
|
||||
return obj
|
||||
|
||||
def _retrieve(self, commandname, name, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user