use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AzureMvpModel method listLocationsBySubscriptionId.
/**
* List Location by Subscription ID.
*
* @param sid subscription Id
* @return List of Location instances
*/
@AzureOperation(name = "common|region.list.subscription", params = { "sid" }, type = AzureOperation.Type.SERVICE)
public List<Region> listLocationsBySubscriptionId(String sid) {
List<Region> locations = new ArrayList<>();
Subscription subscription = getSubscriptionById(sid);
try {
locations.addAll(az(AzureAccount.class).listRegions(subscription.getId()));
} catch (Exception e) {
e.printStackTrace();
}
Collections.sort(locations, getComparator(Region::getName));
return locations;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsNewDialog method createSubCmpnt.
private void createSubCmpnt(Composite container) {
Label lblName = new Label(container, SWT.LEFT);
GridData gridData = gridDataForLbl();
lblName.setLayoutData(gridData);
lblName.setText(Messages.sub);
subscription = new Combo(container, SWT.READ_ONLY);
gridData = gridDataForText(180);
subscription.setLayoutData(gridData);
subscription.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
Subscription newSub = (Subscription) subscription.getData(subscription.getText());
String prevResGrpVal = resourceGrpCombo.getText();
if (currentSub.equals(newSub)) {
populateResourceGroupValues(currentSub.getId(), prevResGrpVal);
} else {
populateResourceGroupValues(newSub.getId(), "");
}
currentSub = newSub;
enableOkBtn();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsNewDialog method populateValues.
private void populateValues() {
try {
subscription.removeAll();
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
if (azureManager == null) {
return;
}
List<Subscription> subList = azureManager.getSelectedSubscriptions();
// check at least single subscription is associated with the account
if (subList.size() > 0) {
for (Subscription sub : subList) {
subscription.add(sub.getName());
subscription.setData(sub.getName(), sub);
}
subscription.select(0);
currentSub = subList.get(0);
populateResourceGroupValues(currentSub.getId(), "");
List<String> regionList = AzureSDKManager.getLocationsForInsights(currentSub.getId());
String[] regionArray = regionList.toArray(new String[regionList.size()]);
region.setItems(regionArray);
region.setText(regionArray[0]);
}
enableOkBtn();
} catch (Exception ex) {
Activator.getDefault().log(Messages.getValuesErrMsg, ex);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class CreateFunctionForm method getEventHubNameSpaces.
private List<EventHubNamespace> getEventHubNameSpaces() {
if (eventHubNamespaces == null) {
eventHubNamespaces = new ArrayList<>();
final List<Subscription> subs = az(AzureAccount.class).account().getSelectedSubscriptions();
for (final Subscription subscriptionId : subs) {
final Azure azure = AuthMethodManager.getInstance().getAzureClient(subscriptionId.getId());
final PagedList<EventHubNamespace> pagedList = azure.eventHubNamespaces().list();
pagedList.loadAll();
eventHubNamespaces.addAll(pagedList);
eventHubNamespaces.sort(Comparator.comparing(HasName::name));
}
}
return eventHubNamespaces;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AppServiceInfoAdvancedPanel method getData.
@Override
public T getData() {
final Subscription subscription = this.selectorSubscription.getValue();
final ResourceGroup resourceGroup = this.selectorGroup.getValue();
final String name = this.textName.getValue();
final Runtime runtime = this.selectorRuntime.getValue();
final Region region = this.selectorRegion.getValue();
final AppServicePlanEntity servicePlan = this.selectorServicePlan.getValue();
final AzureArtifact artifact = this.selectorApplication.getValue();
final T config = supplier.get();
config.setSubscription(subscription);
config.setResourceGroup(resourceGroup);
config.setName(name);
config.setRuntime(runtime);
config.setRegion(region);
config.setServicePlan(servicePlan);
if (Objects.nonNull(artifact)) {
final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
final String path = manager.getFileForDeployment(this.selectorApplication.getValue());
config.setApplication(Paths.get(path));
}
return config;
}
Aggregations