Search in sources :

Example 1 with IdentityAzureManager

use of com.microsoft.azuretools.sdkmanage.IdentityAzureManager in project azure-tools-for-java by Microsoft.

the class AzureLoginHelper method ensureAzureSubsAvailable.

public static void ensureAzureSubsAvailable() throws AzureExecutionException {
    if (!AuthMethodManager.getInstance().isSignedIn()) {
        throw new AzureExecutionException(NEED_SIGN_IN);
    }
    IdentityAzureManager azureManager = IdentityAzureManager.getInstance();
    final List<Subscription> subscriptions = azureManager.getSubscriptions();
    if (CollectionUtils.isEmpty(subscriptions)) {
        throw new AzureExecutionException(NO_SUBSCRIPTION);
    }
    final List<Subscription> selectedSubscriptions = azureManager.getSelectedSubscriptions();
    if (CollectionUtils.isEmpty(selectedSubscriptions)) {
        throw new AzureExecutionException(MUST_SELECT_SUBSCRIPTION);
    }
}
Also used : IdentityAzureManager(com.microsoft.azuretools.sdkmanage.IdentityAzureManager) AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 2 with IdentityAzureManager

use of com.microsoft.azuretools.sdkmanage.IdentityAzureManager in project azure-tools-for-java by Microsoft.

the class SignInCommandHandler method ensureAzureSubsAvailable.

private static void ensureAzureSubsAvailable() throws AzureExecutionException {
    if (!AuthMethodManager.getInstance().isSignedIn()) {
        throw new AzureExecutionException(NEED_SIGN_IN);
    }
    IdentityAzureManager azureManager = IdentityAzureManager.getInstance();
    final List<Subscription> subscriptions = azureManager.getSubscriptions();
    if (CollectionUtils.isEmpty(subscriptions)) {
        throw new AzureExecutionException(NO_SUBSCRIPTION);
    }
    final List<Subscription> selectedSubscriptions = azureManager.getSelectedSubscriptions();
    if (CollectionUtils.isEmpty(selectedSubscriptions)) {
        throw new AzureExecutionException(MUST_SELECT_SUBSCRIPTION);
    }
}
Also used : IdentityAzureManager(com.microsoft.azuretools.sdkmanage.IdentityAzureManager) AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Aggregations

AzureExecutionException (com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException)2 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)2 IdentityAzureManager (com.microsoft.azuretools.sdkmanage.IdentityAzureManager)2