From 6a6fbca11872005506120384441e68b944973e85 Mon Sep 17 00:00:00 2001 From: "m.lettere" Date: Thu, 13 Jul 2023 17:20:01 +0200 Subject: [PATCH] added two new subworkflows of group_created --- .../create_vre_folder_for_context.json.j2 | 97 +++++++++++++++++++ templates/record_context_to_is.json.j2 | 95 ++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 templates/create_vre_folder_for_context.json.j2 create mode 100644 templates/record_context_to_is.json.j2 diff --git a/templates/create_vre_folder_for_context.json.j2 b/templates/create_vre_folder_for_context.json.j2 new file mode 100644 index 0000000..96252e5 --- /dev/null +++ b/templates/create_vre_folder_for_context.json.j2 @@ -0,0 +1,97 @@ +{ + "createTime": 1689260185434, + "updateTime": 1689259167761, + "name": "create_vre_folder_for_context", + "description": "Upon creation of a new context, create also a vre folder on the workspace", + "version": 1, + "tasks": [ + { + "name": "LAMBDA_TASK", + "taskReferenceName": "init", + "inputParameters": { + "base_url": "https://url.gcube.d4science.org/", + "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", + "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", + "storagehub" : "{{ storagehub }}" + "ctx": "${workflow.input.context}", + "scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))} if(e($.ctx)) throw('Context must not be empty'); return { decoded_context : $.ctx.replaceAll('%2F', '/') }" + }, + "type": "LAMBDA", + "decisionCases": {}, + "defaultCase": [], + "forkTasks": [], + "startDelay": 0, + "joinOn": [], + "optional": false, + "defaultExclusiveJoinTask": [], + "asyncComplete": false, + "loopOver": [] + }, + { + "name": "pyrest", + "taskReferenceName": "authorize", + "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" + } + }, + "type": "SIMPLE", + "decisionCases": {}, + "defaultCase": [], + "forkTasks": [], + "startDelay": 0, + "joinOn": [], + "optional": false, + "defaultExclusiveJoinTask": [], + "asyncComplete": false, + "loopOver": [] + }, + { + "name": "pyrest", + "taskReferenceName": "create_vre_folder", + "inputParameters": { + "url": "https://en5ql62qrka7q.x.pipedream.net/${init.output.result.child}", + "method": "POST", + "headers": { + "Authorization": "Bearer bearer_here", + "Accept": "application/json", + "Content-Type": "multipart/form-data" + }, + "body": { + "accessType": "WRITE_ALL", + "folderOwner": "", + "group": "${init.output.result.decoded_context}" + } + }, + "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": {} +} diff --git a/templates/record_context_to_is.json.j2 b/templates/record_context_to_is.json.j2 new file mode 100644 index 0000000..0e002af --- /dev/null +++ b/templates/record_context_to_is.json.j2 @@ -0,0 +1,95 @@ +{ + "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": "LAMBDA_TASK", + "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}", + "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", + "decisionCases": {}, + "defaultCase": [], + "forkTasks": [], + "startDelay": 0, + "joinOn": [], + "optional": false, + "defaultExclusiveJoinTask": [], + "asyncComplete": false, + "loopOver": [] + }, + { + "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" + } + } + }, + { + "name": "pyrest", + "taskReferenceName": "write_to_is", + "inputParameters": { + "url": "https://en5ql62qrka7q.x.pipedream.net/${init.output.result.child}", + "method": "PUT", + "headers": { + "Authorization": "Bearer bearer_here", + "Accept": "application/json", + "Content-Type": "application/json" + }, + "body": { + "type": "Context", + "id": "${init.output.result.child}", + "name": "${init.output.result.child}", + "parent": { + "type": "IsParentOf", + "source": { + "type": "Context", + "id": "${init.output.result.parent}" + } + } + } + }, + "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": {} +}