use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.
the class SettingPanel method apply.
/**
* Function triggered by any content change events.
*
* @param webAppOnLinuxDeployConfiguration configuration instance
*/
@Override
public void apply(WebAppOnLinuxDeployConfiguration webAppOnLinuxDeployConfiguration) {
webAppOnLinuxDeployConfiguration.setDockerFilePath(containerSettingPanel.getDockerPath());
// set ACR info
webAppOnLinuxDeployConfiguration.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(containerSettingPanel.getServerUrl().replaceFirst("^https?://", "").replaceFirst("/$", ""), containerSettingPanel.getUserName(), containerSettingPanel.getPassword(), containerSettingPanel.getImageTag(), containerSettingPanel.getStartupFile()));
final ISecureStore secureStore = AzureStoreManager.getInstance().getSecureStore();
secureStore.savePassword(PRIVATE_DOCKER_REGISTRY, containerSettingPanel.getServerUrl(), containerSettingPanel.getUserName(), containerSettingPanel.getPassword());
webAppOnLinuxDeployConfiguration.setTargetPath(getTargetPath());
webAppOnLinuxDeployConfiguration.setTargetName(getTargetName());
// set web app info
if (rdoUseExist.isSelected()) {
// existing web app
webAppOnLinuxDeployConfiguration.setCreatingNewWebAppOnLinux(false);
IWebApp selectedWebApp = null;
final int index = webAppTable.getSelectedRow();
if (cachedWebAppList != null && index >= 0 && index < cachedWebAppList.size()) {
selectedWebApp = cachedWebAppList.get(webAppTable.getSelectedRow());
}
if (selectedWebApp != null) {
webAppOnLinuxDeployConfiguration.setWebAppId(selectedWebApp.id());
webAppOnLinuxDeployConfiguration.setAppName(selectedWebApp.name());
webAppOnLinuxDeployConfiguration.setSubscriptionId(selectedWebApp.subscriptionId());
webAppOnLinuxDeployConfiguration.setResourceGroupName(selectedWebApp.resourceGroup());
} else {
webAppOnLinuxDeployConfiguration.setWebAppId(null);
webAppOnLinuxDeployConfiguration.setAppName(null);
webAppOnLinuxDeployConfiguration.setSubscriptionId(null);
webAppOnLinuxDeployConfiguration.setResourceGroupName(null);
}
} else if (rdoCreateNew.isSelected()) {
// create new web app
webAppOnLinuxDeployConfiguration.setCreatingNewWebAppOnLinux(true);
webAppOnLinuxDeployConfiguration.setWebAppId("");
webAppOnLinuxDeployConfiguration.setAppName(textAppName.getText());
final Subscription selectedSubscription = (Subscription) comboSubscription.getSelectedItem();
if (selectedSubscription != null) {
webAppOnLinuxDeployConfiguration.setSubscriptionId(selectedSubscription.getId());
}
// resource group
if (rdoUseExistResGrp.isSelected()) {
// existing RG
webAppOnLinuxDeployConfiguration.setCreatingNewResourceGroup(false);
final ResourceGroup selectedRg = (ResourceGroup) comboResourceGroup.getSelectedItem();
if (selectedRg != null) {
webAppOnLinuxDeployConfiguration.setResourceGroupName(selectedRg.getName());
} else {
webAppOnLinuxDeployConfiguration.setResourceGroupName(null);
}
} else if (rdoCreateResGrp.isSelected()) {
// new RG
webAppOnLinuxDeployConfiguration.setCreatingNewResourceGroup(true);
webAppOnLinuxDeployConfiguration.setResourceGroupName(txtNewResGrp.getText());
}
// app service plan
if (rdoCreateAppServicePlan.isSelected()) {
webAppOnLinuxDeployConfiguration.setCreatingNewAppServicePlan(true);
webAppOnLinuxDeployConfiguration.setAppServicePlanName(txtCreateAppServicePlan.getText());
final Region selectedLocation = (Region) cbLocation.getSelectedItem();
if (selectedLocation != null) {
webAppOnLinuxDeployConfiguration.setLocationName(selectedLocation.getName());
} else {
webAppOnLinuxDeployConfiguration.setLocationName(null);
}
final PricingTier selectedPricingTier = (PricingTier) cbPricing.getSelectedItem();
if (selectedPricingTier != null) {
webAppOnLinuxDeployConfiguration.setPricingSkuTier(selectedPricingTier.getTier());
webAppOnLinuxDeployConfiguration.setPricingSkuSize(selectedPricingTier.getSize());
} else {
webAppOnLinuxDeployConfiguration.setPricingSkuTier(null);
webAppOnLinuxDeployConfiguration.setPricingSkuSize(null);
}
} else if (rdoUseExistAppServicePlan.isSelected()) {
webAppOnLinuxDeployConfiguration.setCreatingNewAppServicePlan(false);
final AppServicePlan selectedAsp = (AppServicePlan) cbExistAppServicePlan.getSelectedItem();
if (selectedAsp != null) {
webAppOnLinuxDeployConfiguration.setAppServicePlanId(selectedAsp.id());
} else {
webAppOnLinuxDeployConfiguration.setAppServicePlanId(null);
}
}
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-gradle-plugins by microsoft.
the class GradleAuthHelper method login.
public static String login(GradleAuthConfig auth, String subscriptionId) {
try {
Account account = login(toAuthConfiguration(ObjectUtils.firstNonNull(auth, new GradleAuthConfig())));
final List<Subscription> subscriptions = account.getSubscriptions();
final String targetSubscriptionId = getTargetSubscriptionId(subscriptionId, subscriptions, account.getSelectedSubscriptions());
checkSubscription(subscriptions, targetSubscriptionId);
Azure.az(AzureAccount.class).account().selectSubscription(Collections.singletonList(targetSubscriptionId));
printCurrentSubscription(account);
return targetSubscriptionId;
} catch (InvalidConfigurationException e) {
throw new AzureToolkitAuthenticationException("Failed to authenticate with Azure due to error: " + e.getMessage());
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-gradle-plugins by microsoft.
the class GradleAuthHelper method getTargetSubscriptionId.
private static String getTargetSubscriptionId(String defaultSubscriptionId, List<Subscription> subscriptions, List<Subscription> selectedSubscriptions) {
String targetSubscriptionId = defaultSubscriptionId;
if (StringUtils.isBlank(targetSubscriptionId) && !selectedSubscriptions.isEmpty()) {
targetSubscriptionId = selectedSubscriptions.stream().filter(Subscription::isSelected).map(Subscription::getId).findFirst().orElse(null);
}
if (StringUtils.isBlank(targetSubscriptionId) && !subscriptions.isEmpty()) {
targetSubscriptionId = subscriptions.stream().map(Subscription::getId).findFirst().orElse(null);
}
TelemetryAgent.getInstance().addDefaultProperty(TelemetryConstants.SUBSCRIPTION_ID_KEY, targetSubscriptionId);
return targetSubscriptionId;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class CreateRedisCacheForm method initWidgetListeners.
private void initWidgetListeners() {
txtRedisName.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
});
cbSubs.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
currentSub = (Subscription) cbSubs.getSelectedItem();
cbLocations.setSubscription(currentSub);
fillResourceGrps(currentSub);
validateEmptyFields();
}
});
rdoCreateNewGrp.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
txtNewResGrp.setVisible(true);
cbUseExist.setVisible(false);
newResGrp = true;
validateEmptyFields();
}
});
txtNewResGrp.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
validateEmptyFields();
}
});
rdoUseExist.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
txtNewResGrp.setVisible(false);
cbUseExist.setVisible(true);
newResGrp = false;
validateEmptyFields();
}
});
cbUseExist.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
cbLocations.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
lblPricing.addMouseListener(new LinkListener(PRICING_LINK));
cbPricing.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
validateEmptyFields();
}
});
chkNoSSL.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (chkNoSSL.isSelected()) {
noSSLPort = true;
} else {
noSSLPort = false;
}
}
});
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class RedisCreationDialog method onSubscriptionChanged.
private void onSubscriptionChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final Subscription subscription = (Subscription) e.getItem();
this.resourceGroupComboBox.setSubscription(subscription);
this.regionComboBox.setSubscription(subscription);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
this.resourceGroupComboBox.setSubscription(null);
this.regionComboBox.setSubscription(null);
}
}
Aggregations