{ "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" : ["user", "group"], "tasks" : [ { "name": "INLINE_TASK", "taskReferenceName": "init", "type": "INLINE", "inputParameters": { "root_vo": "{{ root_vo }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "group" : "${workflow.input.group}", "evaluatorType" : "javascript", "expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){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)}} f()" } }, { "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" : "check_is_gateway", "taskReferenceName" : "check_is_gateway", "type" : "SWITCH", "evaluatorType" : "javascript", "inputParameters" :{ "group" : "${workflow.input.group}" }, "expression": "$.group.toLowerCase().endsWith('gateway') ? 'gateway' : ''", "decisionCases" : { "gateway" : [ { "name" : "pyrest", "taskReferenceName" : "create_gateway_group", "type" : "SIMPLE", "inputParameters" : { "url" : "${init.input.keycloak_admin}/groups", "body" : { "name" : "${init.output.result.child}" }, "method" : "POST", "headers" : { "Authorization" : "Bearer ${authorize.output.body.access_token}", "Content-Type" : "application/json" } } }, { "name" : "terminate", "taskReferenceName" : "terminate_when_gateway", "type" : "TERMINATE", "inputParameters" : { "terminationStatus" : "COMPLETED" } } ] } }, { "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": "INLINE_TASK", "taskReferenceName": "extract_client_id", "type": "INLINE", "inputParameters": { "client_location" : "${create_client.output.headers.location}", "evaluatorType" : "javascript", "expression": "function f(){var client_id = $.client_location.split('/').pop(); return {'client_id' : client_id}} f()" } }, { "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": "INLINE_TASK", "taskReferenceName": "prepare", "type": "INLINE", "inputParameters": { "evaluatorType" : "javascript", "append": "${init.output.result.append}", "groups": "${list_kc_groups.output.body}", "expression": "function recurse(inp){for(var i=0;i