public static AppServicePlan getAppServicePlan(final String servicePlanName, final Azure azureClient, final String resourceGroup, final String servicePlanResourceGroup) { if (StringUtils.isNotEmpty(servicePlanName)) { final String servicePlanResGrp = getAppServicePlanResourceGroup(resourceGroup, servicePlanResourceGroup); return azureClient.appServices().appServicePlans() .getByResourceGroup(servicePlanResGrp, servicePlanName); } return null; }
/** * List app service plan by subscription id. */ public List<AppServicePlan> listAppServicePlanBySubscriptionId(String sid) throws IOException { return AuthMethodManager.getInstance().getAzureClient(sid).appServices().appServicePlans().list(); }
/** * List app service plan by subscription id and resource group name. */ public List<AppServicePlan> listAppServicePlanBySubscriptionIdAndResourceGroupName(String sid, String group) { List<AppServicePlan> appServicePlans = new ArrayList<>(); try { Azure azure = AuthMethodManager.getInstance().getAzureClient(sid); appServicePlans.addAll(azure.appServices().appServicePlans().listByResourceGroup(group)); } catch (Exception e) { e.printStackTrace(); } return appServicePlans; }
.define(servicePlanName).withRegion(region);
.define(model.getAppServicePlanName()) .withRegion(Region.findByLabelOrName(model.getLocationName())) .withNewResourceGroup(model.getResourceGroupName()) .define(model.getAppServicePlanName()) .withRegion(Region.findByLabelOrName(model.getLocationName())) .withExistingResourceGroup(model.getResourceGroupName()) AppServicePlan asp = azure.appServices().appServicePlans().getById(model.getAppServicePlanId()); if (model.isCreatingNewResourceGroup()) {
public static void deleteAppService(WebAppDetails webAppDetails) throws IOException { AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager(); Azure azure = azureManager.getAzure(webAppDetails.subscriptionDetail.getSubscriptionId()); azure.webApps().deleteById(webAppDetails.webApp.id()); // check asp still exists AppServicePlan asp = azure.appServices().appServicePlans().getById(webAppDetails.appServicePlan.id()); System.out.println("asp is " + (asp == null ? "null -> removing form cache" : asp.name())); // update cache AzureModelController.removeWebAppFromResourceGroup(webAppDetails.resourceGroup, webAppDetails.webApp); if (asp == null) { AzureModelController.removeAppServicePlanFromResourceGroup(webAppDetails.appServicePlanResourceGroup, webAppDetails.appServicePlan); } }
@SuppressWarnings("unchecked") private AppServicePlanImpl newDefaultAppServicePlan() { String planName = SdkContext.randomResourceName(name() + "plan", 32); AppServicePlanImpl appServicePlan = (AppServicePlanImpl) (this.manager().appServicePlans() .define(planName)) .withRegion(regionName()); if (super.creatableGroup != null && isInCreateMode()) { appServicePlan = appServicePlan.withNewResourceGroup(super.creatableGroup); } else { appServicePlan = appServicePlan.withExistingResourceGroup(resourceGroupName()); } return appServicePlan; }
public void onLoadWebAppProperty(final String sid, @NotNull final String webAppId, @Nullable final String name) { Observable.fromCallable(() -> { final Azure azure = AuthMethodManager.getInstance().getAzureClient(sid); final WebAppBase appBase = getWebAppBase(sid, webAppId, name); final AppServicePlan plan = azure.appServices().appServicePlans().getById(appBase.appServicePlanId()); return generateProperty(appBase, plan); }).subscribeOn(getSchedulerProvider().io()) .subscribe(property -> DefaultLoader.getIdeHelper().invokeLater(() -> { if (isViewDetached()) { return; } getMvpView().showProperty(property); }), e -> errorHandler((Exception) e)); }
private AppServicePlan.DefinitionStages.WithCreate prepareWithCreate( @NotNull Azure azure, @NotNull WebAppSettingModel model) throws Exception { final String[] tierSize = model.getPricing().split("_"); if (tierSize.length != 2) { throw new Exception("Cannot get valid price tier"); } final PricingTier pricingTier = new PricingTier(tierSize[0], tierSize[1]); final AppServicePlan.DefinitionStages.WithGroup withGroup = azure .appServices() .appServicePlans() .define(model.getAppServicePlanName()) .withRegion(model.getRegion()); final AppServicePlan.DefinitionStages.WithPricingTier withPricingTier; final String resourceGroup = model.getResourceGroup(); if (model.isCreatingResGrp()) { withPricingTier = withGroup.withNewResourceGroup(resourceGroup); } else { withPricingTier = withGroup.withExistingResourceGroup(resourceGroup); } return withPricingTier.withPricingTier(pricingTier).withOperatingSystem(model.getOS()); }
private WebApp.DefinitionStages.WithDockerContainerImage withExistingLinuxServicePlan( @NotNull Azure azure, @NotNull WebAppSettingModel model) { AppServicePlan servicePlan = azure.appServices().appServicePlans().getById(model.getAppServicePlanId()); WebApp.DefinitionStages.ExistingLinuxPlanWithGroup withGroup = azure .webApps() .define(model.getWebAppName()) .withExistingLinuxPlan(servicePlan); if (model.isCreatingResGrp()) { return withGroup.withNewResourceGroup(model.getResourceGroup()); } return withGroup.withExistingResourceGroup(model.getResourceGroup()); }
public static AppServicePlan getAppServicePlan(final String servicePlanName, final Azure azureClient, final String resourceGroup, final String servicePlanResourceGroup) { if (StringUtils.isNotEmpty(servicePlanName)) { final String servicePlanResGrp = getAppServicePlanResourceGroup(resourceGroup, servicePlanResourceGroup); return azureClient.appServices().appServicePlans() .getByResourceGroup(servicePlanResGrp, servicePlanName); } return null; }
private WebApp.DefinitionStages.WithCreate withExistingWindowsServicePlan( @NotNull Azure azure, @NotNull WebAppSettingModel model) { AppServicePlan servicePlan = azure.appServices().appServicePlans().getById(model.getAppServicePlanId()); WebApp.DefinitionStages.ExistingWindowsPlanWithGroup withGroup = azure .webApps() .define(model.getWebAppName()) .withExistingWindowsPlan(servicePlan); if (model.isCreatingResGrp()) { return withGroup.withNewResourceGroup(model.getResourceGroup()); } return withGroup.withExistingResourceGroup(model.getResourceGroup()); }