2021-07-14 17:15:03 +02:00
|
|
|
{
|
|
|
|
"ownerApp" : "Orchestrator",
|
|
|
|
"name" : "da_cache_to_shub",
|
|
|
|
"createBy" : "Marco Lettere",
|
|
|
|
"description": "Workflow for streaming da_cache files to storage hub",
|
|
|
|
"version" : 1,
|
|
|
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
|
|
|
"inputParameters" : ["token", "descriptor"],
|
|
|
|
"tasks" : [
|
|
|
|
{
|
2021-07-16 10:46:36 +02:00
|
|
|
"name": "LAMBDA_TASK",
|
2021-09-13 15:00:27 +02:00
|
|
|
"taskReferenceName": "init",
|
2021-07-16 10:46:36 +02:00
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
2021-07-16 11:21:55 +02:00
|
|
|
"downloads" : "${workflow.input.descriptor.downloads.*}",
|
2021-09-13 15:00:27 +02:00
|
|
|
"storagehub" : "{{ storagehub }}",
|
2021-07-16 10:46:36 +02:00
|
|
|
"auth" : "Bearer ${workflow.input.token}",
|
2021-09-13 15:00:27 +02:00
|
|
|
"parentfolder" : "Blue-Cloud Data Downloads",
|
2021-09-13 15:13:40 +02:00
|
|
|
"folder" : "${workflow.input.descriptor.order_name}-${workflow.input.descriptor.order_number}",
|
2021-09-13 15:00:27 +02:00
|
|
|
"scriptExpression": "1 === 1"
|
2021-07-16 10:46:36 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-09-13 15:00:27 +02:00
|
|
|
"name" : "http",
|
|
|
|
"taskReferenceName" : "get_workspace",
|
|
|
|
"type" : "HTTP",
|
|
|
|
"inputParameters" : {
|
|
|
|
"http_request": {
|
|
|
|
"uri" : "${init.input.storagehub}/workspace",
|
|
|
|
"method" : "GET",
|
2021-09-13 15:36:02 +02:00
|
|
|
"headers" : { "Authorization" : "${init.input.auth}" }
|
2021-09-13 15:00:27 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 10:46:36 +02:00
|
|
|
},
|
|
|
|
{
|
2021-09-13 15:00:27 +02:00
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "init2",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
2021-09-13 15:38:16 +02:00
|
|
|
"workspace_root_folder_id" : "${get_workspace.output.response.body.item.id}",
|
|
|
|
"scriptExpression": "1 === 1"
|
2021-09-13 15:00:27 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "http",
|
|
|
|
"taskReferenceName" : "check_folder",
|
|
|
|
"type" : "HTTP",
|
|
|
|
"inputParameters" : {
|
|
|
|
"http_request": {
|
|
|
|
"uri" : "${init.input.storagehub}/workspace/items/${init2.input.workspace_root_folder_id}/items/${init.input.parentfolder}",
|
|
|
|
"method" : "GET",
|
2021-09-13 15:36:02 +02:00
|
|
|
"headers" : { "Authorization" : "${init.input.auth}" }
|
2021-09-13 15:00:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-09-13 16:11:26 +02:00
|
|
|
{
|
|
|
|
"name": "decision",
|
|
|
|
"taskReferenceName": "check_user_existance",
|
|
|
|
"inputParameters": {
|
2021-09-13 16:20:09 +02:00
|
|
|
"folders": "${check_folder.output.response.body.itemlist}"
|
2021-09-13 16:11:26 +02:00
|
|
|
},
|
|
|
|
"type": "DECISION",
|
|
|
|
"caseExpression": "($.folders.length === 0 ? 'create' : 'exists')",
|
|
|
|
"decisionCases": {
|
|
|
|
"create": [
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "create_parent_folder",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
2021-09-13 16:14:57 +02:00
|
|
|
"url" : "${init.input.storagehub}/workspace/items/${init2.input.workspace_root_folder_id}/create/FOLDER",
|
2021-09-13 16:11:26 +02:00
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Content-type": "application/x-www-form-urlencoded",
|
2021-09-13 16:22:26 +02:00
|
|
|
"Accept" : "text/plain",
|
|
|
|
"Authorization" : "${init.input.auth}"
|
2021-09-13 16:11:26 +02:00
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"name" : "${init.input.parentfolder}",
|
|
|
|
"description" : "Root folder of all Bluecloud data downloads",
|
|
|
|
"hidden" : "false"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2021-09-13 16:38:23 +02:00
|
|
|
"type": "SET_VARIABLE",
|
2021-09-13 16:39:28 +02:00
|
|
|
"name": "store_parent_folderid_1",
|
2021-09-13 16:40:35 +02:00
|
|
|
"taskReferenceName": "store_parent_folderid_1",
|
2021-09-13 16:11:26 +02:00
|
|
|
"inputParameters": {
|
2021-09-13 16:56:02 +02:00
|
|
|
"parent_folder_id": "${create_parent_folder.output.body}"
|
2021-09-13 16:11:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"exists" : [
|
|
|
|
{
|
2021-09-13 16:38:23 +02:00
|
|
|
"type": "SET_VARIABLE",
|
2021-09-13 16:39:28 +02:00
|
|
|
"name": "store_parent_folderid_2",
|
2021-09-13 16:40:35 +02:00
|
|
|
"taskReferenceName": "store_parent_folderid_2",
|
2021-09-13 16:11:26 +02:00
|
|
|
"inputParameters": {
|
2021-09-13 16:38:23 +02:00
|
|
|
"parent_folder_id": "${check_folder.output.response.body.itemlist[0].id}"
|
2021-09-13 16:11:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2021-09-13 16:38:23 +02:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "create_destination_folder",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.storagehub}/workspace/items/${workflow.variables.parent_folder_id}/create/FOLDER",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Content-type": "application/x-www-form-urlencoded",
|
|
|
|
"Accept" : "text/plain",
|
|
|
|
"Authorization" : "${init.input.auth}"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"name" : "${init.input.folder}",
|
|
|
|
"description" : "Target folder of Bluecloud data downloads",
|
|
|
|
"hidden" : "false"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "SET_VARIABLE",
|
|
|
|
"name": "store_target_folderid",
|
|
|
|
"taskReferenceName": "store_target_folderid",
|
|
|
|
"inputParameters": {
|
2021-09-13 16:56:02 +02:00
|
|
|
"target_folder_id": "${create_destination_folder.output.body}"
|
2021-09-13 16:38:23 +02:00
|
|
|
}
|
|
|
|
},
|
2021-09-13 15:00:27 +02:00
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "build_transfer_tasks",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
2021-09-13 16:38:23 +02:00
|
|
|
"downloads" : "${workflow.input.descriptor.downloads.*}",
|
2021-09-13 17:17:23 +02:00
|
|
|
"upload" : "${init.input.storagehub}/workspace/items/${init2.input.workspace_root_folder_id}/items/${workflow.variables.parent_folder_id}/items/${workflow.variables.target_folder_id}/create/FILE",
|
2021-09-13 15:00:27 +02:00
|
|
|
"auth" : "Bearer ${workflow.input.token}",
|
|
|
|
"description" : "${workflow.input.descriptor.order_name}",
|
|
|
|
"scriptExpression": "inputs={};tasks=[];for(var i=0;i<$.downloads.length;i++)download=$.downloads[i],tasks.push({name:'pyrestbridge',type:'SIMPLE',taskReferenceName:'bridge_'+i}),inputs['bridge_'+i]={ datamap : { place: 'files', name : 'file'}, endpoint1 : { url: download.url}, endpoint2 : { url: $.upload, headers: { Authorization : $.auth}, files: { name : 'file' + download.number, description : $.description[0]}} };return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
|
|
|
}
|
2021-09-13 16:38:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_dynamic",
|
|
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
|
|
"taskReferenceName" : "parallel_downloads",
|
|
|
|
"inputParameters" : {
|
|
|
|
"tasks" : "${build_transfer_tasks.output.result.tasks}",
|
|
|
|
"inputs" : "${build_transfer_tasks.output.result.inputs}"
|
|
|
|
},
|
|
|
|
"dynamicForkTasksParam": "tasks",
|
|
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "join",
|
|
|
|
"type" : "JOIN",
|
|
|
|
"taskReferenceName" : "join_parallel_downloads"
|
2021-07-14 17:15:03 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|