From ce6625934323444d5ec9c8c4bb11ce4e794d5f73 Mon Sep 17 00:00:00 2001 From: "m.lettere" Date: Tue, 18 Jul 2023 11:02:42 +0200 Subject: [PATCH] added queries to IC proxy --- templates/record_context_to_is.json.j2 | 106 ++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 13 deletions(-) diff --git a/templates/record_context_to_is.json.j2 b/templates/record_context_to_is.json.j2 index 0e002af..d84acb0 100644 --- a/templates/record_context_to_is.json.j2 +++ b/templates/record_context_to_is.json.j2 @@ -11,9 +11,10 @@ "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}", + "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", + "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", + "ctx": "${workflow.input.context}", + "ic_proxy" : "{{ ic_proxy }}", "scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} 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', '/') }" }, "type": "LAMBDA", @@ -27,21 +28,100 @@ "asyncComplete": false, "loopOver": [] }, + { + "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" : "pyrest", + "taskReferenceName" : "authorize_uma_paarent_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_parent_vo", + "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_rootvo.output.body.access_token}" + } + } + } + ] + ] + }, + { + "name": "notification_join", + "taskReferenceName": "notification_join_ref", + "type": "JOIN", + "joinOn": ["retrieve_root_vo", "retrieve_parent_vo"] + }, { "name" : "pyrest", "taskReferenceName" : "authorize", "type" : "SIMPLE", "inputParameters" : { - "url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token", - "method" : "POST", - "headers" : { - "Accept" : "application/json" - }, - "body" : { - "client_id" : "orchestrator", - "client_secret" : "{{ keycloak_auth }}", - "grant_type" : "client_credentials" - } + "url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token", + "method" : "POST", + "headers" : { + "Accept" : "application/json" + }, + "body" : { + "client_id" : "orchestrator", + "client_secret" : "{{ keycloak_auth }}", + "grant_type" : "client_credentials" + } } }, {