Search in sources :

Example 1 with PricingTier

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

the class PublishWebAppOnLinuxDialog method apply.

private void apply() {
    model.setDockerFilePath(cpAcr.getDockerfilePath());
    // set ACR info
    model.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(cpAcr.getServerUrl(), cpAcr.getUserName(), cpAcr.getPassword(), cpAcr.getImageTag(), cpAcr.getStartupFile()));
    // set target
    model.setTargetPath(targetPath);
    model.setTargetName(Paths.get(targetPath).getFileName().toString());
    // set web app info
    if (rdoExistingWebApp.getSelection()) {
        // existing web app
        model.setCreatingNewWebAppOnLinux(false);
        IWebApp selectedWebApp = getSelectedWebApp();
        if (selectedWebApp != null) {
            model.setWebAppId(selectedWebApp.id());
            model.setWebAppName(selectedWebApp.name());
            model.setSubscriptionId(selectedWebApp.subscriptionId());
            model.setResourceGroupName(selectedWebApp.resourceGroup());
        } else {
            model.setWebAppId(null);
            model.setWebAppName(null);
            model.setSubscriptionId(null);
            model.setResourceGroupName(null);
        }
    } else if (rdoNewWebApp.getSelection()) {
        // create new web app
        model.setCreatingNewWebAppOnLinux(true);
        model.setWebAppId("");
        model.setWebAppName(cpNew.txtAppName.getText());
        Subscription selectedSubscription = getSelectedSubscription();
        if (selectedSubscription != null) {
            model.setSubscriptionId(selectedSubscription.getId());
        }
        // resource group
        if (cpNew.rdoExistingResourceGroup.getSelection()) {
            // existing RG
            model.setCreatingNewResourceGroup(false);
            ResourceGroup selectedRg = getSelectedResourceGroup();
            if (selectedRg != null) {
                model.setResourceGroupName(selectedRg.getName());
            } else {
                model.setResourceGroupName(null);
            }
        } else if (cpNew.rdoNewResourceGroup.getSelection()) {
            // new RG
            model.setCreatingNewResourceGroup(true);
            model.setResourceGroupName(cpNew.txtNewResourceGroupName.getText());
        }
        // app service plan
        if (cpNew.rdoNewAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(true);
            model.setAppServicePlanName(cpNew.txtAppServicePlanName.getText());
            Region selectedLocation = getSelectedLocation();
            if (selectedLocation != null) {
                model.setLocationName(selectedLocation.getLabel());
            } else {
                model.setLocationName(null);
            }
            PricingTier selectedPricingTier = getSelectedPricingTier();
            if (selectedPricingTier != null) {
                model.setPricingSkuTier(selectedPricingTier.getTier());
                model.setPricingSkuSize(selectedPricingTier.getSize());
            } else {
                model.setPricingSkuTier(null);
                model.setPricingSkuSize(null);
            }
        } else if (cpNew.rdoExistingAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(false);
            IAppServicePlan selectedAsp = getSelectedAppServicePlan();
            if (selectedAsp != null) {
                model.setAppServicePlanId(selectedAsp.id());
            } else {
                model.setAppServicePlanId(null);
            }
        }
    }
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) 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)

Example 2 with PricingTier

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

the class AppServiceCreateDialog method collectData.

private void collectData() {
    model.setCreatingNew(true);
    model.setWebAppName(textAppName.getText().trim());
    int index = comboSubscription.getSelectionIndex();
    model.setSubscriptionId(index < 0 ? null : binderSubscriptionDetails.get(index).getId());
    // Resource Group
    boolean isCreatingNewResGrp = btnResourceGroupCreateNew.getSelection();
    model.setCreatingResGrp(isCreatingNewResGrp);
    if (isCreatingNewResGrp) {
        model.setResourceGroup(textResourceGroupName.getText().trim());
    } else {
        index = comboResourceGroup.getSelectionIndex();
        model.setResourceGroup(index < 0 ? null : binderResourceGroup.get(index).getName());
    }
    // App Service Plan
    boolean isCreatingAppServicePlan = btnAppServiceCreateNew.getSelection();
    model.setCreatingAppServicePlan(isCreatingAppServicePlan);
    if (isCreatingAppServicePlan) {
        model.setAppServicePlanName(textAppSevicePlanName.getText().trim());
        index = comboAppServicePlanLocation.getSelectionIndex();
        model.setRegion(index < 0 ? null : binderAppServicePlanLocation.get(index).getName());
        model.setPricing(Optional.ofNullable(getSelectedPricingTier()).map(PricingTier::toString).orElse(APPSETTINGS_TOOLTIP));
    } else {
        index = comboAppServicePlan.getSelectionIndex();
        model.setAppServicePlanId(index < 0 ? null : binderAppServicePlan.get(index).id());
    }
    // Runtime
    final OperatingSystem os = getSelectedOS();
    final Runtime runtime = os == OperatingSystem.LINUX ? getSelectedRuntimeStack() : Runtime.getRuntime(OperatingSystem.WINDOWS, getSelectedWebcontainer(), getSelectedJavaVersion());
    model.saveRuntime(runtime);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Point(org.eclipse.swt.graphics.Point)

Example 3 with PricingTier

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

the class WebAppBasePropertyViewPresenter method generateProperty.

protected <T extends AppServiceBaseEntity> WebAppProperty generateProperty(@Nonnull final IAppService<T> appService, @Nonnull final IAppServicePlan plan) {
    final AppServiceBaseEntity appServiceEntity = appService.entity();
    final AppServicePlanEntity planEntity = plan.entity();
    final Map<String, String> appSettingsMap = appServiceEntity.getAppSettings();
    final Map<String, Object> propertyMap = new HashMap<>();
    propertyMap.put(KEY_NAME, appServiceEntity.getName());
    propertyMap.put(KEY_RESOURCE_GRP, appServiceEntity.getResourceGroup());
    propertyMap.put(KEY_LOCATION, appServiceEntity.getRegion().getLabel());
    propertyMap.put(KEY_SUB_ID, appService.subscriptionId());
    propertyMap.put(KEY_STATUS, appService.state());
    propertyMap.put(KEY_PLAN, plan.name());
    propertyMap.put(KEY_URL, appService.hostName());
    final PricingTier pricingTier = planEntity.getPricingTier();
    propertyMap.put(KEY_PRICING, String.format("%s_%s", pricingTier.getTier(), pricingTier.getSize()));
    final Runtime runtime = appService.getRuntime();
    final JavaVersion javaVersion = runtime.getJavaVersion();
    if (javaVersion != null && ObjectUtils.notEqual(javaVersion, JavaVersion.OFF)) {
        propertyMap.put(KEY_JAVA_VERSION, javaVersion.getValue());
        propertyMap.put(KEY_JAVA_CONTAINER, runtime.getWebContainer().getValue());
    }
    propertyMap.put(KEY_OPERATING_SYS, runtime.getOperatingSystem());
    propertyMap.put(KEY_APP_SETTING, appSettingsMap);
    return new WebAppProperty(propertyMap);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AppServiceBaseEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) HashMap(java.util.HashMap) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) WebAppProperty(com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)

Example 4 with PricingTier

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

the class PublishWebAppOnLinuxDialog method renderPricingTierList.

@Override
public void renderPricingTierList(List<PricingTier> list) {
    // TODO Auto-generated method stub
    pricingTierList = list;
    cpNew.cbPricingTier.removeAll();
    for (PricingTier pt : pricingTierList) {
        cpNew.cbPricingTier.add(pt.toString());
    }
    if (cpNew.cbPricingTier.getItemCount() > 0) {
        cpNew.cbPricingTier.select(0);
    }
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)

Example 5 with PricingTier

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

the class PublishWebAppOnLinuxDialog method getSelectedPricingTier.

private PricingTier getSelectedPricingTier() {
    PricingTier pt = null;
    int index = cpNew.cbPricingTier.getSelectionIndex();
    if (pricingTierList != null && index >= 0 && index < pricingTierList.size()) {
        pt = pricingTierList.get(index);
    }
    return pt;
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Point(org.eclipse.swt.graphics.Point)

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