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();
}
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)));
}
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));
}
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));
}
}
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);
}
}));
}
Aggregations