use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class PublishWebAppOnLinuxDialog method getSelectedSubscription.
private Subscription getSelectedSubscription() {
Subscription sub = null;
int subsIndex = cpNew.cbSubscription.getSelectionIndex();
if (subscriptionList != null && subsIndex >= 0 && subsIndex < subscriptionList.size()) {
sub = subscriptionList.get(subsIndex);
}
return sub;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class PublishWebAppOnLinuxDialog method onResourceGroupSelection.
private void onResourceGroupSelection() {
cpNew.cbExistingAppServicePlan.removeAll();
cpNew.lblLocationValue.setText("");
cpNew.lblPricingTierValue.setText("");
Subscription sub = getSelectedSubscription();
ResourceGroup rg = getSelectedResourceGroup();
if (sub != null && rg != null) {
// TODO: a minor bug here, if rg is null, related labels should be set to "N/A"
webAppOnLinuxDeployPresenter.onLoadAppServicePlan(sub.getId(), rg.getName());
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class SignInCommandHandler method ensureAzureSubsAvailable.
private static void ensureAzureSubsAvailable() throws AzureExecutionException {
if (!AuthMethodManager.getInstance().isSignedIn()) {
throw new AzureExecutionException(NEED_SIGN_IN);
}
IdentityAzureManager azureManager = IdentityAzureManager.getInstance();
final List<Subscription> subscriptions = azureManager.getSubscriptions();
if (CollectionUtils.isEmpty(subscriptions)) {
throw new AzureExecutionException(NO_SUBSCRIPTION);
}
final List<Subscription> selectedSubscriptions = azureManager.getSelectedSubscriptions();
if (CollectionUtils.isEmpty(selectedSubscriptions)) {
throw new AzureExecutionException(MUST_SELECT_SUBSCRIPTION);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class ApplicationInsightsResourceRegistryEclipse method updateApplicationInsightsResourceRegistry.
/**
* Method updates application insights registry by adding, removing or updating resources.
* @param client
* @throws java.io.IOException
* @throws RestOperationException
* @throws AzureCmdException
*/
public static void updateApplicationInsightsResourceRegistry(List<Subscription> subList) throws Exception {
for (Subscription sub : subList) {
if (sub.isSelected()) {
try {
// fetch resources available for particular subscription
List<ApplicationInsightsComponent> resourceList = AzureSDKManager.getInsightsResources(sub.getId());
// Removal logic
List<ApplicationInsightsResource> registryList = ApplicationInsightsResourceRegistry.getResourceListAsPerSub(sub.getId());
List<ApplicationInsightsResource> importedList = ApplicationInsightsResourceRegistry.prepareAppResListFromRes(resourceList, sub);
List<String> inUsekeyList = getInUseInstrumentationKeys();
for (ApplicationInsightsResource registryRes : registryList) {
if (!importedList.contains(registryRes)) {
String key = registryRes.getInstrumentationKey();
int index = ApplicationInsightsResourceRegistry.getResourceIndexAsPerKey(key);
if (inUsekeyList.contains(key)) {
// key is used by project but not present in
// cloud,
// so make it as manually added resource and not
// imported.
ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(key, key, Messages.unknown, Messages.unknown, Messages.unknown, Messages.unknown, false);
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().set(index, resourceToAdd);
} else {
// key is not used by any project then delete
// it.
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().remove(index);
}
}
}
// Addition logic
List<ApplicationInsightsResource> list = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
for (ApplicationInsightsComponent resource : resourceList) {
ApplicationInsightsResource resourceToAdd = new ApplicationInsightsResource(resource, sub, true);
if (list.contains(resourceToAdd)) {
int index = ApplicationInsightsResourceRegistry.getResourceIndexAsPerKey(resource.instrumentationKey());
ApplicationInsightsResource objectFromRegistry = list.get(index);
if (!objectFromRegistry.isImported()) {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().set(index, resourceToAdd);
}
} else {
ApplicationInsightsResourceRegistry.getAppInsightsResrcList().add(resourceToAdd);
}
}
} catch (Exception e) {
Activator.getDefault().log(String.format(Messages.aiListErr, sub.getName()), e);
}
}
}
ApplicationInsightsPreferences.save();
ApplicationInsightsPreferences.setLoaded(true);
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class SettingPanel method onComboResourceGroupSelection.
private void onComboResourceGroupSelection(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
cbExistAppServicePlan.removeAllItems();
lblLocation.setText("");
lblPricing.setText("");
final Subscription sub = (Subscription) comboSubscription.getSelectedItem();
final ResourceGroup rg = (ResourceGroup) comboResourceGroup.getSelectedItem();
if (sub != null && rg != null) {
updateAppServicePlanList(sub.getId(), rg.getName());
}
}
}
Aggregations