use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class FunctionDeploymentState method prepareStagingFolder.
@AzureOperation(name = "function.prepare_staging_folder_detail", params = { "stagingFolder.getName()", "this.deployModel.getFunctionAppConfig().getName()" }, type = AzureOperation.Type.TASK)
private void prepareStagingFolder(File stagingFolder, RunProcessHandler processHandler, @NotNull final Operation operation) {
AzureTaskManager.getInstance().read(() -> {
final Path hostJsonPath = FunctionUtils.getDefaultHostJson(project);
final PsiMethod[] methods = FunctionUtils.findFunctionsByAnnotation(functionDeployConfiguration.getModule());
final Path folder = stagingFolder.toPath();
try {
final Map<String, FunctionConfiguration> configMap = FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionDeployConfiguration.getModule(), methods);
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(FunctionUtils.getFunctionBindingList(configMap), ","));
} catch (final AzureExecutionException | IOException e) {
final String error = String.format("failed prepare staging folder[%s]", folder);
throw new AzureToolkitRuntimeException(error, e);
}
});
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class RunFunctionAction method onActionPerformed.
@Override
@AzureOperation(name = "function.run.configuration", type = AzureOperation.Type.ACTION)
public boolean onActionPerformed(@NotNull AnActionEvent anActionEvent, @Nullable Operation operation) {
final Module module = DataKeys.MODULE.getData(anActionEvent.getDataContext());
AzureTaskManager.getInstance().runLater(() -> runConfiguration(module));
return true;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureMvpModel method getDeploymentByRgName.
/**
* Get deployment by resource group name
* @param rgName
* @return
*/
@AzureOperation(name = "arm|deployment.list.subscription|rg", params = { "rgName", "sid" }, type = AzureOperation.Type.SERVICE)
public List<ResourceEx<Deployment>> getDeploymentByRgName(String sid, String rgName) {
List<ResourceEx<Deployment>> res = new ArrayList<>();
Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
res.addAll(azure.deployments().listByResourceGroup(rgName).stream().map(deployment -> new ResourceEx<>(deployment, sid)).collect(Collectors.toList()));
Collections.sort(res, getComparator((ResourceEx<Deployment> deploymentResourceEx) -> deploymentResourceEx.getResource().name()));
return res;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureMvpModel method getSelectedSubscriptions.
/**
* Get list of selected Subscriptions.
*
* @return List of Subscription instances
*/
@AzureOperation(name = "account|subscription.get_detail.selected", type = AzureOperation.Type.SERVICE)
public List<Subscription> getSelectedSubscriptions() {
final List<Subscription> ret = new ArrayList<>();
final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
ret.addAll(azureManager.getSelectedSubscriptions());
Collections.sort(ret, getComparator(Subscription::getName));
return ret;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AuthMethodManager method persistAuthMethodDetails.
@AzureOperation(name = "account|auth_setting.persist", type = AzureOperation.Type.TASK)
public void persistAuthMethodDetails() {
waitInitFinish();
try {
System.out.println("saving authMethodDetails...");
String sd = JsonHelper.serialize(authMethodDetails);
AzureStoreManager.getInstance().getIdeStore().setProperty(ACCOUNT, AUTH_METHOD_DETAIL, sd);
} catch (final IOException e) {
final String error = "Failed to persist auth method settings while updating";
final String action = "Retry later";
throw new AzureToolkitRuntimeException(error, e, action);
}
}
Aggregations