Search in sources :

Example 1 with IAzureMessage

use of com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage in project azure-tools-for-java by Microsoft.

the class CreateFunctionAppAction method createFunctionApp.

@AzureOperation(name = "function.create_detail", params = { "config.getName()" }, type = AzureOperation.Type.ACTION)
private Single<IFunctionApp> createFunctionApp(final FunctionAppConfig config) {
    final AzureString title = title("function.create_detail", config.getName());
    final IntellijAzureMessager actionMessenger = new IntellijAzureMessager() {

        @Override
        public boolean show(IAzureMessage raw) {
            if (raw.getType() != IAzureMessage.Type.INFO) {
                return super.show(raw);
            }
            return false;
        }
    };
    final AzureTask<IFunctionApp> task = new AzureTask<>(null, title, false, () -> {
        final Operation operation = TelemetryManager.createOperation(TelemetryConstants.FUNCTION, TelemetryConstants.CREATE_FUNCTION_APP);
        operation.trackProperties(config.getTelemetryProperties());
        try {
            AzureMessager.getContext().setMessager(actionMessenger);
            final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
            indicator.setIndeterminate(true);
            return functionAppService.createFunctionApp(config);
        } finally {
            operation.trackProperties(AzureTelemetry.getActionContext().getProperties());
            operation.complete();
        }
    });
    return AzureTaskManager.getInstance().runInModalAsObservable(task).toSingle().doOnSuccess(app -> {
        AzureMessager.getMessager().success(message("function.create.success.message", app.name()), message("function.create.success.title"));
        this.refreshAzureExplorer(app);
    });
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) IAzureMessage(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage) IntellijAzureMessager(com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 IntellijAzureMessager (com.microsoft.azure.toolkit.intellij.common.messager.IntellijAzureMessager)1 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 IAzureMessage (com.microsoft.azure.toolkit.lib.common.messager.IAzureMessage)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)1