Search in sources :

Example 1 with IAzureMessager

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

the class FunctionDeploymentState method listFunctions.

// todo: Move to toolkit lib as shared task
private List<FunctionEntity> listFunctions(final IFunctionApp functionApp) {
    final int[] count = { 0 };
    final IAzureMessager azureMessager = AzureMessager.getMessager();
    return Mono.fromCallable(() -> {
        final AzureString message = count[0]++ == 0 ? AzureString.fromString(SYNCING_TRIGGERS) : AzureString.format(SYNCING_TRIGGERS_WITH_RETRY, count[0], LIST_TRIGGERS_MAX_RETRY);
        azureMessager.info(message);
        return Optional.ofNullable(functionApp.listFunctions(true)).filter(CollectionUtils::isNotEmpty).orElseThrow(() -> new AzureToolkitRuntimeException(NO_TRIGGERS_FOUNDED));
    }).subscribeOn(Schedulers.boundedElastic()).retryWhen(Retry.fixedDelay(LIST_TRIGGERS_MAX_RETRY - 1, Duration.ofSeconds(LIST_TRIGGERS_RETRY_PERIOD_IN_SECONDS))).block();
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Example 2 with IAzureMessager

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

the class SpringCloudExplorerContributor method getModuleNode.

@Override
public Node<?> getModuleNode() {
    final AzureActionManager am = AzureActionManager.getInstance();
    final IAzureMessager messager = AzureMessager.getDefaultMessager();
    final AzureSpringCloud service = az(AzureSpringCloud.class);
    return new Node<>(service).view(new AzureServiceLabelView<>(service, "Spring Cloud", ICON)).actions(SpringCloudActionsContributor.SERVICE_ACTIONS).addChildren(AzureSpringCloud::clusters, (cluster, ascNode) -> new Node<>(cluster).view(new AzureResourceLabelView<>(cluster)).actions(SpringCloudActionsContributor.CLUSTER_ACTIONS).addChildren(SpringCloudCluster::apps, (app, clusterNode) -> new Node<>(app).view(new AzureResourceLabelView<>(app)).actions(SpringCloudActionsContributor.APP_ACTIONS)));
}
Also used : IExplorerContributor(com.microsoft.azure.toolkit.ide.common.IExplorerContributor) AzureResourceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView) AzureServiceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView) SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) Azure.az(com.microsoft.azure.toolkit.lib.Azure.az) IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud) Node(com.microsoft.azure.toolkit.ide.common.component.Node) IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) Node(com.microsoft.azure.toolkit.ide.common.component.Node) AzureResourceLabelView(com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud)

Example 3 with IAzureMessager

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

the class StorageExplorerContributor method getModuleNode.

@Override
public Node<?> getModuleNode() {
    final AzureActionManager am = AzureActionManager.getInstance();
    final IAzureMessager messager = AzureMessager.getDefaultMessager();
    final AzureStorageAccount service = az(AzureStorageAccount.class);
    return new Node<>(service).view(new AzureServiceLabelView<>(service, NAME, ICON)).actions(StorageActionsContributor.SERVICE_ACTIONS).addChildren(AzureStorageAccount::list, (account, storageNode) -> new Node<>(account).view(new AzureResourceLabelView<>(account)).actions(StorageActionsContributor.ACCOUNT_ACTIONS));
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) AzureStorageAccount(com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount) AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)

Example 4 with IAzureMessager

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

the class SpringCloudDeploymentConfigurationState method printPublicUrl.

private void printPublicUrl(final SpringCloudApp app) {
    final IAzureMessager messager = AzureMessager.getMessager();
    if (!app.entity().isPublic()) {
        return;
    }
    messager.info(String.format("Getting public url of app(%s)...", app.name()));
    String publicUrl = app.entity().getApplicationUrl();
    if (StringUtils.isEmpty(publicUrl)) {
        publicUrl = Utils.pollUntil(() -> app.refresh().entity().getApplicationUrl(), StringUtils::isNotBlank, GET_URL_TIMEOUT);
    }
    if (StringUtils.isEmpty(publicUrl)) {
        messager.warning("Failed to get application url", NOTIFICATION_TITLE);
    } else {
        messager.info(String.format("Application url: %s", publicUrl));
    }
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager)

Example 5 with IAzureMessager

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

the class SpringCloudStreamingLogAction method startLogStreaming.

public static void startLogStreaming(@Nonnull SpringCloudApp app, @Nullable Project project) {
    final IAzureMessager messager = AzureMessager.getMessager();
    final AzureString title = AzureOperationBundle.title("springcloud|log_stream.open", app.name());
    AzureTaskManager.getInstance().runInBackground(new AzureTask<>(project, title, false, () -> {
        try {
            final SpringCloudDeployment deployment = app.activeDeployment();
            if (deployment == null || !deployment.exists()) {
                messager.warning(NO_ACTIVE_DEPLOYMENT, FAILED_TO_START_LOG_STREAMING);
                return;
            }
            final List<SpringCloudDeploymentInstanceEntity> instances = deployment.entity().getInstances();
            if (CollectionUtils.isEmpty(instances)) {
                messager.warning(NO_AVAILABLE_INSTANCES, FAILED_TO_START_LOG_STREAMING);
            } else {
                showLogStreamingDialog(instances, app, project);
            }
        } catch (final Exception e) {
            final String errorMessage = StringUtils.isEmpty(e.getMessage()) ? FAILED_TO_LIST_INSTANCES : String.format(FAILED_TO_LIST_INSTANCES_WITH_MESSAGE, e.getMessage());
            messager.error(errorMessage, FAILED_TO_START_LOG_STREAMING);
        }
    }));
}
Also used : IAzureMessager(com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) List(java.util.List) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString)

Aggregations

IAzureMessager (com.microsoft.azure.toolkit.lib.common.messager.IAzureMessager)5 AzureActionManager (com.microsoft.azure.toolkit.lib.common.action.AzureActionManager)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 IExplorerContributor (com.microsoft.azure.toolkit.ide.common.IExplorerContributor)1 AzureResourceLabelView (com.microsoft.azure.toolkit.ide.common.component.AzureResourceLabelView)1 AzureServiceLabelView (com.microsoft.azure.toolkit.ide.common.component.AzureServiceLabelView)1 Node (com.microsoft.azure.toolkit.ide.common.component.Node)1 Azure.az (com.microsoft.azure.toolkit.lib.Azure.az)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 AzureMessager (com.microsoft.azure.toolkit.lib.common.messager.AzureMessager)1 AzureSpringCloud (com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud)1 SpringCloudCluster (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster)1 SpringCloudDeployment (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment)1 AzureStorageAccount (com.microsoft.azure.toolkit.lib.storage.service.AzureStorageAccount)1 List (java.util.List)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1