Search in sources :

Example 31 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class UnitTest method stringDataTest.

@Test
public void stringDataTest() {
    Variables vars = new MapBackedVariables(getMap("path", "secret/mysecret", "key", "top_secret"));
    TaskParams params = TaskParams.of(vars, null, exporter);
    HashiVaultTaskResult result = HashiVaultTaskResult.of(true, getMap("top_secret", "value"), null, params);
    try {
        Map<String, Object> m = result.data();
        fail("data should be String when key param is given");
    } catch (ClassCastException e) {
    // that's expected
    }
    // this should work
    String s = result.data();
    assertEquals("value", s);
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables) MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Test(org.junit.Test)

Example 32 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class TeamsTaskParams method of.

public static TeamsTaskParams of(Variables input, Map<String, Object> defaults) {
    Variables variables = Utils.merge(input, defaults);
    Action action = new TeamsTaskParams(variables).action();
    switch(action) {
        case SENDMESSAGE:
            {
                return new SendMessageParams(variables);
            }
        default:
            throw new IllegalArgumentException("Unsupported action type: " + action);
    }
}
Also used : Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables)

Example 33 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class TaskParams method of.

public static TaskParams of(Variables input, Map<String, Object> defaults) {
    Variables variables = merge(input, defaults);
    Action action = new TaskParams(variables).action();
    switch(action) {
        case SEARCHBYDN:
            {
                return new SearchByDnParams(variables);
            }
        case GETUSER:
            {
                return new GetUserParams(variables);
            }
        case GETGROUP:
            {
                return new GetGroupParams(variables);
            }
        case ISMEMBEROF:
            {
                return new MemberOfParams(variables);
            }
        default:
            throw new IllegalArgumentException("Unsupported action type: " + action);
    }
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables)

Example 34 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class S3TaskV2 method execute.

@Override
@SuppressWarnings("unchecked")
public TaskResult execute(Variables input) throws Exception {
    Result result = delegate.execute(TaskParams.of(input, context.defaultVariables().toMap()));
    ObjectMapper om = new ObjectMapper();
    Map<String, Object> r = om.convertValue(result, Map.class);
    return TaskResult.of(MapUtils.getBoolean(r, "ok", false), MapUtils.getString(r, "error")).values(r);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TaskResult(com.walmartlabs.concord.runtime.v2.sdk.TaskResult) Result(com.walmartlabs.concord.plugins.s3.Result)

Example 35 with Variables

use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.

the class TaskParams method of.

public static TaskParams of(Variables input, Map<String, Object> defaults) {
    Variables variables = merge(input, defaults);
    Action action = new TaskParams(variables).action();
    switch(action) {
        case RUN:
            {
                return new RunParams(variables);
            }
        default:
            throw new IllegalArgumentException("Unsupported action type: " + action);
    }
}
Also used : MapBackedVariables(com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables) Variables(com.walmartlabs.concord.runtime.v2.sdk.Variables)

Aggregations

Variables (com.walmartlabs.concord.runtime.v2.sdk.Variables)24 MapBackedVariables (com.walmartlabs.concord.runtime.v2.sdk.MapBackedVariables)16 HashMap (java.util.HashMap)7 Test (org.junit.Test)6 SimpleResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult.SimpleResult)5 Path (java.nio.file.Path)4 Map (java.util.Map)4 TaskProviders (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskProviders)3 UpdateLocalsCommand (com.walmartlabs.concord.runtime.v2.runner.vm.UpdateLocalsCommand)3 TaskResult (com.walmartlabs.concord.runtime.v2.sdk.TaskResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ProcessDefinition (com.walmartlabs.concord.runtime.v2.model.ProcessDefinition)2 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)2 com.walmartlabs.concord.runtime.v2.sdk (com.walmartlabs.concord.runtime.v2.sdk)2 ProcessConfiguration (com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration)2 Inject (javax.inject.Inject)2 Named (javax.inject.Named)2 Injector (com.google.inject.Injector)1 ApiClient (com.walmartlabs.concord.ApiClient)1 DependencyManager (com.walmartlabs.concord.dependencymanager.DependencyManager)1