Search in sources :

Example 36 with AzureOperation

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

the class AzureMvpModel method listDeploymentsBySid.

@AzureOperation(name = "arm|deployment.list.subscription", params = { "sid" }, type = AzureOperation.Type.SERVICE)
public List<Deployment> listDeploymentsBySid(String sid) {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    List<Deployment> deployments = azure.deployments().list();
    Collections.sort(deployments, getComparator(Deployment::name));
    return deployments;
}
Also used : Azure(com.microsoft.azure.management.Azure) Deployment(com.microsoft.azure.management.resources.Deployment) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 37 with AzureOperation

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

the class AzureSdkLibraryService method loadAzureSDKWhitelist.

@Cacheable("sdk/packages/whitelist")
@AzureOperation(name = "sdk.load_meta_data.whitelist", type = AzureOperation.Type.TASK)
private static Set<String> loadAzureSDKWhitelist() {
    try {
        final URL destination = AzureSdkLibraryService.class.getResource(SDK_ALLOW_LIST_CSV);
        final ObjectReader reader = CSV_MAPPER.readerFor(AzureSdkAllowListEntity.class).with(CsvSchema.emptySchema().withHeader());
        final MappingIterator<AzureSdkAllowListEntity> data = reader.readValues(destination);
        return data.readAll().stream().filter(e -> StringUtils.isNoneBlank(e.getArtifactId(), e.getGroupId())).map(AzureSdkAllowListEntity::getPackageName).collect(Collectors.toSet());
    } catch (final IOException e) {
        log.warn(String.format("failed to load Azure SDK allow list from \"%s\"", SDK_ALLOW_LIST_CSV), e);
    }
    return Collections.emptySet();
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException) AzureSdkAllowListEntity(com.microsoft.azure.toolkit.intellij.azuresdk.model.AzureSdkAllowListEntity) URL(java.net.URL) Cacheable(com.microsoft.azure.toolkit.lib.common.cache.Cacheable) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 38 with AzureOperation

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

the class FunctionNode method trigger.

@AzureOperation(name = "function|trigger.start.detail", params = { "this.functionApp.name()" }, type = AzureOperation.Type.SERVICE)
private void trigger() {
    final FunctionEntity.BindingEntity trigger = functionEntity.getTrigger();
    final String triggerType = Optional.ofNullable(trigger).map(functionTrigger -> functionTrigger.getProperty("type")).orElse(null);
    if (StringUtils.isEmpty(triggerType)) {
        final String error = String.format("failed to get trigger type of function[%s].", functionApp.name());
        final String action = "confirm trigger type is configured.";
        throw new AzureToolkitRuntimeException(error, action);
    }
    switch(triggerType.toLowerCase()) {
        case "httptrigger":
            triggerHttpTrigger(trigger);
            break;
        case "timertrigger":
            // no input for timer trigger
            functionApp.triggerFunction(this.name, new Object());
            break;
        default:
            final String input = DefaultLoader.getUIHelper().showInputDialog(tree.getParent(), "Please set the input value: ", String.format("Trigger function %s", this.name), null);
            functionApp.triggerFunction(this.name, new TriggerRequest(input));
            break;
    }
}
Also used : AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) RequiredArgsConstructor(lombok.RequiredArgsConstructor) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) AppInsightsConstants(com.microsoft.azuretools.telemetry.AppInsightsConstants) TRIGGER_FUNCTION(com.microsoft.azuretools.telemetry.TelemetryConstants.TRIGGER_FUNCTION) WrappedTelemetryNodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener) EnumUtils(org.apache.commons.lang3.EnumUtils) AuthorizationLevel(com.microsoft.azure.functions.annotation.AuthorizationLevel) Map(java.util.Map) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) Nonnull(javax.annotation.Nonnull) NodeActionListener(com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) TelemetryProperties(com.microsoft.azuretools.telemetry.TelemetryProperties) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) Optional(java.util.Optional) Utils(com.microsoft.azure.toolkit.lib.appservice.utils.Utils) FUNCTION(com.microsoft.azuretools.telemetry.TelemetryConstants.FUNCTION) OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) NodeActionEvent(com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent) FunctionEntity(com.microsoft.azure.toolkit.lib.appservice.entity.FunctionEntity) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) FunctionEntity(com.microsoft.azure.toolkit.lib.appservice.entity.FunctionEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 39 with AzureOperation

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

the class VMNode method delete.

@AzureOperation(name = "vm.delete", params = { "this.virtualMachine.name()" }, type = AzureOperation.Type.ACTION)
private void delete() {
    AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
    // not signed in
    if (azureManager == null) {
        return;
    }
    azureManager.getAzure(subscriptionId).virtualMachines().deleteByResourceGroup(virtualMachine.resourceGroupName(), virtualMachine.name());
    DefaultLoader.getIdeHelper().invokeLater(() -> {
        // instruct parent node to remove this node
        getParent().removeDirectChildNode(VMNode.this);
    });
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 40 with AzureOperation

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

the class CreateSpringCloudAppAction method createApp.

@AzureOperation(name = "springcloud|app.create", params = "config.getAppName()", type = AzureOperation.Type.ACTION)
private static void createApp(SpringCloudAppConfig config) {
    AzureTaskManager.getInstance().runInBackground(AzureOperationBundle.title("springcloud|app.create", config.getAppName()), () -> {
        final DeploySpringCloudAppTask task = new DeploySpringCloudAppTask(config);
        final SpringCloudDeployment deployment = task.execute();
        if (!deployment.waitUntilReady(GET_STATUS_TIMEOUT)) {
            AzureMessager.getMessager().warning(GET_DEPLOYMENT_STATUS_TIMEOUT, NOTIFICATION_TITLE);
        }
    });
}
Also used : DeploySpringCloudAppTask(com.microsoft.azure.toolkit.lib.springcloud.task.DeploySpringCloudAppTask) SpringCloudDeployment(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudDeployment) 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