Search in sources :

Example 51 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class SubscriptionManager method updateAccountSubscriptionList.

protected List<SubscriptionDetail> updateAccountSubscriptionList() throws IOException {
    System.out.println(Thread.currentThread().getId() + " SubscriptionManager.updateAccountSubscriptionList()");
    if (azureManager == null) {
        throw new IllegalArgumentException("azureManager is null");
    }
    System.out.println("Getting subscription list from Azure");
    List<SubscriptionDetail> sdl = new ArrayList<>();
    List<Pair<Subscription, Tenant>> stpl = azureManager.getSubscriptionsWithTenant();
    for (Pair<Subscription, Tenant> stp : stpl) {
        sdl.add(new SubscriptionDetail(stp.first().subscriptionId(), stp.first().displayName(), stp.second().tenantId(), true));
    }
    return sdl;
}
Also used : Tenant(com.microsoft.azure.management.resources.Tenant) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) Subscription(com.microsoft.azure.management.resources.Subscription) Pair(com.microsoft.azuretools.utils.Pair)

Example 52 with SubscriptionDetail

use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.

the class SubscriptionManagerPersist method loadSubscriptions.

private static List<SubscriptionDetail> loadSubscriptions(String subscriptionsDetailsFileName) throws IOException {
    System.out.println("SubscriptionManagerPersist.loadSubscriptions()");
    //subscriptionDetails.clear();
    FileStorage subscriptionsDetailsFileStorage = new FileStorage(subscriptionsDetailsFileName, CommonSettings.settingsBaseDir);
    byte[] data = subscriptionsDetailsFileStorage.read();
    String json = new String(data, StandardCharsets.UTF_8);
    if (json.isEmpty()) {
        System.out.println(subscriptionsDetailsFileName + " file is empty");
        return null;
    }
    SubscriptionDetail[] sda = JsonHelper.deserialize(SubscriptionDetail[].class, json);
    List<SubscriptionDetail> sdl = new ArrayList<>();
    for (SubscriptionDetail sd : sda) {
        sdl.add(sd);
    }
    return sdl;
}
Also used : ArrayList(java.util.ArrayList) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail)

Aggregations

SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)52 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)17 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)13 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)13 IOException (java.io.IOException)9 AppServicePlan (com.microsoft.azure.management.appservice.AppServicePlan)7 Location (com.microsoft.azure.management.resources.Location)7 List (java.util.List)7 WebApp (com.microsoft.azure.management.appservice.WebApp)5 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Azure (com.microsoft.azure.management.Azure)4 Subscription (com.microsoft.azure.management.resources.Subscription)4 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)4 HashMap (java.util.HashMap)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 AccessTokenAzureManager (com.microsoft.azuretools.sdkmanage.AccessTokenAzureManager)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3