use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class SubscriptionStep method loadSubscriptions.
private void loadSubscriptions() {
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
/*
* if (manager.authenticated()) { String upn =
* manager.getUserInfo().getUniqueName();
* userInfoLabel.setText("Signed in as: " + (upn.contains("#") ?
* upn.split("#")[1] : upn)); } else { userInfoLabel.setText(""); }
*/
List<Subscription> Subscriptions = AuthMethodManager.getInstance().getAzureManager().getSelectedSubscriptions();
for (Subscription subscription : Subscriptions) {
if (subscription.isSelected()) {
subscriptionComboBox.add(subscription.getName());
subscriptionComboBox.setData(subscription.getName(), subscription);
}
}
if (!Subscriptions.isEmpty()) {
subscriptionComboBox.select(0);
wizard.setSubscription((Subscription) subscriptionComboBox.getData(subscriptionComboBox.getText()));
}
setPageComplete(!Subscriptions.isEmpty());
} catch (Exception ex) {
DefaultLoader.getUIHelper().logError("An error occurred when trying to load Subscriptions\n\n" + ex.getMessage(), ex);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AzureLoginHelper method ensureAzureSubsAvailable.
public 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 SettingPanel method onComboSubscriptionSelection.
private void onComboSubscriptionSelection(ItemEvent event) {
if (event.getStateChange() != ItemEvent.SELECTED) {
return;
}
comboResourceGroup.removeAllItems();
cbLocation.removeAllItems();
final Subscription sb = (Subscription) comboSubscription.getSelectedItem();
if (sb != null) {
updateResourceGroupList(sb.getId());
updateLocationList(sb.getId());
}
}
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());
}
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AzureMySQLConfig method getDefaultAzureMySQLConfig.
public static AzureMySQLConfig getDefaultAzureMySQLConfig() {
final String defaultNameSuffix = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
final AzureMySQLConfig config = new AzureMySQLConfig();
final List<Subscription> selectedSubscriptions = az(AzureAccount.class).account().getSelectedSubscriptions();
Preconditions.checkArgument(CollectionUtils.isNotEmpty(selectedSubscriptions), "There are no subscriptions in your account.");
final Subscription subscription = selectedSubscriptions.get(0);
config.setSubscription(subscription);
final DraftResourceGroup resourceGroup = new DraftResourceGroup(subscription, "rs-" + defaultNameSuffix);
config.setResourceGroup(resourceGroup);
final AzureMySql azureMySql = az(AzureMySql.class).subscription(subscription.getId());
config.setServerName("mysql-" + defaultNameSuffix);
config.setAdminUsername(StringUtils.EMPTY);
// default to 5.7
config.setVersion("5.7");
config.setPassword(StringUtils.EMPTY.toCharArray());
config.setConfirmPassword(StringUtils.EMPTY.toCharArray());
// TODO(andy): remove the dependency to MySQLCreationAdvancedPanel
config.setRegion(Utils.selectFirstOptionIfCurrentInvalid("region", MySQLCreationAdvancedPanel.loadSupportedRegions(az(AzureMySql.class), subscription.getId()), Region.US_EAST));
return config;
}
Aggregations