use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class UnitTest method mapDataTest.
/**
* The data returned by the task may be either a Map containing all of the
* key/value pairs in the Vault secret OR a single String value from the
* Vault secret when a specific secret "key" is specified.
*/
@Test
public void mapDataTest() {
Variables vars = new MapBackedVariables(getMap("path", "secret/mysecret"));
TaskParams params = TaskParams.of(vars, null, exporter);
HashiVaultTaskResult result = HashiVaultTaskResult.of(true, getMap("top_secret", "value"), null, params);
try {
String s = result.data();
fail("data should be Map when key param is not given");
} catch (ClassCastException e) {
// that's expected
}
// this should work
Map<String, Object> m = result.data();
assertEquals(1, m.size());
}
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, SecretExporter secretExporter) {
Map<String, Object> variablesMap = new HashMap<>(defaults != null ? defaults : Collections.emptyMap());
variablesMap.putAll(input.toMap());
if (variablesMap.containsKey(API_TOKEN_SECRET_KEY)) {
Map<String, Object> tokenSecret = MapUtils.assertMap(variablesMap, API_TOKEN_SECRET_KEY);
variablesMap.put(API_TOKEN_KEY, exportToken(secretExporter, tokenSecret));
}
Variables variables = new MapBackedVariables(variablesMap);
TaskParams p = new TaskParams(variables);
switch(p.action()) {
case READKV:
case WRITEKV:
return new TaskParams(variables);
default:
throw new IllegalArgumentException("Unsupported action type: " + p.action());
}
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class TeamsV2TaskParams method of.
public static TeamsV2TaskParams of(Variables input, Map<String, Object> defaults) {
Variables variables = Utils.merge(input, defaults);
Action action = new TeamsV2TaskParams(variables).action();
switch(action) {
case CREATECONVERSATION:
{
return new CreateConversationParams(variables);
}
case REPLYTOCONVERSATION:
{
return new ReplayToConversationParams(variables);
}
default:
throw new IllegalArgumentException("Unsupported action type: " + action);
}
}
use of com.walmartlabs.concord.runtime.v2.sdk.Variables in project concord-plugins by walmartlabs.
the class TeamsV2TaskV2 method execute.
@Override
public TaskResult execute(Variables input) {
Result r = delegate.execute(TeamsV2TaskParams.of(input, context.defaultVariables().toMap()));
TaskResult.SimpleResult result = TaskResult.of(r.isOk(), r.getError()).value("data", r.getData());
if (r.getActivityId() != null && r.getConversationId().contains(r.getActivityId())) {
result.value("conversationId", r.getConversationId()).value("activityId", r.getActivityId());
}
return result;
}
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 ADDCOMMENT:
{
return new AddCommentParams(variables);
}
case CREATECOMPONENT:
{
return new CreateComponentParams(variables);
}
case CREATEISSUE:
{
return new CreateIssueParams(variables);
}
case DELETECOMPONENT:
{
return new DeleteComponentParams(variables);
}
case DELETEISSUE:
{
return new DeleteIssueParams(variables);
}
case TRANSITION:
{
return new TransitionParams(variables);
}
case UPDATEISSUE:
{
return new UpdateIssueParams(variables);
}
case CREATESUBTASK:
{
return new CreateSubTaskParams(variables);
}
case CURRENTSTATUS:
{
return new CurrentStatusParams(variables);
}
case ADDATTACHMENT:
{
return new AddAttachmentParams(variables);
}
case GETISSUES:
{
return new GetIssuesParams(variables);
}
default:
throw new IllegalArgumentException("Unsupported action type: " + action);
}
}
Aggregations