mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add ipalib.frontend.Command method to build an entry from params with attribute=True.
Often plugins need to build LDAP entries from params. This should make things a bit easier. Crud methods (Create, Retrieve, Update, Delete, Search) have attribute=True by default. And it also works for multivalue params.
This commit is contained in:
committed by
Rob Crittenden
parent
f2abe05398
commit
016b82250e
@@ -176,6 +176,21 @@ class Command(plugable.Plugin):
|
||||
if name in options:
|
||||
yield (name, options[name])
|
||||
|
||||
def args_options_2_entry(self, *args, **options):
|
||||
"""
|
||||
Creates a LDAP entry from attributes in args and options.
|
||||
"""
|
||||
kw = self.args_options_2_params(*args, **options)
|
||||
return dict(self.__attributes_2_entry(kw))
|
||||
|
||||
def __attributes_2_entry(self, kw):
|
||||
for name in self.params:
|
||||
if self.params[name].attribute and name in kw:
|
||||
if type(kw[name]) is tuple:
|
||||
yield (name, [str(value) for value in kw[name]])
|
||||
else:
|
||||
yield (name, str(kw[name]))
|
||||
|
||||
def params_2_args_options(self, **params):
|
||||
"""
|
||||
Split params into (args, options).
|
||||
|
||||
Reference in New Issue
Block a user