summaryrefslogtreecommitdiffstats
path: root/ipaclient
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-05-30 09:07:25 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commitb8988da0968e3b0bf27ac97a18b1ceae77e41cc3 (patch)
tree65b96589831109a4740e562b60a28c76de78b4b4 /ipaclient
parent60d946241cc5a13050fd67873a2044df144d6743 (diff)
downloadfreeipa-b8988da0968e3b0bf27ac97a18b1ceae77e41cc3.tar.gz
freeipa-b8988da0968e3b0bf27ac97a18b1ceae77e41cc3.tar.xz
freeipa-b8988da0968e3b0bf27ac97a18b1ceae77e41cc3.zip
ipaclient: add client-side command override class
This adds a new ipaclient.frontend module with two classes, CommandOverride and MethodOverride, which can be used to implement additional client-side functionality on top of server-side Command and Method plugins. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipaclient')
-rw-r--r--ipaclient/frontend.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/ipaclient/frontend.py b/ipaclient/frontend.py
new file mode 100644
index 000000000..c2d916d92
--- /dev/null
+++ b/ipaclient/frontend.py
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
+#
+
+from ipalib.frontend import Command, Method
+
+
+class CommandOverride(Command):
+ def __init__(self, api):
+ super(CommandOverride, self).__init__(api)
+
+ next_class = api.get_plugin_next(type(self))
+ self.next = next_class(api)
+
+ @property
+ def doc(self):
+ return self.next.doc
+
+ @property
+ def NO_CLI(self):
+ return self.next.NO_CLI
+
+ @property
+ def topic(self):
+ return self.next.topic
+
+ def _on_finalize(self):
+ self.next.finalize()
+
+ super(CommandOverride, self)._on_finalize()
+
+ def get_args(self):
+ for arg in self.next.args():
+ yield arg
+ for arg in super(CommandOverride, self).get_args():
+ yield arg
+
+ def get_options(self):
+ for option in self.next.options():
+ yield option
+ for option in super(CommandOverride, self).get_options():
+ if option.name not in ('all', 'raw', 'version'):
+ yield option
+
+ def get_output_params(self):
+ return self.next.output_params()
+
+ def _iter_output(self):
+ return self.next.output()
+
+
+class MethodOverride(CommandOverride, Method):
+ @property
+ def obj_name(self):
+ return self.next.obj_name
+
+ @property
+ def attr_name(self):
+ return self.next.attr_name
+
+ @property
+ def obj(self):
+ return self.next.obj