Search in sources :

Example 1 with RedisConfig

use of com.microsoft.azure.toolkit.redis.RedisConfig in project azure-tools-for-java by Microsoft.

the class CreateRedisCacheForm method okPressed.

@Override
protected void okPressed() {
    try {
        RedisCacheUtil.doValidate(currentSub, dnsNameValue, selectedLocationValue, selectedResGrpValue, selectedPriceTierValue);
        if (newResGrp) {
            for (String resGrp : sortedGroups) {
                if (selectedResGrpValue.equals(resGrp)) {
                    throw new InvalidFormDataException("The resource group " + selectedResGrpValue + " is not available");
                }
            }
        }
    } catch (InvalidFormDataException e) {
        MessageDialog.openError(getShell(), "Form Validation Error", e.getMessage());
        return;
    }
    RedisConfig config = getData();
    final Runnable runnable = () -> {
        final Operation operation = TelemetryManager.createOperation(REDIS, CREATE_REDIS);
        try {
            operation.start();
            new CreateRedisTask(config).execute();
            if (onCreate != null) {
                onCreate.run();
            }
        } catch (Exception ex) {
            EventUtil.logError(operation, ErrorType.userError, ex, null, null);
            operation.complete();
            MessageDialog.openError(getShell(), String.format(MessageHandler.getResourceString(resourceBundle, CREATING_ERROR_INDICATOR_FORMAT), dnsNameValue), ex.getMessage());
            LOG.log(String.format(MessageHandler.getResourceString(resourceBundle, CREATING_ERROR_INDICATOR_FORMAT), dnsNameValue), ex);
        }
    };
    String progressMessage = Node.getProgressMessage(AzureActionEnum.CREATE.getDoingName(), RedisCacheModule.MODULE_NAME, config.getName());
    AzureTaskManager.getInstance().runInBackground(new AzureTask<>(null, progressMessage, false, runnable));
    super.okPressed();
}
Also used : InvalidFormDataException(com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) InvalidFormDataException(com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException) IOException(java.io.IOException) RedisConfig(com.microsoft.azure.toolkit.redis.RedisConfig)

Example 2 with RedisConfig

use of com.microsoft.azure.toolkit.redis.RedisConfig 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 3 with RedisConfig

use of com.microsoft.azure.toolkit.redis.RedisConfig in project azure-tools-for-java by Microsoft.

the class RedisCreationDialog method getData.

@Override
public RedisConfig getData() {
    RedisConfig config = new RedisConfig();
    config.setSubscription(subscriptionComboBox.getValue());
    config.setResourceGroup(resourceGroupComboBox.getValue());
    config.setName(redisNameTextField.getText());
    config.setPricingTier(pricingComboBox.getValue());
    config.setRegion(regionComboBox.getValue());
    config.setEnableNonSslPort(enableNonSSLCheckBox.isSelected());
    return config;
}
Also used : RedisConfig(com.microsoft.azure.toolkit.redis.RedisConfig)

Aggregations

RedisConfig (com.microsoft.azure.toolkit.redis.RedisConfig)3 InvalidFormDataException (com.microsoft.azuretools.azurecommons.exceptions.InvalidFormDataException)2 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)2 IOException (java.io.IOException)2 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 Region (com.microsoft.azure.toolkit.lib.common.model.Region)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)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 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 CreateResourceGroupTask (com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask)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 AuthMethodManager (com.microsoft.azuretools.authmanage.AuthMethodManager)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 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)1