148 lines
5.4 KiB
Django/Jinja
148 lines
5.4 KiB
Django/Jinja
{
|
|
"createTime": 1689260185434,
|
|
"updateTime": 1689259167761,
|
|
"name": "create_vre_folder_for_context",
|
|
"description": "Upon creation of a new context, create also a vre folder on the workspace",
|
|
"version": 1,
|
|
"tasks": [
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "init",
|
|
"inputParameters": {
|
|
"root_vo": "{{ root_vo }}",
|
|
"base_url": "https://url.gcube.d4science.org/",
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
|
"storagehub" : "{{ storagehub }}/workspace",
|
|
"ctx": "${workflow.input.context}",
|
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} if(e($.ctx)) throw('Context must not be empty'); return { shubified_context_name : ($.ctx[0] === '%' ? $.ctx.replace('%2F', '') : $.ctx).split('%2F').join('-') }"
|
|
},
|
|
"type": "LAMBDA",
|
|
"decisionCases": {},
|
|
"defaultCase": [],
|
|
"forkTasks": [],
|
|
"startDelay": 0,
|
|
"joinOn": [],
|
|
"optional": false,
|
|
"defaultExclusiveJoinTask": [],
|
|
"asyncComplete": false,
|
|
"loopOver": []
|
|
},
|
|
{
|
|
"name" : "pyrest",
|
|
"taskReferenceName" : "authorize_with_uma_rpt",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"url" : "${init.input.keycloak}/protocol/openid-connect/token",
|
|
"method" : "POST",
|
|
"headers" : {
|
|
"Accept" : "application/json"
|
|
},
|
|
"body" : {
|
|
"audience" : "${init.input.root_vo}",
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket",
|
|
"client_id" : "orchestrator",
|
|
"client_secret" : "{{ keycloak_auth }}"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name": "pyrest",
|
|
"taskReferenceName": "create_vre_folder",
|
|
"inputParameters": {
|
|
"url": "${init.input.storagehub}/groups",
|
|
"method": "POST",
|
|
"headers": {
|
|
"Authorization": "Bearer ${authorize_with_uma_rpt.output.body.access_token}",
|
|
"Accept": "text/plain",
|
|
"Content-Type": "multipart/form-data"
|
|
},
|
|
"body": {
|
|
"accessType": [
|
|
"WRITE_OWNER",
|
|
"application/json"
|
|
],
|
|
"group": "${init.output.result.shubified_context_name}",
|
|
"folderOwner": "${workflow.input.folder_owner}"
|
|
}
|
|
},
|
|
"type": "SIMPLE",
|
|
"decisionCases": {},
|
|
"defaultCase": [],
|
|
"forkTasks": [],
|
|
"startDelay": 0,
|
|
"joinOn": [],
|
|
"optional": false,
|
|
"defaultExclusiveJoinTask": [],
|
|
"asyncComplete": false,
|
|
"loopOver": []
|
|
},
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "build_add_vre_folder_users_tasks",
|
|
"type": "LAMBDA",
|
|
"inputParameters": {
|
|
"admins" : "${workflow.input.folder_admins}",
|
|
"url": "${init.input.storagehub}/groups/${init.output.result.shubified_context_name}/users",
|
|
"scriptExpression": "inputs={},tasks=[];for(var i=0;i<$.admins.length;i++)a=$.admins[i],tasks.push({name:'pyrest',type:'SIMPLE',taskReferenceName:'tu_'+i}),inputs['tu_'+i]={url:$.url,body:{userId:a},method:'PUT',headers:{Authorization:'Bearer ${authorize_with_uma_rpt.output.body.access_token}', Accept: 'text/plain'}};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
|
}
|
|
},
|
|
{
|
|
"name" : "fork_dynamic",
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
"taskReferenceName" : "parallel_add_vre_folder_users",
|
|
"inputParameters" : {
|
|
"tasks" : "${build_add_vre_folder_users_tasks.output.result.tasks}",
|
|
"inputs" : "${build_add_vre_folder_users_tasks.output.result.inputs}"
|
|
},
|
|
"dynamicForkTasksParam": "tasks",
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
},
|
|
{
|
|
"name" : "join",
|
|
"type" : "JOIN",
|
|
"taskReferenceName" : "join_parallel_add_vre_folder_users"
|
|
},
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "build_add_vre_folder_admins_tasks",
|
|
"type": "LAMBDA",
|
|
"inputParameters": {
|
|
"admins" : "${workflow.input.folder_admins}",
|
|
"url": "${init.input.storagehub}/groups/${init.output.result.shubified_context_name}/admins",
|
|
"scriptExpression": "inputs={},tasks=[];for(var i=0;i<$.admins.length;i++)a=$.admins[i],tasks.push({name:'pyrest',type:'SIMPLE',taskReferenceName:'ta_'+i}),inputs['ta_'+i]={url:$.url,body:{userId:a},method:'PUT',headers:{Authorization:'Bearer ${authorize_with_uma_rpt.output.body.access_token}', Accept: 'text/plain'}};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
|
}
|
|
},
|
|
{
|
|
"name" : "fork_dynamic",
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
"taskReferenceName" : "parallel_add_vre_folder_admins",
|
|
"inputParameters" : {
|
|
"tasks" : "${build_add_vre_folder_admins_tasks.output.result.tasks}",
|
|
"inputs" : "${build_add_vre_folder_admins_tasks.output.result.inputs}"
|
|
},
|
|
"dynamicForkTasksParam": "tasks",
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
},
|
|
{
|
|
"name" : "join",
|
|
"type" : "JOIN",
|
|
"taskReferenceName" : "join_parallel_add_vre_folder_admins"
|
|
}
|
|
],
|
|
"inputParameters": [
|
|
"context",
|
|
"folder_owner",
|
|
"folder_admins"
|
|
],
|
|
"outputParameters": {},
|
|
"schemaVersion": 2,
|
|
"restartable": true,
|
|
"workflowStatusListenerEnabled": false,
|
|
"ownerEmail": "example@email.com",
|
|
"timeoutPolicy": "ALERT_ONLY",
|
|
"timeoutSeconds": 0,
|
|
"variables": {},
|
|
"inputTemplate": {}
|
|
}
|