use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method fillAppServicePlans.
protected void fillAppServicePlans() {
Subscription selectedSubscription = getSelectedSubscription();
if (selectedSubscription == null) {
return;
}
OperatingSystem os = getSelectedOS();
setComboRefreshingStatus(comboAppServicePlan, true);
Mono.fromCallable(() -> {
return Azure.az(AzureAppService.class).appServicePlans(selectedSubscription.getId(), false).stream().filter(asp -> asp.entity().getOperatingSystem() == null || asp.entity().getOperatingSystem() == os).collect(Collectors.toList());
}).subscribeOn(Schedulers.boundedElastic()).subscribe(appServicePlans -> {
appServicePlans.sort(Comparator.comparing(IAppServicePlan::name));
DefaultLoader.getIdeHelper().invokeLater(() -> {
setComboRefreshingStatus(comboAppServicePlan, false);
binderAppServicePlan = new ArrayList<>();
for (IAppServicePlan asp : appServicePlans) {
binderAppServicePlan.add(asp);
comboAppServicePlan.add(asp.name());
}
if (comboAppServicePlan.getItemCount() > 0) {
comboAppServicePlan.select(0);
}
String aspName = CommonUtils.getPreference(CommonUtils.ASP_NAME);
CommonUtils.selectComboIndex(comboAppServicePlan, aspName);
fillAppServicePlansDetails();
});
});
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AppServiceCreateDialog method fillRegions.
protected void fillRegions() {
Subscription selectedSubscription = getSelectedSubscription();
if (selectedSubscription == null) {
return;
}
setComboRefreshingStatus(comboAppServicePlanLocation, true);
Mono.fromCallable(() -> Azure.az(AzureAccount.class).listRegions(selectedSubscription.getId())).subscribeOn(Schedulers.boundedElastic()).subscribe(locl -> {
if (locl != null) {
binderAppServicePlanLocation = new ArrayList<>();
DefaultLoader.getIdeHelper().invokeLater(() -> {
for (int i = 0; i < locl.size(); i++) {
Region loc = locl.get(i);
comboAppServicePlanLocation.add(loc.getLabel());
binderAppServicePlanLocation.add(loc);
if (Objects.equals(loc, DEFAULT_REGION)) {
comboAppServicePlanLocation.select(i);
}
}
if (comboAppServicePlanLocation.getSelectionIndex() < 0 && comboAppServicePlanLocation.getItemCount() > 0) {
comboAppServicePlanLocation.select(0);
}
String aspLocation = CommonUtils.getPreference(ASP_CREATE_LOCATION);
CommonUtils.selectComboIndex(comboAppServicePlanLocation, aspLocation);
});
}
});
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class DatabaseResourcePanel method onSubscriptionChanged.
private void onSubscriptionChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final Subscription subscription = (Subscription) e.getItem();
this.serverComboBox.setSubscription(subscription);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
this.serverComboBox.setSubscription(null);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class CreateDeploymentForm method doOKAction.
@Override
protected void doOKAction() {
deploymentName = deploymentNameTextField.getText();
final AzureString title = AzureOperationBundle.title("arm|deployment.deploy", deploymentName);
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
EventUtil.executeWithLog(TelemetryConstants.ARM, TelemetryConstants.CREATE_DEPLOYMENT, (operation -> {
Subscription subs = (Subscription) subscriptionCb.getSelectedItem();
com.microsoft.azure.management.Azure azure = AuthMethodManager.getInstance().getAzureClient(subs.getId());
WithTemplate template;
if (createNewRgButton.isSelected()) {
rgName = rgNameTextFiled.getText();
final Region region = (Region) regionCb.getSelectedItem();
template = azure.deployments().define(deploymentName).withNewResourceGroup(rgNameTextFiled.getText(), com.microsoft.azure.management.resources.fluentcore.arm.Region.fromName(region.getName()));
} else {
ResourceGroup rg = (ResourceGroup) rgNameCb.getSelectedItem();
List<ResourceEx<Deployment>> deployments = AzureMvpModel.getInstance().getDeploymentByRgName(subs.getId(), rg.getName());
boolean isExist = deployments.parallelStream().anyMatch(deployment -> deployment.getResource().name().equals(deploymentName));
if (isExist) {
throw new RuntimeException(DUPLICATED_DEPLOYMENT_NAME);
}
rgName = rg.getName();
template = azure.deployments().define(deploymentName).withExistingResourceGroup(rg.getName());
}
String fileText = templateTextField.getText();
String content = IOUtils.toString(new FileReader(fileText));
String parametersPath = parametersTextField.getText();
String parameters = StringUtils.isEmpty(parametersPath) ? "{}" : IOUtils.toString(new FileReader(parametersPath));
parameters = DeploymentUtils.parseParameters(parameters);
template.withTemplate(content).withParameters(parameters).withMode(DeploymentMode.INCREMENTAL).create();
UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
updateUI();
}), (ex) -> {
UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_FAIL + ", " + ex.getMessage(), MessageType.ERROR);
updateUI();
});
}));
close(DialogWrapper.OK_EXIT_CODE, true);
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class CreateDeploymentForm method fillResourceGroup.
private void fillResourceGroup() {
if (subscriptionCb.getSelectedItem() == null) {
return;
}
String sid = ((Subscription) subscriptionCb.getSelectedItem()).getId();
rgNameCb.removeAllItems();
for (ResourceEx<ResourceGroup> rg : AzureMvpModel.getInstance().getResourceGroups(sid)) {
rgNameCb.addItem(rg.getResource());
}
}
Aggregations