From d8c4a61a2d30817542a2328655f1bce552db4d60 Mon Sep 17 00:00:00 2001 From: Jim Madge Date: Fri, 22 Sep 2023 16:23:15 +0100 Subject: [PATCH] Add confirm method --- data_safe_haven/external/api/azure_cli.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/data_safe_haven/external/api/azure_cli.py b/data_safe_haven/external/api/azure_cli.py index f7aacf8bee..0a2ae8177c 100644 --- a/data_safe_haven/external/api/azure_cli.py +++ b/data_safe_haven/external/api/azure_cli.py @@ -4,6 +4,8 @@ from dataclasses import dataclass from shutil import which +import typer + from data_safe_haven.exceptions import DataSafeHavenAzureError from data_safe_haven.utility import LoggingSingleton @@ -55,3 +57,12 @@ def account(self) -> AzureCliAccount: raise DataSafeHavenAzureError(msg) from exc return self._account + + def confirm(self) -> None: + account = self.account + print( + f"name: {account.name} (id: {account.id_}\n", + f"tenant: {account.tenant_id}" + ) + if not typer.confirm("Is this the Azure account you expect?\n"): + typer.Exit()