Search in sources :

Example 6 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.

the class SubscriptionStep method loadSubscriptions.

private void loadSubscriptions() {
    try {
        AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureManager == null) {
            return;
        }
        /*
             * if (manager.authenticated()) { String upn =
             * manager.getUserInfo().getUniqueName();
             * userInfoLabel.setText("Signed in as: " + (upn.contains("#") ?
             * upn.split("#")[1] : upn)); } else { userInfoLabel.setText(""); }
             */
        List<Subscription> Subscriptions = AuthMethodManager.getInstance().getAzureManager().getSelectedSubscriptions();
        for (Subscription subscription : Subscriptions) {
            if (subscription.isSelected()) {
                subscriptionComboBox.add(subscription.getName());
                subscriptionComboBox.setData(subscription.getName(), subscription);
            }
        }
        if (!Subscriptions.isEmpty()) {
            subscriptionComboBox.select(0);
            wizard.setSubscription((Subscription) subscriptionComboBox.getData(subscriptionComboBox.getText()));
        }
        setPageComplete(!Subscriptions.isEmpty());
    } catch (Exception ex) {
        DefaultLoader.getUIHelper().logError("An error occurred when trying to load Subscriptions\n\n" + ex.getMessage(), ex);
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 7 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription 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 8 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.

the class SettingPanel method onComboSubscriptionSelection.

private void onComboSubscriptionSelection(ItemEvent event) {
    if (event.getStateChange() != ItemEvent.SELECTED) {
        return;
    }
    comboResourceGroup.removeAllItems();
    cbLocation.removeAllItems();
    final Subscription sb = (Subscription) comboSubscription.getSelectedItem();
    if (sb != null) {
        updateResourceGroupList(sb.getId());
        updateLocationList(sb.getId());
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 9 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.

the class SettingPanel method onComboResourceGroupSelection.

private void onComboResourceGroupSelection(ItemEvent event) {
    if (event.getStateChange() == ItemEvent.SELECTED) {
        cbExistAppServicePlan.removeAllItems();
        lblLocation.setText("");
        lblPricing.setText("");
        final Subscription sub = (Subscription) comboSubscription.getSelectedItem();
        final ResourceGroup rg = (ResourceGroup) comboResourceGroup.getSelectedItem();
        if (sub != null && rg != null) {
            updateAppServicePlanList(sub.getId(), rg.getName());
        }
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 10 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.

the class AzureMySQLConfig method getDefaultAzureMySQLConfig.

public static AzureMySQLConfig getDefaultAzureMySQLConfig() {
    final String defaultNameSuffix = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
    final AzureMySQLConfig config = new AzureMySQLConfig();
    final List<Subscription> selectedSubscriptions = az(AzureAccount.class).account().getSelectedSubscriptions();
    Preconditions.checkArgument(CollectionUtils.isNotEmpty(selectedSubscriptions), "There are no subscriptions in your account.");
    final Subscription subscription = selectedSubscriptions.get(0);
    config.setSubscription(subscription);
    final DraftResourceGroup resourceGroup = new DraftResourceGroup(subscription, "rs-" + defaultNameSuffix);
    config.setResourceGroup(resourceGroup);
    final AzureMySql azureMySql = az(AzureMySql.class).subscription(subscription.getId());
    config.setServerName("mysql-" + defaultNameSuffix);
    config.setAdminUsername(StringUtils.EMPTY);
    // default to 5.7
    config.setVersion("5.7");
    config.setPassword(StringUtils.EMPTY.toCharArray());
    config.setConfirmPassword(StringUtils.EMPTY.toCharArray());
    // TODO(andy): remove the dependency to MySQLCreationAdvancedPanel
    config.setRegion(Utils.selectFirstOptionIfCurrentInvalid("region", MySQLCreationAdvancedPanel.loadSupportedRegions(az(AzureMySql.class), subscription.getId()), Region.US_EAST));
    return config;
}
Also used : DraftResourceGroup(com.microsoft.azure.toolkit.intellij.common.DraftResourceGroup) ToString(lombok.ToString) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Date(java.util.Date)

Aggregations

Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)64 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)13 Region (com.microsoft.azure.toolkit.lib.common.model.Region)9 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)9 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)7 ArrayList (java.util.ArrayList)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Project (com.intellij.openapi.project.Project)4 Azure (com.microsoft.azure.toolkit.lib.Azure)4 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)4 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)4 IOException (java.io.IOException)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 Point (org.eclipse.swt.graphics.Point)4 GridData (org.eclipse.swt.layout.GridData)4 Combo (org.eclipse.swt.widgets.Combo)4 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)3 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)3 EventType (com.microsoft.azuretools.telemetrywrapper.EventType)3 EventUtil (com.microsoft.azuretools.telemetrywrapper.EventUtil)3