99 lines
4.0 KiB
Django/Jinja
99 lines
4.0 KiB
Django/Jinja
{
|
|
"ownerApp" : "Orchestrator",
|
|
"name" : "enable_workspace_clients_for_context",
|
|
"createBy" : "Marco Lettere",
|
|
"description": "All workspace clients registered on Information system for given context are enabled for VRE by calling add_workspace_client_to_context",
|
|
"version" : 1,
|
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
|
"inputParameters" : ["filter", "context"],
|
|
"tasks" : [
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "init",
|
|
"type": "LAMBDA",
|
|
"inputParameters": {
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
|
"ctx" : "${workflow.input.context}",
|
|
"filter" : "${workflow.input.filter}",
|
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} if(e($.ctx)) throw('Context must not be empty'); f=$.filter; if(e(f)) f = []; else if(typeof(f) === 'string') f=[f]; else f=Java.from(f); return { encoded_root_vo : encodeURI($.root_vo), filter : Java.to(f,'java.lang.String[]')}"
|
|
}
|
|
},
|
|
{
|
|
"name" : "pyrest",
|
|
"taskReferenceName" : "authorize_with_uma_rpt",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
|
"method" : "POST",
|
|
"headers" : {
|
|
"Accept" : "application/json"
|
|
},
|
|
"body" : {
|
|
"audience" : "${workflow.input.context}",
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket",
|
|
"client_id" : "orchestrator",
|
|
"client_secret" : "{{ keycloak_auth }}"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name" : "pyrest",
|
|
"taskReferenceName" : "query_workspace_clients_on_icproxy",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"url" : "{{ ic_proxy }}/icproxy/gcube/service/ServiceEndpoint/SystemWorkspaceClient",
|
|
"method" : "GET",
|
|
"headers" : {
|
|
"Authorization" : "Bearer ${authorize_with_uma_rpt.output.body.access_token}"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"name" : "pyeval",
|
|
"taskReferenceName" : "extract_workspace_client_names",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"code" : "exec('import xml.etree.ElementTree as ET') or list(map(lambda n: n.text, ET.fromstring(data['xmlstring']).findall('Resource/Profile/Name')))",
|
|
"xmlstring" : "${query_workspace_clients_on_icproxy.output.body}"
|
|
}
|
|
},
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "filtered_workspace_client_names",
|
|
"type": "LAMBDA",
|
|
"inputParameters": {
|
|
"names" : "${extract_workspace_client_names.output.result}",
|
|
"filter" : "${init.output.result.filter}",
|
|
"scriptExpression": "names=Java.from($.names); f=Java.from($.filter); if(f.length === 0) output=names; else { output=[]; for(i=0;i<names.length;i++){ if(f.indexOf(names[i]) !== -1) output.push(names[i])}} return { 'names' : Java.to(output, 'java.lang.String[]')}"
|
|
}
|
|
},
|
|
{
|
|
"name": "LAMBDA_TASK",
|
|
"taskReferenceName": "build_add_workspace_client_to_context_tasks",
|
|
"type": "LAMBDA",
|
|
"inputParameters": {
|
|
"context" : "${workflow.input.context}",
|
|
"names" : "${filtered_workspace_client_names.output.result.names}",
|
|
"scriptExpression": "inputs={};tasks=[];for(var i=0;i<$.names.length;i++){tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'call_add_ws_client_to_context_'+i, subWorkflowParam:{ name:'add_workspace_client_to_context'}});inputs['call_add_ws_client_to_context_'+i]={client_id:$.names[i], context:$.context}} return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
|
}
|
|
},
|
|
{
|
|
"name" : "fork_dynamic",
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
"taskReferenceName" : "parallel_add_workspace_client_to_context_tasks",
|
|
"inputParameters" : {
|
|
"tasks" : "${build_add_workspace_client_to_context_tasks.output.result.tasks}",
|
|
"inputs" : "${build_add_workspace_client_to_context_tasks.output.result.inputs}"
|
|
},
|
|
"dynamicForkTasksParam": "tasks",
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
},
|
|
{
|
|
"name" : "join",
|
|
"type" : "JOIN",
|
|
"taskReferenceName" : "join_parallel_add_workspace_client_to_context_tasks"
|
|
}
|
|
]
|
|
}
|