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();
}
});
}
});
}
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);
}
}
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);
}
}
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;
}
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()));
}
Aggregations