Search in sources :

Example 61 with Subscription

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

the class PublishWebAppOnLinuxDialog method getSelectedSubscription.

private Subscription getSelectedSubscription() {
    Subscription sub = null;
    int subsIndex = cpNew.cbSubscription.getSelectionIndex();
    if (subscriptionList != null && subsIndex >= 0 && subsIndex < subscriptionList.size()) {
        sub = subscriptionList.get(subsIndex);
    }
    return sub;
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Point(org.eclipse.swt.graphics.Point)

Example 62 with Subscription

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

the class PublishWebAppOnLinuxDialog method onResourceGroupSelection.

private void onResourceGroupSelection() {
    cpNew.cbExistingAppServicePlan.removeAll();
    cpNew.lblLocationValue.setText("");
    cpNew.lblPricingTierValue.setText("");
    Subscription sub = getSelectedSubscription();
    ResourceGroup rg = getSelectedResourceGroup();
    if (sub != null && rg != null) {
        // TODO: a minor bug here, if rg is null, related labels should be set to "N/A"
        webAppOnLinuxDeployPresenter.onLoadAppServicePlan(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 63 with Subscription

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

Example 64 with Subscription

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

the class ApplicationInsightsResourceRegistryEclipse method updateApplicationInsightsResourceRegistry.

/**
 * Method updates application insights registry by adding, removing or updating resources.
 * @param client
 * @throws java.io.IOException
 * @throws RestOperationException
 * @throws AzureCmdException
 */
public static void updateApplicationInsightsResourceRegistry(List<Subscription> subList) throws Exception {
    for (Subscription sub : subList) {
        if (sub.isSelected()) {
            try {
                // fetch resources available for particular subscription
                List<ApplicationInsightsComponent> resourceList = AzureSDKManager.getInsightsResources(sub.getId());
                // Removal logic
                List<ApplicationInsightsResource> registryList = ApplicationInsightsResourceRegistry.getResourceListAsPerSub(sub.getId());
                List<ApplicationInsightsResource> importedList = ApplicationInsightsResourceRegistry.prepareAppResListFromRes(resourceList, sub);
                List<String> inUsekeyList = getInUseInstrumentationKeys();
                for (ApplicationInsightsResource registryRes : registryList) {
                    if (!importedList.contains(registryRes)) {
                        String key = registryRes.getInstrumentationKey();
                        int index = ApplicationInsightsResourceRegistry.getResourceIndexAsPerKey(key);
                        if (inUsekeyList.contains(key)) {
                            // key is used by project but not present in
                            // cloud,
                            // so make it as manually added resource and not
                            // imported.
                            ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(key, key, Messages.unknown, Messages.unknown, Messages.unknown, Messages.unknown, false);
                            ApplicationInsightsResourceRegistry.getAppInsightsResrcList().set(index, resourceToAdd);
                        } else {
                            // key is not used by any project then delete
                            // it.
                            ApplicationInsightsResourceRegistry.getAppInsightsResrcList().remove(index);
                        }
                    }
                }
                // Addition logic
                List<ApplicationInsightsResource> list = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
                for (ApplicationInsightsComponent resource : resourceList) {
                    ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(resource, sub, true);
                    if (list.contains(resourceToAdd)) {
                        int index = ApplicationInsightsResourceRegistry.getResourceIndexAsPerKey(resource.instrumentationKey());
                        ApplicationInsightsResource objectFromRegistry = list.get(index);
                        if (!objectFromRegistry.isImported()) {
                            ApplicationInsightsResourceRegistry.getAppInsightsResrcList().set(index, resourceToAdd);
                        }
                    } else {
                        ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resourceToAdd);
                    }
                }
            } catch (Exception e) {
                Activator.getDefault().log(String.format(Messages.aiListErr, sub.getName()), e);
            }
        }
    }
    ApplicationInsightsPreferences.save();
    ApplicationInsightsPreferences.setLoaded(true);
}
Also used : ApplicationInsightsResource(com.microsoft.applicationinsights.preference.ApplicationInsightsResource) ApplicationInsightsComponent(com.microsoft.azure.management.applicationinsights.v2015_05_01.ApplicationInsightsComponent) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) IOException(java.io.IOException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 65 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)

Aggregations

Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)139 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)26 Region (com.microsoft.azure.toolkit.lib.common.model.Region)18 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)18 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)17 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Project (com.intellij.openapi.project.Project)8 Azure (com.microsoft.azure.toolkit.lib.Azure)8 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)8 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)8 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)8 HashMap (java.util.HashMap)8 List (java.util.List)8 StringUtils (org.apache.commons.lang3.StringUtils)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 GridData (org.eclipse.swt.layout.GridData)8 Combo (org.eclipse.swt.widgets.Combo)8