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