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