{ "createTime": 1689254203836, "updateTime": 1689259676819, "name": "record_context_to_is", "description": "Upon creation of a new context, record it to the Information System", "version": 1, "tasks": [ { "name": "INLINE_TASK", "type" : "INLINE", "taskReferenceName": "init", "inputParameters": { "base_url": "{{is_url}}/resource-registry/contexts", "root_vo": "{{ root_vo }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "ctx": "${workflow.input.context}", "ic_proxy" : "{{ ic_proxy }}", "evaluatorType" : "javascript", "expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} function f(){if(e($.ctx)) throw('Context must not be empty'); var tree = $.ctx.split('%2F'); return { child : tree[tree.length - 1], parent : tree[tree.length-2], decoded_root_vo : $.root_vo.replace('%2F', '/') }} f()" } }, { "name" : "parallel_ic_proxy_queries", "taskReferenceName" : "parallel_ic_proxy_queries", "type" : "FORK_JOIN", "forkTasks" : [ [ { "name" : "pyrest", "taskReferenceName" : "authorize_uma_rootvo", "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" : "retrieve_infrastructure", "type" : "SIMPLE", "inputParameters" : { "url" : "{{ ic_proxy }}/icproxy/gcube/service/GenericResource/INFRASTRUCTURE", "method" : "GET", "headers" : { "Accept" : "application/xml", "Authorization" : "Bearer ${authorize_uma_rootvo.output.body.access_token}" } } }, { "name" : "pyeval", "taskReferenceName" : "extract_infrastructure_id", "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/Body/infrastructures/infrastructure/vos/vo[scope=\\'${init.output.result.decoded_root_vo}/${init.output.result.parent}\\'].id')))", "xmlstring" : "${retrieve_infrastructure.output.body}" } } ], [ { "name" : "pyrest", "taskReferenceName" : "authorize_uma_parent_vo", "type" : "SIMPLE", "inputParameters" : { "url" : "${init.input.keycloak}/protocol/openid-connect/token", "method" : "POST", "headers" : { "Accept" : "application/json" }, "body" : { "audience" : "${init.input.root_vo}%2F${init.output.result.parent}", "grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket", "client_id" : "orchestrator", "client_secret" : "{{ keycloak_auth }}" } } }, { "name" : "pyrest", "taskReferenceName" : "retrieve_vre", "type" : "SIMPLE", "inputParameters" : { "url" : "{{ ic_proxy }}/icproxy/gcube/service/GenericResource/VRE/${init.output.result.child}", "method" : "GET", "headers" : { "Accept" : "application/xml", "Authorization" : "Bearer ${authorize_uma_parent_vo.output.body.access_token}" } } }, { "name" : "pyeval", "taskReferenceName" : "extract_vre_id", "type" : "SIMPLE", "inputParameters" : { "code" : "exec('import xml.etree.ElementTree as ET') or list(map(lambda n: n.text, ET.fromstring(data['xmlstring']).findall('Resource/ID')))", "xmlstring" : "${retrieve_vre.output.body}" } } ] ] }, { "name": "notification_join", "taskReferenceName": "notification_join_ref", "type": "JOIN", "joinOn": ["extract_infrastructure_id", "extract_vre_id"] }, { "type" : "INLINE", "name": "INLINE_TASK", "taskReferenceName": "check", "inputParameters": { "vre": "${extract_vre_id.output.result[0]}", "infra": "${extract_infrastructure_id.output.result[0]}", "evaluatorType" : "javascript", "expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} function f(){if(e($.vre) || e($.infra)) throw('VRE ID and Infra ID must not be empty');} f()" } }, { "name": "pyrest", "taskReferenceName": "write_to_is", "inputParameters": { "url": "${init.input.base_url}/${extract_vre_id.output.result[0]}", "method": "PUT", "headers": { "Authorization": "Bearer ${authorize_uma_rootvo.output.body.access_token}", "Content-Type": "application/json", "Accept" : "application/json" }, "body": { "type": "Context", "id": "${extract_vre_id.output.result[0]}", "name": "${init.output.result.child}", "parent": { "type": "IsParentOf", "source": { "type": "Context", "id": "${extract_infrastructure_id.output.result[0]}" } } } }, "type": "SIMPLE", "decisionCases": {}, "defaultCase": [], "forkTasks": [], "startDelay": 0, "joinOn": [], "optional": false, "defaultExclusiveJoinTask": [], "asyncComplete": false, "loopOver": [] } ], "inputParameters": [ "context" ], "outputParameters": {}, "schemaVersion": 2, "restartable": true, "workflowStatusListenerEnabled": false, "ownerEmail": "example@email.com", "timeoutPolicy": "ALERT_ONLY", "timeoutSeconds": 0, "variables": {}, "inputTemplate": {} }