From adb63054add31e06cefec09982a02b1cd21c2cbd Mon Sep 17 00:00:00 2001 From: Karol Ossowski Date: Wed, 24 Apr 2019 11:49:22 +0200 Subject: [PATCH 1/2] dont ask for id attr if this is *Manager originating custom action --- gitlab/v4/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 242874d1a..8ad75ae56 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -217,14 +217,14 @@ def _populate_sub_parser_by_class(cls, sub_parser): for x in mgr_cls._from_parent_attrs] sub_parser_action.add_argument("--sudo", required=False) + required, optional, needs_id = cli.custom_actions[name][action_name] # We need to get the object somehow - if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(cls): + if needs_id and gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(cls): if cls._id_attr is not None: id_attr = cls._id_attr.replace('_', '-') sub_parser_action.add_argument("--%s" % id_attr, required=True) - required, optional, dummy = cli.custom_actions[name][action_name] [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), required=True) for x in required if x != cls._id_attr] From 6158fd23022b2e2643b6da7a39708b28ce59270a Mon Sep 17 00:00:00 2001 From: Karol Ossowski Date: Wed, 24 Apr 2019 11:59:22 +0200 Subject: [PATCH 2/2] fix -/_ replacament for *Manager custom actions --- gitlab/v4/cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py index 8ad75ae56..4e1564288 100644 --- a/gitlab/v4/cli.py +++ b/gitlab/v4/cli.py @@ -80,10 +80,10 @@ def do_custom(self): if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(self.cls): data[self.cls._id_attr] = self.args.pop(self.cls._id_attr) o = self.cls(self.mgr, data) - method_name = self.action.replace('-', '_') - return getattr(o, method_name)(**self.args) else: - return getattr(self.mgr, self.action)(**self.args) + o = self.mgr + method_name = self.action.replace('-', '_') + return getattr(o, method_name)(**self.args) def do_project_export_download(self): try: