diff sat_frontends/jp/cmd_invitation.py @ 3339:c560aae54f5f

jp (invitation): `delete` implementation
author Goffi <goffi@goffi.org>
date Thu, 13 Aug 2020 23:46:18 +0200
parents 559a625a236b
children be6d91572633
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_invitation.py	Thu Aug 13 23:46:18 2020 +0200
+++ b/sat_frontends/jp/cmd_invitation.py	Thu Aug 13 23:46:18 2020 +0200
@@ -213,6 +213,33 @@
             await self.output_data(invitation_data, jid_)
 
 
+class Delete(base.CommandBase):
+    def __init__(self, host):
+        base.CommandBase.__init__(
+            self,
+            host,
+            "delete",
+            use_profile=False,
+            help=_("delete guest account"),
+        )
+
+    def add_parser_options(self):
+        self.parser.add_argument(
+            "id", help=_("invitation UUID")
+        )
+
+    async def start(self):
+        try:
+            await self.host.bridge.invitationDelete(
+                self.args.id,
+            )
+        except Exception as e:
+            self.disp(msg=_(f"can't delete guest account: {e}"), error=True)
+            self.host.quit(C.EXIT_BRIDGE_ERRBACK)
+
+        self.host.quit()
+
+
 class Modify(base.CommandBase):
     def __init__(self, host):
         base.CommandBase.__init__(
@@ -339,7 +366,7 @@
 
 
 class Invitation(base.CommandBase):
-    subcommands = (Create, Get, Modify, List)
+    subcommands = (Create, Get, Delete, Modify, List)
 
     def __init__(self, host):
         super(Invitation, self).__init__(