Search in sources :

Example 41 with AzureOperation

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

the class AzureSdkEnforcer method warnDeprecatedLibs.

@AzureOperation(name = "sdk|deprecated_libs.warn", type = AzureOperation.Type.ACTION)
private static void warnDeprecatedLibs(@AzureTelemetry.Property List<? extends AzureJavaSdkEntity> deprecatedLibs) {
    final String message = buildMessage(deprecatedLibs);
    final AzureActionManager am = AzureActionManager.getInstance();
    final Action<?> referenceBook = am.getAction(Action.Id.of(OpenReferenceBookAction.ID));
    final Action<?> neverShowAgain = am.getAction(Action.Id.of(IntellijNeverShowAgainAction.ID));
    AzureMessager.getMessager().warning(message, "Deprecated Azure SDK libraries Detected", referenceBook, neverShowAgain);
}
Also used : AzureActionManager(com.microsoft.azure.toolkit.lib.common.action.AzureActionManager) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 42 with AzureOperation

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

the class FunctionUtils method findFunctionsByAnnotation.

@AzureOperation(name = "function.list_function_methods", params = { "module.getName()" }, type = AzureOperation.Type.TASK)
public static PsiMethod[] findFunctionsByAnnotation(Module module) {
    final PsiClass functionNameClass = JavaPsiFacade.getInstance(module.getProject()).findClass(AZURE_FUNCTION_ANNOTATION_CLASS, GlobalSearchScope.moduleWithLibrariesScope(module));
    final List<PsiMethod> methods = new ArrayList<>(AnnotatedElementsSearch.searchPsiMethods(functionNameClass, GlobalSearchScope.moduleScope(module)).findAll());
    return methods.toArray(new PsiMethod[0]);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 43 with AzureOperation

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

the class FunctionUtils method copyLocalSettingsToStagingFolder.

@AzureOperation(name = "function.copy_settings", params = { "localSettingJson", "stagingFolder" }, type = AzureOperation.Type.TASK)
public static void copyLocalSettingsToStagingFolder(Path stagingFolder, Path localSettingJson, Map<String, String> appSettings) throws IOException {
    final File localSettingsFile = new File(stagingFolder.toFile(), "local.settings.json");
    copyFilesWithDefaultContent(localSettingJson, localSettingsFile, DEFAULT_LOCAL_SETTINGS_JSON);
    if (MapUtils.isNotEmpty(appSettings)) {
        updateLocalSettingValues(localSettingsFile, appSettings);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 44 with AzureOperation

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

the class DeployFunctionAction method onActionPerformed.

@Override
@AzureOperation(name = "function.deploy.configuration", type = AzureOperation.Type.ACTION)
public boolean onActionPerformed(@NotNull AnActionEvent anActionEvent, @Nullable Operation operation) {
    final Module module = DataKeys.MODULE.getData(anActionEvent.getDataContext());
    if (module == null) {
        return true;
    }
    final Project project = anActionEvent.getProject();
    AzureSignInAction.requireSignedIn(project, () -> runConfiguration(module));
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 45 with AzureOperation

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

the class CreateMySQLAction method createMySQL.

@AzureOperation(name = "mysql|server.create.task", params = { "config.getServerName()", "config.getSubscription().getName()" }, type = AzureOperation.Type.SERVICE)
public void createMySQL(final AzureMySQLConfig config) {
    final Operation operation = TelemetryManager.createOperation(ActionConstants.MySQL.CREATE);
    try {
        operation.start();
        final String subscriptionId = config.getSubscription().getId();
        EventUtil.logEvent(EventType.info, operation, Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, subscriptionId));
        // create resource group if necessary.
        if (config.getResourceGroup() instanceof Draft) {
            try {
                Azure.az(AzureGroup.class).get(subscriptionId, config.getResourceGroup().getName());
            } catch (Throwable ex) {
                Azure.az(AzureGroup.class).subscription(subscriptionId).create(config.getResourceGroup().getName(), config.getRegion().getName());
            }
            config.setResourceGroup(Azure.az(AzureGroup.class).get(subscriptionId, config.getResourceGroup().getName()));
        }
        // create mysql server
        final MySqlServer server = Azure.az(AzureMySql.class).subscription(subscriptionId).create(MySqlServerConfig.builder().subscription(config.getSubscription()).resourceGroup(config.getResourceGroup()).region(config.getRegion()).name(config.getServerName()).version(config.getVersion()).administratorLoginName(config.getAdminUsername()).administratorLoginPassword(String.valueOf(config.getPassword())).build()).commit();
        // update access from azure services
        if (config.isAllowAccessFromAzureServices()) {
            server.firewallRules().enableAzureAccessRule();
        }
        // update access from local machine
        if (config.isAllowAccessFromLocalMachine()) {
            server.firewallRules().enableLocalMachineAccessRule(server.getPublicIpForLocalMachine());
        }
    } catch (final RuntimeException e) {
        EventUtil.logError(operation, ErrorType.systemError, e, null, null);
        throw e;
    } finally {
        operation.complete();
    }
}
Also used : Draft(com.microsoft.azure.toolkit.intellij.common.Draft) AzureMySql(com.microsoft.azure.toolkit.lib.mysql.AzureMySql) MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)64 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)11 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)11 IOException (java.io.IOException)10 Project (com.intellij.openapi.project.Project)9 ArrayList (java.util.ArrayList)9 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)8 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)6 Path (java.nio.file.Path)6 Module (com.intellij.openapi.module.Module)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)5 Azure (com.microsoft.azure.management.Azure)4 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)4 AzureUIRefreshEvent (com.microsoft.azuretools.utils.AzureUIRefreshEvent)4 Action (com.microsoft.azure.toolkit.lib.common.action.Action)3 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)3 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)3 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)3