diff --git a/templates/create_vre.json.j2 b/templates/create_vre.json.j2 new file mode 100644 index 0000000..1c51f29 --- /dev/null +++ b/templates/create_vre.json.j2 @@ -0,0 +1,645 @@ +{ + "ownerApp" : "Orchestrator", + "name" : "group_created", + "createBy" : "Marco Lettere", + "description": "Handle workflow related to Portal event group_created", + "version" : 1, + "ownerEmail" : "marco.lettere@nubisware.com", + "inputParameters" : ["context", "folder_owner", "folder_admins"], + "tasks" : [ + { + "name": "LAMBDA_TASK", + "taskReferenceName": "init", + "type": "LAMBDA", + "inputParameters": { + "root_vo": "{{ root_vo }}", + "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", + "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", + "group" : "${workflow.input.context}", + "scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.group)) throw('Group must not be empty'); var tree = $.group.startsWith('%2F') ? $.group.split('%2F') : [$.group]; return { 'tree' : tree, 'child': tree[tree.length-1], 'append' : tree.slice(0,-1).join('/'), 'name' : tree.join('/'), encoded_root_vo : encodeURI($.root_vo)}" + } + }, + { + "name" : "pyrest", + "taskReferenceName" : "authorize", + "type" : "SIMPLE", + "inputParameters" : { + "url" : "{{ keycloak }}/master/protocol/openid-connect/token", + "method" : "POST", + "headers" : { + "Accept" : "application/json" + }, + "body" : { + "client_id" : "orchestrator", + "client_secret" : "{{ keycloak_auth_master }}", + "grant_type" : "client_credentials" + } + } + }, + { + "name" : "fork_join", + "taskReferenceName" : "preliminary_fork", + "type" : "FORK_JOIN", + "forkTasks" : [ + [ + { + "name" : "pyrest", + "taskReferenceName" : "create_client", + "type" : "SIMPLE", + "inputParameters" : { + "url" : "${init.input.keycloak_admin}/clients", + "body" : { + "clientId": "${init.input.group}", + "name": "${init.output.result.name}", + "description": "Client representation for ${init.output.result.name} context", + "rootUrl": "http://localhost${init.output.result.name}", + "enabled": true, + "serviceAccountsEnabled": true, + "standardFlowEnabled": true, + "authorizationServicesEnabled": true, + "publicClient": false, + "fullScopeAllowed" : false, + "protocol": "openid-connect" + }, + "method" : "POST", + "headers" : { + "Authorization" : "Bearer ${authorize.output.body.access_token}", + "Content-Type" : "application/json" + } + } + }, + { + "name": "LAMBDA_TASK", + "taskReferenceName": "extract_client_id", + "type": "LAMBDA", + "inputParameters": { + "client_location" : "${create_client.output.headers.location}", + "scriptExpression": "var client_id = $.client_location.split('/').pop(); return {'client_id' : client_id}" + } + }, + { + "name" : "pyrest", + "taskReferenceName" : "list_kc_groups", + "type" : "SIMPLE", + "inputParameters" : { + "url" : "${init.input.keycloak_admin}/groups", + "method" : "GET", + "headers" : { + "Authorization" : "Bearer ${authorize.output.body.access_token}", + "Accept" : "application/json" + } + } + }, + { + "name": "LAMBDA_TASK", + "taskReferenceName": "prepare", + "type": "LAMBDA", + "inputParameters": { + "append": "${init.output.result.append}", + "groups": "${list_kc_groups.output.body}", + "scriptExpression": "function recurse(inp){for(var i=0;i