Search in sources :

Example 11 with Region

use of com.microsoft.azure.toolkit.lib.common.model.Region in project azure-tools-for-java by Microsoft.

the class MySQLCreationAdvancedPanel method loadSupportedRegions.

public static List<Region> loadSupportedRegions(AzureService service, String subscriptionId) {
    // this the sequence in listSupportedRegions is alphabetical order for mysql
    // we need to rearrange it according to: az account list-regions
    final List<Region> regions = Azure.az(AzureAccount.class).listRegions(subscriptionId);
    final List supportedRegions = service.listSupportedRegions(subscriptionId);
    return regions.stream().filter(supportedRegions::contains).collect(Collectors.toList());
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region) List(java.util.List) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount)

Example 12 with Region

use of com.microsoft.azure.toolkit.lib.common.model.Region in project azure-tools-for-java by Microsoft.

the class PublishWebAppOnLinuxDialog method renderLocationList.

@Override
public void renderLocationList(List<Region> list) {
    // TODO Auto-generated method stub
    locationList = list;
    cpNew.cbLocation.removeAll();
    for (Region l : locationList) {
        cpNew.cbLocation.add(l.getLabel());
    }
    if (cpNew.cbLocation.getItemCount() > 0) {
        cpNew.cbLocation.select(0);
    }
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region)

Example 13 with Region

use of com.microsoft.azure.toolkit.lib.common.model.Region in project azure-tools-for-java by Microsoft.

the class CreateRedisCacheForm method fillLocationsAndResourceGrps.

private void fillLocationsAndResourceGrps(Subscription selectedSub) {
    cbLocations.removeAll();
    List<? extends Region> locations = com.microsoft.azure.toolkit.lib.Azure.az(AzureAccount.class).listRegions(selectedSub.getId());
    if (locations != null) {
        sortedLocations = locations.stream().sorted(Comparator.comparing(Region::getLabel)).collect(Collectors.toList());
        for (Region location : sortedLocations) {
            cbLocations.add(location.getLabel());
        }
        if (sortedLocations.size() > 0) {
            cbLocations.select(0);
            selectedLocationValue = sortedLocations.get(0).getLabel();
        }
    }
    cbUseExisting.removeAll();
    List<ResourceGroup> groups = AzureMvpModel.getInstance().getResourceGroups(selectedSub.getId()).stream().map(ResourceEx::getResource).collect(Collectors.toList());
    if (groups != null) {
        sortedGroups = groups.stream().map(ResourceGroup::getName).sorted().collect(Collectors.toList());
        for (String group : sortedGroups) {
            cbUseExisting.add(group);
        }
        if (sortedGroups.size() > 0) {
            cbUseExisting.select(0);
            if (rdoUseExisting.getSelection()) {
                newResGrp = false;
                selectedResGrpValue = sortedGroups.get(0);
            }
        }
    }
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 14 with Region

use of com.microsoft.azure.toolkit.lib.common.model.Region in project azure-tools-for-java by Microsoft.

the class SelectImageStep method fillRegions.

private void fillRegions() {
    regionComboBox.removeAll();
    Subscription subs = wizard.getSubscription();
    List<Region> locations = Azure.az(AzureAccount.class).listRegions(subs.getId());
    for (Region location : locations) {
        regionComboBox.add(location.getLabel());
        regionComboBox.setData(location.getLabel(), location);
    }
    if (locations.size() > 0) {
        regionComboBox.select(0);
        selectRegion();
    }
    regionComboBox.setEnabled(true);
    validateNext();
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 15 with Region

use of com.microsoft.azure.toolkit.lib.common.model.Region in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountForm method okPressed.

@Override
protected void okPressed() {
    if (nameTextField.getText().length() < 3 || nameTextField.getText().length() > 24 || !nameTextField.getText().matches("[a-z0-9]+")) {
        DefaultLoader.getUIHelper().showError("Invalid storage account name. The name should be between 3 and 24 characters long and " + "can contain only lowercase letters and numbers.", "Azure Explorer");
        return;
    }
    if (subscription == null) {
        subscription = (Subscription) subscriptionComboBox.getData(subscriptionComboBox.getText());
    }
    final boolean isNewResourceGroup = createNewRadioButton.getSelection();
    final ResourceGroup resourceGroup = isNewResourceGroup ? new DraftResourceGroup(subscription, resourceGrpField.getText()) : Azure.az(AzureGroup.class).subscription(subscription.getId()).getByName(resourceGrpCombo.getText());
    Region region = ((Region) regionComboBox.getData(regionComboBox.getText()));
    Kind kind = (Kind) kindCombo.getData(kindCombo.getText());
    String name = nameTextField.getText();
    newStorageAccount = StorageAccountConfig.builder().name(name).region(region).kind(kind).resourceGroup(resourceGroup).performance((Performance) performanceCombo.getData(performanceCombo.getText())).redundancy((Redundancy) replicationComboBox.getData(replicationComboBox.getText())).subscription(subscription).accessTier(Optional.ofNullable(accessTierComboBox).map(t -> (AccessTier) accessTierComboBox.getData(accessTierComboBox.getText())).orElse(null)).build();
    this.onCreate.run();
    super.okPressed();
}
Also used : DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) Kind(com.microsoft.azure.toolkit.lib.storage.model.Kind) Region(com.microsoft.azure.toolkit.lib.common.model.Region) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) Performance(com.microsoft.azure.toolkit.lib.storage.model.Performance) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Aggregations

Region (com.microsoft.azure.toolkit.lib.common.model.Region)17 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)8 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)6 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)5 RegionComboBox (com.microsoft.azure.toolkit.intellij.common.component.RegionComboBox)2 SubscriptionComboBox (com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox)2 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)2 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)2 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)2 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 MessageType (com.intellij.openapi.ui.MessageType)1