Search in sources :

Example 1 with DraftResourceGroup

use of com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup in project azure-tools-for-java by Microsoft.

the class CreateRedisCacheForm method getData.

private RedisConfig getData() {
    RedisConfig redisConfig = new RedisConfig();
    redisConfig.setSubscription(this.currentSub);
    redisConfig.setRegion(Region.fromName(selectedLocationValue));
    redisConfig.setResourceGroup(newResGrp ? new DraftResourceGroup(this.currentSub, selectedResGrpValue) : com.microsoft.azure.toolkit.lib.Azure.az(AzureGroup.class).get(this.currentSub.getId(), selectedResGrpValue));
    redisConfig.setEnableNonSslPort(noSSLPort);
    redisConfig.setPricingTier(PricingTier.values().stream().filter(pricingTier -> StringUtils.equalsIgnoreCase(pricingTier.toString(), selectedPriceTierValue)).findFirst().orElse(null));
    redisConfig.setName(dnsNameValue);
    return redisConfig;
}
Also used : AuthMethodManager(com.microsoft.azuretools.authmanage.AuthMethodManager) URL(java.net.URL) InvalidFormDataException(com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) StringUtils(org.apache.commons.lang3.StringUtils) Point(org.eclipse.swt.graphics.Point) RedisCacheUtil(com.microsoft.azuretools.azurecommons.helpers.RedisCacheUtil) AzureTitleAreaDialogWrapper(com.microsoft.azuretools.core.components.AzureTitleAreaDialogWrapper) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) Activator(com.microsoft.azuretools.core.Activator) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ResourceEx(com.microsoft.azuretools.core.mvp.model.ResourceEx) AzureActionEnum(com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum) Text(org.eclipse.swt.widgets.Text) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) ErrorType(com.microsoft.azuretools.telemetrywrapper.ErrorType) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) CREATE_REDIS(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_REDIS) Collectors(java.util.stream.Collectors) AzureRedis(com.microsoft.azure.toolkit.redis.AzureRedis) List(java.util.List) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) SWT(org.eclipse.swt.SWT) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) FieldDecorationRegistry(org.eclipse.jface.fieldassist.FieldDecorationRegistry) REDIS(com.microsoft.azuretools.telemetry.TelemetryConstants.REDIS) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) Label(org.eclipse.swt.widgets.Label) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) RedisCache(com.microsoft.azure.toolkit.redis.RedisCache) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) RedisCacheModule(com.microsoft.tooling.msservices.serviceexplorer.azure.rediscache.RedisCacheModule) CreateResourceGroupTask(com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Region(com.microsoft.azure.toolkit.lib.common.model.Region) ResourceBundle(java.util.ResourceBundle) MessageHandler(com.microsoft.azuretools.azureexplorer.messages.MessageHandler) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) GridData(org.eclipse.swt.layout.GridData) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Link(org.eclipse.swt.widgets.Link) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) PricingTier(com.microsoft.azure.toolkit.redis.PricingTier) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) IOException(java.io.IOException) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) Draft(com.microsoft.azuretools.azureexplorer.forms.common.Draft) ModifyListener(org.eclipse.swt.events.ModifyListener) TelemetryManager(com.microsoft.azuretools.telemetrywrapper.TelemetryManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RedisConfig(com.microsoft.azure.toolkit.redis.RedisConfig) Comparator(java.util.Comparator) Control(org.eclipse.swt.widgets.Control) Utils(com.microsoft.azuretools.azurecommons.util.Utils) GridLayout(org.eclipse.swt.layout.GridLayout) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) RedisConfig(com.microsoft.azure.toolkit.redis.RedisConfig)

Example 2 with DraftResourceGroup

use of com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup 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)2 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)2 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)2 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)2 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 CreateResourceGroupTask (com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask)1 Kind (com.microsoft.azure.toolkit.lib.storage.model.Kind)1 Performance (com.microsoft.azure.toolkit.lib.storage.model.Performance)1 AzureRedis (com.microsoft.azure.toolkit.redis.AzureRedis)1 PricingTier (com.microsoft.azure.toolkit.redis.PricingTier)1 RedisCache (com.microsoft.azure.toolkit.redis.RedisCache)1 RedisConfig (com.microsoft.azure.toolkit.redis.RedisConfig)1 AuthMethodManager (com.microsoft.azuretools.authmanage.AuthMethodManager)1 InvalidFormDataException (com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException)1 RedisCacheUtil (com.microsoft.azuretools.azurecommons.helpers.RedisCacheUtil)1 Utils (com.microsoft.azuretools.azurecommons.util.Utils)1 Draft (com.microsoft.azuretools.azureexplorer.forms.common.Draft)1