Search in sources :

Example 6 with PricingTier

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

the class AppServiceCreateDialog method fillPricingTiers.

protected void fillPricingTiers() {
    try {
        comboAppServicePlanPricingTier.removeAll();
        binderAppServicePlanPricingTier = new ArrayList<>();
        final List<PricingTier> pricingTiers = AzureMvpModel.getInstance().listPricingTier();
        for (int i = 0; i < pricingTiers.size(); i++) {
            PricingTier pricingTier = pricingTiers.get(i);
            comboAppServicePlanPricingTier.add(pricingTier.toString());
            binderAppServicePlanPricingTier.add(pricingTier);
            if (pricingTier.equals(DEFAULT_PRICINGTIER)) {
                comboAppServicePlanPricingTier.select(i);
            }
        }
        if (comboAppServicePlanPricingTier.getSelectionIndex() < 0 && comboAppServicePlanPricingTier.getItemCount() > 0) {
            comboAppServicePlanPricingTier.select(0);
        }
        String aspPricing = CommonUtils.getPreference(ASP_CREATE_PRICING);
        CommonUtils.selectComboIndex(comboAppServicePlanPricingTier, aspPricing);
    } catch (Exception ex) {
        LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "fillAppServicePlanPricingTiers@AppServiceCreateDialog", ex));
    }
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) Point(org.eclipse.swt.graphics.Point) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException)

Example 7 with PricingTier

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

the class WebAppConfigFormPanelAdvance method createUIComponents.

private void createUIComponents() {
    // TODO: place custom component creation code here
    appServiceConfigPanelAdvanced = new AppServiceInfoAdvancedPanel(project, WebAppConfig::getWebAppDefaultConfig);
    final List<PricingTier> validPricing = AzureMvpModel.getInstance().listPricingTier();
    appServiceConfigPanelAdvanced.setValidPricingTier(validPricing, WebAppConfig.DEFAULT_PRICING_TIER);
    appServiceMonitorPanel = new AppServiceMonitorPanel(project);
    // Application Insights is not supported in Web App
    appServiceMonitorPanel.setApplicationInsightsVisible(false);
    appServiceMonitorPanel.setData(MonitorConfig.builder().build());
    appServiceConfigPanelAdvanced.getSelectorRuntime().addActionListener(event -> {
        final Runtime runtime = appServiceConfigPanelAdvanced.getSelectorRuntime().getValue();
        appServiceMonitorPanel.setApplicationLogVisible(runtime != null && runtime.getOperatingSystem() == OperatingSystem.WINDOWS);
    });
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AppServiceInfoAdvancedPanel(com.microsoft.azure.toolkit.intellij.appservice.AppServiceInfoAdvancedPanel) AppServiceMonitorPanel(com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)

Example 8 with PricingTier

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

the class SettingPanel method resetFromConfig.

/**
 * Function triggered in constructing the panel.
 *
 * @param conf configuration instance
 */
@Override
public void resetFromConfig(@NotNull WebAppOnLinuxDeployConfiguration conf) {
    if (!isMavenProject()) {
        containerSettingPanel.setDockerPath(DockerUtil.getDefaultDockerFilePathIfExist(getProjectBasePath()));
    }
    // load dockerFile path from existing configuration.
    if (!Utils.isEmptyString(conf.getDockerFilePath())) {
        containerSettingPanel.setDockerPath(conf.getDockerFilePath());
    }
    final PrivateRegistryImageSetting acrInfo = conf.getPrivateRegistryImageSetting();
    if (StringUtils.isNotEmpty(acrInfo.getServerUrl())) {
        final ISecureStore secureStore = AzureStoreManager.getInstance().getSecureStore();
        secureStore.migratePassword(acrInfo.getServerUrl(), acrInfo.getUsername(), PRIVATE_DOCKER_REGISTRY, acrInfo.getServerUrl(), acrInfo.getUsername());
        acrInfo.setPassword(secureStore.loadPassword(PRIVATE_DOCKER_REGISTRY, acrInfo.getServerUrl(), acrInfo.getUsername()));
    }
    containerSettingPanel.setTxtFields(acrInfo);
    // cache for table/combo selection
    defaultSubscriptionId = conf.getSubscriptionId();
    defaultWebAppId = conf.getWebAppId();
    defaultLocationName = conf.getLocationName();
    defaultPricingTier = StringUtils.isEmpty(conf.getPricingSkuTier()) ? Constant.WEBAPP_CONTAINER_DEFAULT_PRICING_TIER : new PricingTier(conf.getPricingSkuTier(), conf.getPricingSkuSize()).toString();
    defaultResourceGroup = conf.getResourceGroupName();
    defaultAppServicePlanId = conf.getAppServicePlanId();
    // pnlUseExisting
    loadWebAppList();
    // pnlCreateNew
    // including related RG & Region
    webAppOnLinuxDeployPresenter.onLoadSubscriptionList();
    webAppOnLinuxDeployPresenter.onLoadPricingTierList();
    final boolean creatingRg = conf.isCreatingNewResourceGroup();
    rdoCreateResGrp.setSelected(creatingRg);
    rdoUseExistResGrp.setSelected(!creatingRg);
    updateResourceGroupEnabled();
    if (creatingRg) {
        txtNewResGrp.setText(conf.getResourceGroupName());
    }
    final boolean creatingAsp = conf.isCreatingNewAppServicePlan();
    rdoCreateAppServicePlan.setSelected(creatingAsp);
    rdoUseExistAppServicePlan.setSelected(!creatingAsp);
    updateAppServicePlanEnabled();
    if (creatingAsp) {
        txtCreateAppServicePlan.setText(conf.getAppServicePlanName());
    }
    // active panel
    final boolean creatingApp = conf.isCreatingNewWebAppOnLinux();
    if (creatingApp) {
        textAppName.setText(conf.getAppName());
    }
    rdoCreateNew.setSelected(creatingApp);
    rdoUseExist.setSelected(!creatingApp);
    updatePanelVisibility();
    // default value for new resources
    final DateFormat df = new SimpleDateFormat("yyMMddHHmmss");
    final String date = df.format(new Date());
    if (Utils.isEmptyString(textAppName.getText())) {
        textAppName.setText(String.format("%s-%s", APP_NAME_PREFIX, date));
    }
    if (Utils.isEmptyString(txtNewResGrp.getText())) {
        txtNewResGrp.setText(String.format("%s-%s", RESOURCE_GROUP_NAME_PREFIX, date));
    }
    if (Utils.isEmptyString(txtCreateAppServicePlan.getText())) {
        txtCreateAppServicePlan.setText(String.format("%s-%s", APP_SERVICE_PLAN_NAME_PREFIX, date));
    }
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) ISecureStore(com.microsoft.azure.toolkit.ide.common.store.ISecureStore) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 9 with PricingTier

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

the class SettingPanel method apply.

/**
 * Function triggered by any content change events.
 *
 * @param webAppOnLinuxDeployConfiguration configuration instance
 */
@Override
public void apply(WebAppOnLinuxDeployConfiguration webAppOnLinuxDeployConfiguration) {
    webAppOnLinuxDeployConfiguration.setDockerFilePath(containerSettingPanel.getDockerPath());
    // set ACR info
    webAppOnLinuxDeployConfiguration.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(containerSettingPanel.getServerUrl().replaceFirst("^https?://", "").replaceFirst("/$", ""), containerSettingPanel.getUserName(), containerSettingPanel.getPassword(), containerSettingPanel.getImageTag(), containerSettingPanel.getStartupFile()));
    final ISecureStore secureStore = AzureStoreManager.getInstance().getSecureStore();
    secureStore.savePassword(PRIVATE_DOCKER_REGISTRY, containerSettingPanel.getServerUrl(), containerSettingPanel.getUserName(), containerSettingPanel.getPassword());
    webAppOnLinuxDeployConfiguration.setTargetPath(getTargetPath());
    webAppOnLinuxDeployConfiguration.setTargetName(getTargetName());
    // set web app info
    if (rdoUseExist.isSelected()) {
        // existing web app
        webAppOnLinuxDeployConfiguration.setCreatingNewWebAppOnLinux(false);
        IWebApp selectedWebApp = null;
        final int index = webAppTable.getSelectedRow();
        if (cachedWebAppList != null && index >= 0 && index < cachedWebAppList.size()) {
            selectedWebApp = cachedWebAppList.get(webAppTable.getSelectedRow());
        }
        if (selectedWebApp != null) {
            webAppOnLinuxDeployConfiguration.setWebAppId(selectedWebApp.id());
            webAppOnLinuxDeployConfiguration.setAppName(selectedWebApp.name());
            webAppOnLinuxDeployConfiguration.setSubscriptionId(selectedWebApp.subscriptionId());
            webAppOnLinuxDeployConfiguration.setResourceGroupName(selectedWebApp.resourceGroup());
        } else {
            webAppOnLinuxDeployConfiguration.setWebAppId(null);
            webAppOnLinuxDeployConfiguration.setAppName(null);
            webAppOnLinuxDeployConfiguration.setSubscriptionId(null);
            webAppOnLinuxDeployConfiguration.setResourceGroupName(null);
        }
    } else if (rdoCreateNew.isSelected()) {
        // create new web app
        webAppOnLinuxDeployConfiguration.setCreatingNewWebAppOnLinux(true);
        webAppOnLinuxDeployConfiguration.setWebAppId("");
        webAppOnLinuxDeployConfiguration.setAppName(textAppName.getText());
        final Subscription selectedSubscription = (Subscription) comboSubscription.getSelectedItem();
        if (selectedSubscription != null) {
            webAppOnLinuxDeployConfiguration.setSubscriptionId(selectedSubscription.getId());
        }
        // resource group
        if (rdoUseExistResGrp.isSelected()) {
            // existing RG
            webAppOnLinuxDeployConfiguration.setCreatingNewResourceGroup(false);
            final ResourceGroup selectedRg = (ResourceGroup) comboResourceGroup.getSelectedItem();
            if (selectedRg != null) {
                webAppOnLinuxDeployConfiguration.setResourceGroupName(selectedRg.getName());
            } else {
                webAppOnLinuxDeployConfiguration.setResourceGroupName(null);
            }
        } else if (rdoCreateResGrp.isSelected()) {
            // new RG
            webAppOnLinuxDeployConfiguration.setCreatingNewResourceGroup(true);
            webAppOnLinuxDeployConfiguration.setResourceGroupName(txtNewResGrp.getText());
        }
        // app service plan
        if (rdoCreateAppServicePlan.isSelected()) {
            webAppOnLinuxDeployConfiguration.setCreatingNewAppServicePlan(true);
            webAppOnLinuxDeployConfiguration.setAppServicePlanName(txtCreateAppServicePlan.getText());
            final Region selectedLocation = (Region) cbLocation.getSelectedItem();
            if (selectedLocation != null) {
                webAppOnLinuxDeployConfiguration.setLocationName(selectedLocation.getName());
            } else {
                webAppOnLinuxDeployConfiguration.setLocationName(null);
            }
            final PricingTier selectedPricingTier = (PricingTier) cbPricing.getSelectedItem();
            if (selectedPricingTier != null) {
                webAppOnLinuxDeployConfiguration.setPricingSkuTier(selectedPricingTier.getTier());
                webAppOnLinuxDeployConfiguration.setPricingSkuSize(selectedPricingTier.getSize());
            } else {
                webAppOnLinuxDeployConfiguration.setPricingSkuTier(null);
                webAppOnLinuxDeployConfiguration.setPricingSkuSize(null);
            }
        } else if (rdoUseExistAppServicePlan.isSelected()) {
            webAppOnLinuxDeployConfiguration.setCreatingNewAppServicePlan(false);
            final AppServicePlan selectedAsp = (AppServicePlan) cbExistAppServicePlan.getSelectedItem();
            if (selectedAsp != null) {
                webAppOnLinuxDeployConfiguration.setAppServicePlanId(selectedAsp.id());
            } else {
                webAppOnLinuxDeployConfiguration.setAppServicePlanId(null);
            }
        }
    }
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) ISecureStore(com.microsoft.azure.toolkit.ide.common.store.ISecureStore) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) AppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.impl.AppServicePlan)

Aggregations

PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)9 Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)3 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)3 Point (org.eclipse.swt.graphics.Point)3 ISecureStore (com.microsoft.azure.toolkit.ide.common.store.ISecureStore)2 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)2 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)2 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)2 AppServiceInfoAdvancedPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceInfoAdvancedPanel)1 AppServiceMonitorPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)1 AppServiceBaseEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity)1 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)1 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)1 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)1 AppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.impl.AppServicePlan)1 WebAppProperty (com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)1 MalformedURLException (java.net.MalformedURLException)1 DateFormat (java.text.DateFormat)1