Search in sources :

Example 76 with Subscription

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;
}
Also used : ArrayList(java.util.ArrayList) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 77 with Subscription

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) {
        }
    });
}
Also used : Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 78 with Subscription

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);
    }
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 79 with Subscription

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;
}
Also used : EventHubNamespace(com.microsoft.azure.management.eventhub.EventHubNamespace) Azure(com.microsoft.azure.management.Azure) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 80 with Subscription

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;
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Aggregations

Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)139 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)26 Region (com.microsoft.azure.toolkit.lib.common.model.Region)18 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)18 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)17 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Project (com.intellij.openapi.project.Project)8 Azure (com.microsoft.azure.toolkit.lib.Azure)8 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)8 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)8 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)8 HashMap (java.util.HashMap)8 List (java.util.List)8 StringUtils (org.apache.commons.lang3.StringUtils)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 GridData (org.eclipse.swt.layout.GridData)8 Combo (org.eclipse.swt.widgets.Combo)8