Search in sources :

Example 1 with Nullable

use of com.microsoft.azuretools.azurecommons.helpers.Nullable in project azure-tools-for-java by Microsoft.

the class AzureManagerBase method getInsightsManager.

@Nullable
public InsightsManager getInsightsManager(String sid) {
    if (!isSignedIn()) {
        return null;
    }
    return sidToInsightsManagerMap.computeIfAbsent(sid, s -> {
        // Register insights namespace first
        final Azure azure = getAzure(sid);
        azure.providers().register(MICROSOFT_INSIGHTS_NAMESPACE);
        final String tid = this.subscriptionManager.getSubscriptionTenant(sid);
        return authApplicationInsights(sid, tid);
    });
}
Also used : Azure(com.microsoft.azure.management.Azure) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable)

Example 2 with Nullable

use of com.microsoft.azuretools.azurecommons.helpers.Nullable in project azure-tools-for-java by Microsoft.

the class AzureManagerBase method getAzure.

@Override
@Nullable
public Azure getAzure(String sid) {
    if (!isSignedIn()) {
        return null;
    }
    if (sidToAzureMap.containsKey(sid)) {
        return sidToAzureMap.get(sid);
    }
    final String tid = this.subscriptionManager.getSubscriptionTenant(sid);
    final Azure azure = authTenant(tid).withSubscription(sid);
    // TODO: remove this call after Azure SDK properly implements handling of unregistered provider namespaces
    AzureRegisterProviderNamespaces.registerAzureNamespaces(azure);
    sidToAzureMap.put(sid, azure);
    return azure;
}
Also used : Azure(com.microsoft.azure.management.Azure) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable)

Example 3 with Nullable

use of com.microsoft.azuretools.azurecommons.helpers.Nullable in project azure-tools-for-java by Microsoft.

the class AzureSparkCosmosCluster method prepareStorageFolder.

@Nullable
public Observable<Boolean> prepareStorageFolder(@NotNull String path) {
    return Observable.fromCallable(() -> {
        try {
            String accessToken = getHttp().getAccessToken();
            ADLStoreClient storeClient = ADLStoreClient.createClient(URI.create(this.getStorageAccount().getDefaultContainerOrRootPath()).getHost(), accessToken);
            if (storeClient.checkExists(path)) {
                return true;
            } else {
                return storeClient.createDirectory(path);
            }
        } catch (Exception ex) {
            throw new Exception("Failed to create or access spark events log path", ex);
        }
    });
}
Also used : ADLStoreClient(com.microsoft.azure.datalake.store.ADLStoreClient) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException) IOException(java.io.IOException) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable)

Example 4 with Nullable

use of com.microsoft.azuretools.azurecommons.helpers.Nullable in project azure-tools-for-java by Microsoft.

the class AzureSparkServerlessAccount method getStorageRootPath.

@Nullable
public String getStorageRootPath() {
    String storageRootPath = null;
    DataLakeAnalyticsAccount accountDetail = this.getDetailResponse();
    if (accountDetail != null) {
        // find default storage account name and suffix
        String defaultStorageAccountName = accountDetail.defaultDataLakeStoreAccount();
        storageRootPath = accountDetail.dataLakeStoreAccounts().stream().filter(info -> info.name().equals(defaultStorageAccountName)).findFirst().map(DataLakeStoreAccountInformation::suffix).map(suffix -> String.format("adl://%s.%s/", defaultStorageAccountName, suffix)).orElse(null);
    }
    return storageRootPath;
}
Also used : AuthMethodManager(com.microsoft.azuretools.authmanage.AuthMethodManager) JobInfoListResult(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.job.models.JobInfoListResult) SparkSubmitStorageTypeOptionsForCluster(com.microsoft.azure.hdinsight.spark.common.SparkSubmitStorageTypeOptionsForCluster) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull) ODataParam(com.microsoft.azure.hdinsight.sdk.common.ODataParam) DataLakeAnalyticsAccountBasic(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeAnalyticsAccountBasic) SparkSubmitStorageType(com.microsoft.azure.hdinsight.spark.common.SparkSubmitStorageType) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ClusterContainer(com.microsoft.azure.hdinsight.sdk.cluster.ClusterContainer) AzureDataLakeHttpObservable(com.microsoft.azure.hdinsight.sdk.common.AzureDataLakeHttpObservable) StringUtils(org.apache.commons.lang3.StringUtils) ILogger(com.microsoft.azure.hdinsight.common.logger.ILogger) DataLakeAnalyticsAccount(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeAnalyticsAccount) Observable(rx.Observable) ImmutableList(com.google.common.collect.ImmutableList) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) URI(java.net.URI) JobState(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.job.models.JobState) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) VERSION(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.job.models.ApiVersion.VERSION) HttpResponse(com.microsoft.azure.hdinsight.sdk.common.HttpResponse) StringEntity(org.apache.http.entity.StringEntity) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) DataLakeStoreAccountInformation(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeStoreAccountInformation) HttpGet(org.apache.http.client.methods.HttpGet) com.microsoft.azure.hdinsight.sdk.rest.azure.serverless.spark.models(com.microsoft.azure.hdinsight.sdk.rest.azure.serverless.spark.models) NameValuePair(org.apache.http.NameValuePair) Collections(java.util.Collections) AzureHttpObservable(com.microsoft.azure.hdinsight.sdk.common.AzureHttpObservable) DataLakeAnalyticsAccount(com.microsoft.azure.hdinsight.sdk.rest.azure.datalake.analytics.accounts.models.DataLakeAnalyticsAccount) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable)

Example 5 with Nullable

use of com.microsoft.azuretools.azurecommons.helpers.Nullable in project azure-tools-for-java by Microsoft.

the class CreateWebAppAction method openDialog.

@AzureOperation(name = "webapp.open_creation_dialog", type = AzureOperation.Type.ACTION)
private void openDialog(final Project project, @Nullable final WebAppConfig data) {
    final WebAppCreationDialog dialog = new WebAppCreationDialog(project);
    if (Objects.nonNull(data)) {
        dialog.setData(data);
    }
    dialog.setOkActionListener((config) -> {
        dialog.close();
        this.createWebApp(config).subscribe(webapp -> {
            final Path artifact = config.getApplication();
            if (Objects.nonNull(artifact) && artifact.toFile().exists()) {
                AzureTaskManager.getInstance().runLater("deploy", () -> deploy(webapp, artifact, project));
            }
        }, (error) -> {
            final String title = String.format("Reopen dialog \"%s\"", dialog.getTitle());
            final Consumer<Object> act = t -> AzureTaskManager.getInstance().runLater("open dialog", () -> this.openDialog(project, config));
            final Action<?> action = new Action<>(act, new ActionView.Builder(title));
            AzureMessager.getMessager().error(error, null, action);
        });
    });
    dialog.show();
}
Also used : Path(java.nio.file.Path) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) AzureBundle.message(com.microsoft.intellij.ui.messages.AzureBundle.message) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Single(rx.Single) AzureOperationBundle.title(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title) Project(com.intellij.openapi.project.Project) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) TextConsoleBuilderFactory(com.intellij.execution.filters.TextConsoleBuilderFactory) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Path(java.nio.file.Path) Notifications(com.intellij.notification.Notifications) ProgressManager(com.intellij.openapi.progress.ProgressManager) WebAppConfig(com.microsoft.azure.toolkit.lib.webapp.WebAppConfig) AzureActionEnum(com.microsoft.tooling.msservices.serviceexplorer.AzureActionEnum) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) WebAppModule(com.microsoft.tooling.msservices.serviceexplorer.azure.webapp.WebAppModule) WebAppCreationDialog(com.microsoft.azure.toolkit.intellij.webapp.WebAppCreationDialog) AzureMessager(com.microsoft.azure.toolkit.lib.common.messager.AzureMessager) Nullable(com.microsoft.azuretools.azurecommons.helpers.Nullable) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) RunProcessHandler(com.microsoft.intellij.RunProcessHandler) NotificationType(com.intellij.notification.NotificationType) Objects(java.util.Objects) Consumer(java.util.function.Consumer) Notification(com.intellij.notification.Notification) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) WebAppService(com.microsoft.azure.toolkit.lib.webapp.WebAppService) ConsoleView(com.intellij.execution.ui.ConsoleView) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) Action(com.microsoft.azure.toolkit.lib.common.action.Action) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) AzureSignInAction(com.microsoft.intellij.actions.AzureSignInAction) Action(com.microsoft.azure.toolkit.lib.common.action.Action) WebAppCreationDialog(com.microsoft.azure.toolkit.intellij.webapp.WebAppCreationDialog) ActionView(com.microsoft.azure.toolkit.lib.common.action.ActionView) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

Nullable (com.microsoft.azuretools.azurecommons.helpers.Nullable)22 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ILogger (com.microsoft.azure.hdinsight.common.logger.ILogger)3 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)3 ConsoleView (com.intellij.execution.ui.ConsoleView)2 Module (com.intellij.openapi.module.Module)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)2 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)2 Azure (com.microsoft.azure.management.Azure)2 Action (com.microsoft.azure.toolkit.lib.common.action.Action)2 ActionView (com.microsoft.azure.toolkit.lib.common.action.ActionView)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureMessager (com.microsoft.azure.toolkit.lib.common.messager.AzureMessager)2 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)2 AzureOperationBundle.title (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle.title)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2