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));
}
}
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);
});
}
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));
}
}
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);
}
}
}
}
Aggregations