Search in sources :

Example 1 with FUNCTION

use of com.microsoft.azuretools.telemetry.TelemetryConstants.FUNCTION 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)

Aggregations

AuthorizationLevel (com.microsoft.azure.functions.annotation.AuthorizationLevel)1 FunctionEntity (com.microsoft.azure.toolkit.lib.appservice.entity.FunctionEntity)1 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)1 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)1 Utils (com.microsoft.azure.toolkit.lib.appservice.utils.Utils)1 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)1 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)1 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)1 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)1 AppInsightsConstants (com.microsoft.azuretools.telemetry.AppInsightsConstants)1 FUNCTION (com.microsoft.azuretools.telemetry.TelemetryConstants.FUNCTION)1 TRIGGER_FUNCTION (com.microsoft.azuretools.telemetry.TelemetryConstants.TRIGGER_FUNCTION)1 TelemetryProperties (com.microsoft.azuretools.telemetry.TelemetryProperties)1 DefaultLoader (com.microsoft.tooling.msservices.components.DefaultLoader)1 Node (com.microsoft.tooling.msservices.serviceexplorer.Node)1 NodeActionEvent (com.microsoft.tooling.msservices.serviceexplorer.NodeActionEvent)1 NodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.NodeActionListener)1 WrappedTelemetryNodeActionListener (com.microsoft.tooling.msservices.serviceexplorer.WrappedTelemetryNodeActionListener)1