Search in sources :

Example 1 with Location

use of com.microsoft.azure.management.resources.Location in project azure-tools-for-java by Microsoft.

the class SelectImageStep method fillPublishers.

private void fillPublishers() {
    setPageComplete(false);
    String region = ((Location) regionComboBox.getData(regionComboBox.getText())).name();
    publisherComboBox.removeAll();
    offerComboBox.removeAll();
    imageLabelList.removeAll();
    offerComboBox.setEnabled(false);
    skuComboBox.setEnabled(false);
    imageLabelList.setEnabled(false);
    DefaultLoader.getIdeHelper().runInBackground(null, "Loading image publishers...", false, true, "", new Runnable() {

        @Override
        public void run() {
            final java.util.List<VirtualMachinePublisher> publishers = wizard.getAzure().virtualMachineImages().publishers().listByRegion(region);
            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                @Override
                public void run() {
                    for (VirtualMachinePublisher publisher : publishers) {
                        publisherComboBox.add(publisher.name());
                        publisherComboBox.setData(publisher.name(), publisher);
                    }
                    if (publishers.size() > 0) {
                        publisherComboBox.select(0);
                    }
                    fillOffers();
                }
            });
        }
    });
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) Location(com.microsoft.azure.management.resources.Location)

Example 2 with Location

use of com.microsoft.azure.management.resources.Location in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountForm method fillRegions.

private void fillRegions() {
    List<Location> locations = AzureModel.getInstance().getSubscriptionToLocationMap().get(subscriptionComboBox.getData(subscriptionComboBox.getText())).stream().sorted(Comparator.comparing(Location::displayName)).collect(Collectors.toList());
    for (Location location : locations) {
        regionComboBox.add(location.displayName());
        regionComboBox.setData(location.displayName(), location);
    }
    if (locations.size() > 0) {
        regionComboBox.select(0);
    }
}
Also used : Location(com.microsoft.azure.management.resources.Location)

Example 3 with Location

use of com.microsoft.azure.management.resources.Location in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method fillAppServicePlanLocations.

protected void fillAppServicePlanLocations() {
    try {
        DefaultComboBoxModel<SubscriptionDetail> cbModelSub = (DefaultComboBoxModel<SubscriptionDetail>) comboBoxSubscription.getModel();
        SubscriptionDetail sd = (SubscriptionDetail) cbModelSub.getSelectedItem();
        if (sd == null) {
            // empty
            System.out.println("No subscription is selected");
            return;
        }
        Map<SubscriptionDetail, List<Location>> sdlocMap = AzureModel.getInstance().getSubscriptionToLocationMap();
        List<Location> locl = sdlocMap.get(sd);
        DefaultComboBoxModel<LocationAdapter> cbModel = new DefaultComboBoxModel<LocationAdapter>();
        cbModel.addElement(new NullLocationAdapter());
        for (Location l : locl) {
            cbModel.addElement(new LocationAdapter(l));
        }
        comboBoxAppServicePlanLocation.setModel(cbModel);
    } catch (Exception ex) {
        ex.printStackTrace();
        LOGGER.error("fillAppServicePlanLocations@AppServiceCreateDialog", ex);
    }
}
Also used : SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) IOException(java.io.IOException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) CloudException(com.microsoft.azure.CloudException) Location(com.microsoft.azure.management.resources.Location)

Example 4 with Location

use of com.microsoft.azure.management.resources.Location in project azure-tools-for-java by Microsoft.

the class AzureDockerUtils method refreshDockerSubscriptions.

public static Map<String, AzureDockerSubscription> refreshDockerSubscriptions(AzureManager azureAuthManager) {
    Map<String, AzureDockerSubscription> subsMap = new HashMap<>();
    try {
        if (DEBUG)
            System.out.format("Get AzureDockerHostsManage subscription details: %s\n", new Date().toString());
        SubscriptionManager subscriptionManager = azureAuthManager.getSubscriptionManager();
        List<SubscriptionDetail> subscriptions = subscriptionManager.getSubscriptionDetails();
        if (subscriptions != null) {
            if (DEBUG)
                System.out.format("Get AzureDockerHostsManage Docker subscription details: %s\n", new Date().toString());
            Observable.from(subscriptions).flatMap(subscriptionDetail -> {
                return Observable.create(new Observable.OnSubscribe<AzureDockerSubscription>() {

                    @Override
                    public void call(Subscriber<? super AzureDockerSubscription> dockerSubscriptionSubscriber) {
                        if (subscriptionDetail.isSelected()) {
                            AzureDockerSubscription dockerSubscription = new AzureDockerSubscription();
                            dockerSubscription.id = subscriptionDetail.getSubscriptionId();
                            try {
                                if (DEBUG)
                                    System.out.format("\tGet AzureDockerHostsManage Docker subscription: %s at %s\n", dockerSubscription.id, new Date().toString());
                                dockerSubscription.tid = subscriptionDetail.getTenantId();
                                dockerSubscription.name = subscriptionDetail.getSubscriptionName();
                                dockerSubscription.azureClient = azureAuthManager.getAzure(dockerSubscription.id);
                                dockerSubscription.keyVaultClient = azureAuthManager.getKeyVaultClient(subscriptionDetail.getTenantId());
                                dockerSubscription.isSelected = true;
                                if (AzureDockerUtils.hasServicePrincipalAzureManager(azureAuthManager)) {
                                    dockerSubscription.userId = null;
                                    dockerSubscription.servicePrincipalId = azureAuthManager.getCurrentUserId();
                                } else {
                                    dockerSubscription.userId = azureAuthManager.getCurrentUserId();
                                    dockerSubscription.servicePrincipalId = null;
                                }
                                dockerSubscriptionSubscriber.onNext(dockerSubscription);
                            } catch (Exception e) {
                                e.printStackTrace();
                                DefaultLoader.getUIHelper().showError(e.getMessage(), "Error Loading Subscription Details for " + dockerSubscription.id);
                            }
                        }
                        dockerSubscriptionSubscriber.onCompleted();
                    }
                }).subscribeOn(Schedulers.io());
            }).subscribeOn(Schedulers.io()).toBlocking().subscribe(new Action1<AzureDockerSubscription>() {

                @Override
                public void call(AzureDockerSubscription dockerSubscription) {
                    subsMap.put(dockerSubscription.id, dockerSubscription);
                }
            });
        }
        if (DEBUG)
            System.out.format("Get AzureDockerHostsManage locations: %s\n", new Date().toString());
        List<Subscription> azureSubscriptionList = azureAuthManager.getSubscriptions();
        for (Subscription subscription : azureSubscriptionList) {
            AzureDockerSubscription dockerSubscription = subsMap.get(subscription.subscriptionId());
            if (dockerSubscription != null) {
                List<String> locations = subscription.listLocations().stream().sorted(Comparator.comparing(Location::displayName)).map(o -> o.name().toLowerCase()).collect(Collectors.toList());
                dockerSubscription.locations = locations;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        DefaultLoader.getUIHelper().showError(e.getMessage(), "Error loading subscription details");
    }
    return subsMap;
}
Also used : HttpURLConnection(java.net.HttpURLConnection) java.util(java.util) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) URL(java.net.URL) Subnet(com.microsoft.azure.management.network.Subnet) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) Callable(java.util.concurrent.Callable) Action1(rx.functions.Action1) Location(com.microsoft.azure.management.resources.Location) Observable(rx.Observable) Azure(com.microsoft.azure.management.Azure) Network(com.microsoft.azure.management.network.Network) Func1(rx.functions.Func1) ServicePrincipalAzureManager(com.microsoft.azuretools.sdkmanage.ServicePrincipalAzureManager) Schedulers(rx.schedulers.Schedulers) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) Vault(com.microsoft.azure.management.keyvault.Vault) Subscription(com.microsoft.azure.management.resources.Subscription) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) Subscriber(rx.Subscriber) AzureDockerCertVaultOps(com.microsoft.azure.docker.ops.AzureDockerCertVaultOps) AzureRegisterProviderNamespaces(com.microsoft.azuretools.utils.AzureRegisterProviderNamespaces) UnknownHostException(java.net.UnknownHostException) Collectors(java.util.stream.Collectors) Pair(com.microsoft.azuretools.utils.Pair) CountDownLatch(java.util.concurrent.CountDownLatch) Action0(rx.functions.Action0) com.microsoft.azure.docker.model(com.microsoft.azure.docker.model) AzureDockerVMOps(com.microsoft.azure.docker.ops.AzureDockerVMOps) KeyVaultClient(com.microsoft.azure.keyvault.KeyVaultClient) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) Observable(rx.Observable) UnknownHostException(java.net.UnknownHostException) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) Subscription(com.microsoft.azure.management.resources.Subscription)

Example 5 with Location

use of com.microsoft.azure.management.resources.Location in project azure-sdk-for-java by Azure.

the class AzureTests method listLocations.

/**
     * Tests location listing.
     * @throws Exception
     */
@Test
public void listLocations() throws Exception {
    Subscription subscription = azure.getCurrentSubscription();
    Assert.assertNotNull(subscription);
    for (Location location : subscription.listLocations()) {
        Region region = Region.findByLabelOrName(location.name());
        Assert.assertNotNull(region);
        Assert.assertEquals(region, location.region());
        Assert.assertEquals(region.name().toLowerCase(), location.name().toLowerCase());
    }
    Location location = subscription.getLocationByRegion(Region.US_WEST);
    Assert.assertNotNull(location);
    Assert.assertTrue(Region.US_WEST.name().equalsIgnoreCase(location.name()));
}
Also used : Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Subscription(com.microsoft.azure.management.resources.Subscription) Location(com.microsoft.azure.management.resources.Location) Test(org.junit.Test)

Aggregations

Location (com.microsoft.azure.management.resources.Location)13 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)7 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)5 Subscription (com.microsoft.azure.management.resources.Subscription)4 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)4 Azure (com.microsoft.azure.management.Azure)3 SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 CloudException (com.microsoft.azure.CloudException)1 com.microsoft.azure.docker.model (com.microsoft.azure.docker.model)1 AzureDockerCertVaultOps (com.microsoft.azure.docker.ops.AzureDockerCertVaultOps)1 AzureDockerVMOps (com.microsoft.azure.docker.ops.AzureDockerVMOps)1 KeyVaultClient (com.microsoft.azure.keyvault.KeyVaultClient)1 VirtualMachinePublisher (com.microsoft.azure.management.compute.VirtualMachinePublisher)1 Vault (com.microsoft.azure.management.keyvault.Vault)1 Network (com.microsoft.azure.management.network.Network)1 Subnet (com.microsoft.azure.management.network.Subnet)1