Search in sources :

Example 21 with AzureOperation

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);
        }
    });
}
Also used : Path(java.nio.file.Path) PsiMethod(com.intellij.psi.PsiMethod) AzureExecutionException(com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException) FunctionConfiguration(com.microsoft.azure.toolkit.lib.legacy.function.configurations.FunctionConfiguration) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) IOException(java.io.IOException) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 22 with AzureOperation

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;
}
Also used : Module(com.intellij.openapi.module.Module) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 23 with AzureOperation

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;
}
Also used : Azure(com.microsoft.azure.management.Azure) ArrayList(java.util.ArrayList) Deployment(com.microsoft.azure.management.resources.Deployment) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 24 with AzureOperation

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;
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) ArrayList(java.util.ArrayList) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 25 with AzureOperation

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);
    }
}
Also used : AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) IOException(java.io.IOException) 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