use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AppInsightsMngmtPanel method updateApplicationInsightsResourceRegistry.
public static void updateApplicationInsightsResourceRegistry(List<SubscriptionDetail> subList, Project project) throws Exception {
// remove all resourecs that were not manually added
keeepManuallyAddedList(project);
for (SubscriptionDetail sub : subList) {
if (sub.isSelected()) {
try {
// fetch resources available for particular subscription
List<Resource> resourceList = AzureSDKManager.getApplicationInsightsResources(sub);
// Removal logic
List<ApplicationInsightsResource> importedList = ApplicationInsightsResourceRegistry.prepareAppResListFromRes(resourceList, sub);
// Addition logic
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().addAll(importedList);
} catch (Exception ex) {
AzurePlugin.log("Error loading AppInsights information for subscription '" + sub.getSubscriptionName() + "'");
}
}
}
AzureSettings.getSafeInstance(project).saveAppInsights();
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AppInsightsMngmtPanel method refreshDataForDialog.
public static void refreshDataForDialog() {
try {
Project project = PluginUtil.getSelectedProject();
if (AuthMethodManager.getInstance().isSignedIn()) {
List<SubscriptionDetail> subList = AuthMethodManager.getInstance().getAzureManager().getSubscriptionManager().getSubscriptionDetails();
// authenticated using AD. Proceed for updating application insights registry.
updateApplicationInsightsResourceRegistry(subList, project);
} else {
// Neither clear subscription list nor show sign in dialog as user may just want to add key manually.
keeepManuallyAddedList(project);
}
} catch (Exception ex) {
AzurePlugin.log(ex.getMessage());
}
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AzureModelController method updateResourceGroupMaps.
public static synchronized void updateResourceGroupMaps(IProgressIndicator progressIndicator) throws IOException, CanceledByUserException, AuthException {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
updateSubscriptionMaps(progressIndicator);
AzureModel azureModel = AzureModel.getInstance();
Map<ResourceGroup, List<WebApp>> rgwaMap = azureModel.createResourceGroupToWebAppMap();
Map<ResourceGroup, List<AppServicePlan>> rgspMap = azureModel.createResourceGroupToAppServicePlanMap();
for (SubscriptionDetail sd : azureModel.getSubscriptionToResourceGroupMap().keySet()) {
if (progressIndicator != null && progressIndicator.isCanceled()) {
clearAll();
throw new CanceledByUserException();
}
List<ResourceGroup> rgList = azureModel.getSubscriptionToResourceGroupMap().get(sd);
if (rgList.size() == 0) {
System.out.println("no resource groups found!");
continue;
}
Azure azure = azureManager.getAzure(sd.getSubscriptionId());
updateResGrDependency(azure, rgList, progressIndicator, rgwaMap, rgspMap);
}
azureModel.setResourceGroupToWebAppMap(rgwaMap);
azureModel.setResourceGroupToAppServicePlanMap(rgspMap);
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class AzureModule method composeName.
private static String composeName() {
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return BASE_MODULE_NAME + " (Not Signed In)";
}
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
List<SubscriptionDetail> selectedSubscriptions = subscriptionDetails.stream().filter(SubscriptionDetail::isSelected).collect(Collectors.toList());
if (selectedSubscriptions.size() > 0) {
return String.format("%s (%s)", BASE_MODULE_NAME, selectedSubscriptions.size() > 1 ? String.format("%s subscriptions", selectedSubscriptions.size()) : selectedSubscriptions.get(0).getSubscriptionName());
}
} catch (Exception e) {
String msg = "An error occurred while getting the subscription list." + "\n" + "(Message from Azure:" + e.getMessage() + ")";
DefaultLoader.getUIHelper().showException(msg, e, "MS Services - Error Getting Subscriptions", false, true);
}
return BASE_MODULE_NAME;
}
use of com.microsoft.azuretools.authmanage.models.SubscriptionDetail in project azure-tools-for-java by Microsoft.
the class SDKJarsFilter method setData.
private void setData() {
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
List<SubscriptionDetail> subList = azureManager.getSubscriptionManager().getSubscriptionDetails();
if (subList.size() > 0 && !ApplicationInsightsPreferences.isLoaded()) {
// if (manager.authenticated()) {
// authenticated using AD. Proceed for updating application insights registry.
ApplicationInsightsResourceRegistryEclipse.updateApplicationInsightsResourceRegistry(subList);
// } else {
// imported publish settings file. just show manually added list from preferences
// Neither clear subscription list nor show sign in dialog as user may just want to add key manually.
// ApplicationInsightsResourceRegistryEclipse.keeepManuallyAddedList();
// }
}
} catch (Exception ex) {
Activator.getDefault().log(ex.getMessage(), ex);
}
comboInstrumentationKey.removeAll();
String[] array = ApplicationInsightsResourceRegistry.getResourcesNamesToDisplay();
if (array.length > 0) {
comboInstrumentationKey.setItems(array);
comboInstrumentationKey.setText(array[0]);
}
}
Aggregations