From 688e6925047eac8e2fe75414fa73dbcf47dd6a10 Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Wed, 21 Jun 2023 23:33:08 -0300 Subject: [PATCH 1/6] [WIP] Build CloudBank Transfer Sample Workflow. -- Add README -- First cbank workflow code Signed-off-by: Paulo Alberto Simoes --- cloudbank-v2/spring-apps/workflow/README.md | 0 cloudbank-v2/spring-apps/workflow/body.json | 146 ++++++++++++++++++ .../workflow/first_cbank_workflow copy.json | 97 ++++++++++++ .../workflow/first_cbank_workflow.json | 90 +++++++++++ .../workflow/first_sample_workflow.json | 31 ++++ .../workflow/ip_weather_workflow.json | 64 ++++++++ 6 files changed, 428 insertions(+) create mode 100644 cloudbank-v2/spring-apps/workflow/README.md create mode 100644 cloudbank-v2/spring-apps/workflow/body.json create mode 100644 cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json create mode 100644 cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json create mode 100644 cloudbank-v2/spring-apps/workflow/first_sample_workflow.json create mode 100644 cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json diff --git a/cloudbank-v2/spring-apps/workflow/README.md b/cloudbank-v2/spring-apps/workflow/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/cloudbank-v2/spring-apps/workflow/body.json b/cloudbank-v2/spring-apps/workflow/body.json new file mode 100644 index 000000000..ac99ff2ce --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/body.json @@ -0,0 +1,146 @@ +[ + { + "ownerApp": "string", + "createTime": 0, + "updateTime": 0, + "createdBy": "string", + "updatedBy": "string", + "accessPolicy": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "name": "string", + "description": "string", + "version": 0, + "tasks": [ + { + "name": "string", + "taskReferenceName": "string", + "description": "string", + "inputParameters": { + "additionalProp1": {}, + "additionalProp2": {}, + "additionalProp3": {} + }, + "type": "string", + "dynamicTaskNameParam": "string", + "scriptExpression": "string", + "decisionCases": { + "additionalProp1": [ + "string" + ], + "additionalProp2": [ + "string" + ], + "additionalProp3": [ + "string" + ] + }, + "dynamicForkTasksParam": "string", + "dynamicForkTasksInputParamName": "string", + "defaultCase": [ + "string" + ], + "forkTasks": [ + [ + "string" + ] + ], + "startDelay": 0, + "subWorkflowParam": { + "name": "string", + "version": 0, + "taskToDomain": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "workflowDefinition": "string" + }, + "joinOn": [ + "string" + ], + "sink": "string", + "optional": true, + "taskDefinition": { + "ownerApp": "string", + "createTime": 0, + "updateTime": 0, + "createdBy": "string", + "updatedBy": "string", + "accessPolicy": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "name": "string", + "description": "string", + "retryCount": 10, + "timeoutSeconds": 0, + "inputKeys": [ + "string" + ], + "outputKeys": [ + "string" + ], + "timeoutPolicy": "RETRY", + "retryLogic": "FIXED", + "retryDelaySeconds": 0, + "responseTimeoutSeconds": 1, + "concurrentExecLimit": 0, + "inputTemplate": { + "additionalProp1": {}, + "additionalProp2": {}, + "additionalProp3": {} + }, + "rateLimitPerFrequency": 0, + "rateLimitFrequencyInSeconds": 0, + "isolationGroupId": "string", + "executionNameSpace": "string", + "ownerEmail": "string", + "pollTimeoutSeconds": 0, + "backoffScaleFactor": 1 + }, + "rateLimited": true, + "defaultExclusiveJoinTask": [ + "string" + ], + "asyncComplete": true, + "loopCondition": "string", + "loopOver": [ + "string" + ], + "retryCount": 0, + "evaluatorType": "string", + "expression": "string", + "workflowTaskType": "SIMPLE" + } + ], + "inputParameters": [ + "string" + ], + "outputParameters": { + "additionalProp1": {}, + "additionalProp2": {}, + "additionalProp3": {} + }, + "failureWorkflow": "string", + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": true, + "ownerEmail": "string", + "timeoutPolicy": "TIME_OUT_WF", + "timeoutSeconds": 0, + "variables": { + "additionalProp1": {}, + "additionalProp2": {}, + "additionalProp3": {} + }, + "inputTemplate": { + "additionalProp1": {}, + "additionalProp2": {}, + "additionalProp3": {} + } + } +] \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json new file mode 100644 index 000000000..0b50b4eca --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json @@ -0,0 +1,97 @@ +{ + "name": "first_cbank_workflow", + "description": "First Cloud Bank Sample Workflow", + "version": 1, + "inputParameters": [ + "fromCustomerEmail", + "toCustomerEmail", + "amount" + ], + "tasks": [ + { + "name": "call_customer_service", + "taskReferenceName": "call_customer_service_from", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.fromCustomerEmail}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "call_customer_service", + "taskReferenceName": "call_customer_service_to", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.toCustomerEmail}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_from", + "type": "HTTP", + "inputParameters": { + "fromCustomerId": "${call_customer_service_from.output.response.body.customerId}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${call_customer_service_from.output.response.body.customerId}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_to", + "type": "HTTP", + "inputParameters": { + "toCustomerId": "${call_customer_service_to.output.response.body.customerId}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${call_customer_service_to.output.response.body.customerId}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_cleanup", + "taskReferenceName": "jq_cleanup_ref", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_account_service_from.output.response.body}", + "queryExpression": "[.starfromAccountList[]]" + } + }, + { + "name": "call_transfer_service", + "taskReferenceName": "call_transfer_service", + "type": "HTTP", + "inputParameters": { + "fromAccount": "1", + "toAccount": "2", + "http_request": { + "uri": "http://transfer.application.svc.cluster.local:8080/api/v1/transfer?fromAccount=22&toAccount=21&amount=${workflow.input.amount}", + "method": "POST" + } + } + } + ], + "outputParameters": { + "transferMessage": "${call_transfer_service.output.response.body}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": false, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 +} \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json new file mode 100644 index 000000000..295b084fd --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json @@ -0,0 +1,90 @@ +{ + "name": "first_cbank_workflow", + "description": "First Cloud Bank Sample Workflow", + "version": 1, + "inputParameters": [ + "fromCustomerEmail", + "fromAccountType", + "toCustomerEmail", + "toAccountType", + "amount" + ], + "tasks": [ + { + "name": "call_customer_service", + "taskReferenceName": "call_customer_service_from", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.fromCustomerEmail}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_fromCustomerId", + "taskReferenceName": "jq_get_fromCustomerId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_customer_service_from.output.response.body}", + "queryExpression": ".fromAccountList[] | .customerId" + } + }, + { + "name": "call_customer_service", + "taskReferenceName": "call_customer_service_to", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.toCustomerEmail}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_toCustomerId", + "taskReferenceName": "jq_get_toCustomerId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_customer_service_to.output.response.body}", + "queryExpression": ".fromAccountList[] | .customerId" + } + }, + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_from", + "type": "HTTP", + "inputParameters": { + "fromCustomerId": "${jq_get_fromCustomerId.output.result}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${jq_get_fromCustomerId.output.result}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_fromAccountId", + "taskReferenceName": "jq_get_fromAccountId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_account_service_from.output.response.body}", + "queryExpression": ".fromAccountList[] | select (.accountType == \"${workflow.input.fromAccountType}\") | .accountId" + } + } + ], + "outputParameters": { + "fromAccountId": "${jq_get_fromAccountId.output.result}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": true, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 +} diff --git a/cloudbank-v2/spring-apps/workflow/first_sample_workflow.json b/cloudbank-v2/spring-apps/workflow/first_sample_workflow.json new file mode 100644 index 000000000..ea914cb85 --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/first_sample_workflow.json @@ -0,0 +1,31 @@ +[ + { + "name": "first_sample_workflow", + "description": "First Sample Workflow", + "version": 1, + "tasks": [ + { + "name": "get_population_data", + "taskReferenceName": "get_population_data", + "inputParameters": { + "http_request": { + "uri": "https://datausa.io/api/data?drilldowns=Nation&measures=Population", + "method": "GET" + } + }, + "type": "HTTP" + } + ], + "inputParameters": [], + "outputParameters": { + "data": "${get_population_data.output.response.body.data}", + "source": "${get_population_data.output.response.body.source}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": false, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 + } +] \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json b/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json new file mode 100644 index 000000000..add3600c5 --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json @@ -0,0 +1,64 @@ +{ + "name": "ip_weather_workflow", + "description": "Sample Workflow", + "version": 1, + "inputParameters": [ + "my_ip" + ], + "tasks": [ + { + "name": "Get_IP", + "taskReferenceName": "get_IP_ref", + "inputParameters": { + "http_request": { + "uri": "http://ip-api.com/json/${workflow.input.ipaddress}?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,offset,isp,org,as,query", + "method": "GET" + } + }, + "type": "HTTP", + "decisionCases": {}, + "defaultCase": [], + "forkTasks": [], + "startDelay": 0, + "joinOn": [], + "optional": false, + "defaultExclusiveJoinTask": [], + "asyncComplete": false, + "loopOver": [], + "retryCount": 3 + }, + { + "name": "Get_weather", + "taskReferenceName": "get_weather_ref", + "inputParameters": { + "zip_code": "${get_IP_ref.output.response.body.zip}", + "http_request": { + "uri": "https://weatherdbi.herokuapp.com/data/weather/${get_IP_ref.output.response.body.zip}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + }, + "type": "HTTP", + "decisionCases": {}, + "defaultCase": [], + "forkTasks": [], + "startDelay": 0, + "joinOn": [], + "optional": false, + "defaultExclusiveJoinTask": [], + "asyncComplete": false, + "loopOver": [] + } + ], + "outputParameters": { + "zipcode": "${get_IP_ref.output.response.body.zip}", + "forecast": "${get_weather_ref.output.response.body.currentConditions.comment}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": true, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 +} \ No newline at end of file From 2c8b3263b3d426652c88d614f8dd6a5965cfa3a4 Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Thu, 22 Jun 2023 00:12:49 -0300 Subject: [PATCH 2/6] WIP First Workflow Signed-off-by: Paulo Alberto Simoes --- cloudbank-v2/spring-apps/workflow/body.json | 151 +----------------- .../workflow/first_cbank_workflow.json | 40 ++++- 2 files changed, 44 insertions(+), 147 deletions(-) diff --git a/cloudbank-v2/spring-apps/workflow/body.json b/cloudbank-v2/spring-apps/workflow/body.json index ac99ff2ce..115280843 100644 --- a/cloudbank-v2/spring-apps/workflow/body.json +++ b/cloudbank-v2/spring-apps/workflow/body.json @@ -1,146 +1,5 @@ -[ - { - "ownerApp": "string", - "createTime": 0, - "updateTime": 0, - "createdBy": "string", - "updatedBy": "string", - "accessPolicy": { - "additionalProp1": "string", - "additionalProp2": "string", - "additionalProp3": "string" - }, - "name": "string", - "description": "string", - "version": 0, - "tasks": [ - { - "name": "string", - "taskReferenceName": "string", - "description": "string", - "inputParameters": { - "additionalProp1": {}, - "additionalProp2": {}, - "additionalProp3": {} - }, - "type": "string", - "dynamicTaskNameParam": "string", - "scriptExpression": "string", - "decisionCases": { - "additionalProp1": [ - "string" - ], - "additionalProp2": [ - "string" - ], - "additionalProp3": [ - "string" - ] - }, - "dynamicForkTasksParam": "string", - "dynamicForkTasksInputParamName": "string", - "defaultCase": [ - "string" - ], - "forkTasks": [ - [ - "string" - ] - ], - "startDelay": 0, - "subWorkflowParam": { - "name": "string", - "version": 0, - "taskToDomain": { - "additionalProp1": "string", - "additionalProp2": "string", - "additionalProp3": "string" - }, - "workflowDefinition": "string" - }, - "joinOn": [ - "string" - ], - "sink": "string", - "optional": true, - "taskDefinition": { - "ownerApp": "string", - "createTime": 0, - "updateTime": 0, - "createdBy": "string", - "updatedBy": "string", - "accessPolicy": { - "additionalProp1": "string", - "additionalProp2": "string", - "additionalProp3": "string" - }, - "name": "string", - "description": "string", - "retryCount": 10, - "timeoutSeconds": 0, - "inputKeys": [ - "string" - ], - "outputKeys": [ - "string" - ], - "timeoutPolicy": "RETRY", - "retryLogic": "FIXED", - "retryDelaySeconds": 0, - "responseTimeoutSeconds": 1, - "concurrentExecLimit": 0, - "inputTemplate": { - "additionalProp1": {}, - "additionalProp2": {}, - "additionalProp3": {} - }, - "rateLimitPerFrequency": 0, - "rateLimitFrequencyInSeconds": 0, - "isolationGroupId": "string", - "executionNameSpace": "string", - "ownerEmail": "string", - "pollTimeoutSeconds": 0, - "backoffScaleFactor": 1 - }, - "rateLimited": true, - "defaultExclusiveJoinTask": [ - "string" - ], - "asyncComplete": true, - "loopCondition": "string", - "loopOver": [ - "string" - ], - "retryCount": 0, - "evaluatorType": "string", - "expression": "string", - "workflowTaskType": "SIMPLE" - } - ], - "inputParameters": [ - "string" - ], - "outputParameters": { - "additionalProp1": {}, - "additionalProp2": {}, - "additionalProp3": {} - }, - "failureWorkflow": "string", - "schemaVersion": 2, - "restartable": true, - "workflowStatusListenerEnabled": true, - "ownerEmail": "string", - "timeoutPolicy": "TIME_OUT_WF", - "timeoutSeconds": 0, - "variables": { - "additionalProp1": {}, - "additionalProp2": {}, - "additionalProp3": {} - }, - "inputTemplate": { - "additionalProp1": {}, - "additionalProp2": {}, - "additionalProp3": {} - } - } -] \ No newline at end of file + "http_request": { + "uri": "http://transfer.application.svc.cluster.local:8080/api/v1/transfer?fromAccount=${jq_get_fromAccountId.output.result}&toAccount=${jq_get_toAccountId.output.result}&amount=${workflow.input.amount}", + "method": "POST", + "body": "{ + }" \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json index 295b084fd..931a6d19c 100644 --- a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json +++ b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json @@ -76,10 +76,48 @@ "fromAccountList": "${call_account_service_from.output.response.body}", "queryExpression": ".fromAccountList[] | select (.accountType == \"${workflow.input.fromAccountType}\") | .accountId" } + }, + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_to", + "type": "HTTP", + "inputParameters": { + "toCustomerId": "${jq_get_toCustomerId.output.result}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${jq_get_toCustomerId.output.result}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_toAccountId", + "taskReferenceName": "jq_get_toAccountId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "toAccountList": "${call_account_service_to.output.response.body}", + "queryExpression": ".toAccountList[] | select (.accountType == \"${workflow.input.toAccountType}\") | .accountId" + } + }, + { + "name": "call_transfer_service", + "taskReferenceName": "call_transfer_service", + "type": "HTTP", + "inputParameters": { + "fromAccountId": "${jq_get_fromAccountId.output.result}", + "toAccountId": "${jq_get_toAccountId.output.result}", + "http_request": { + "uri": "http://transfer.application.svc.cluster.local:8080/transfer?fromAccount=${jq_get_fromAccountId.output.result}&toAccount=${jq_get_toAccountId.output.result}&amount=${workflow.input.amount}", + "method": "POST" + } + } } ], "outputParameters": { - "fromAccountId": "${jq_get_fromAccountId.output.result}" + "fromAccountId": "${jq_get_fromAccountId.output.result}", + "toAccountId": "${jq_get_toAccountId.output.result}", + "transferMessage": "${call_transfer_service.output.body}" }, "schemaVersion": 2, "restartable": true, From c7e11d3b50aa29874b1195b93632b4068bed069c Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Thu, 22 Jun 2023 01:38:21 -0300 Subject: [PATCH 3/6] Clean up project. Signed-off-by: Paulo Alberto Simoes --- cloudbank-v2/spring-apps/workflow/body.json | 5 - .../workflow/first_cbank_workflow copy.json | 97 ------------------- .../workflow/ip_weather_workflow.json | 64 ------------ 3 files changed, 166 deletions(-) delete mode 100644 cloudbank-v2/spring-apps/workflow/body.json delete mode 100644 cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json delete mode 100644 cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json diff --git a/cloudbank-v2/spring-apps/workflow/body.json b/cloudbank-v2/spring-apps/workflow/body.json deleted file mode 100644 index 115280843..000000000 --- a/cloudbank-v2/spring-apps/workflow/body.json +++ /dev/null @@ -1,5 +0,0 @@ - "http_request": { - "uri": "http://transfer.application.svc.cluster.local:8080/api/v1/transfer?fromAccount=${jq_get_fromAccountId.output.result}&toAccount=${jq_get_toAccountId.output.result}&amount=${workflow.input.amount}", - "method": "POST", - "body": "{ - }" \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json b/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json deleted file mode 100644 index 0b50b4eca..000000000 --- a/cloudbank-v2/spring-apps/workflow/first_cbank_workflow copy.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "name": "first_cbank_workflow", - "description": "First Cloud Bank Sample Workflow", - "version": 1, - "inputParameters": [ - "fromCustomerEmail", - "toCustomerEmail", - "amount" - ], - "tasks": [ - { - "name": "call_customer_service", - "taskReferenceName": "call_customer_service_from", - "type": "HTTP", - "inputParameters": { - "http_request": { - "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.fromCustomerEmail}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 - } - } - }, - { - "name": "call_customer_service", - "taskReferenceName": "call_customer_service_to", - "type": "HTTP", - "inputParameters": { - "http_request": { - "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.toCustomerEmail}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 - } - } - }, - { - "name": "call_account_service", - "taskReferenceName": "call_account_service_from", - "type": "HTTP", - "inputParameters": { - "fromCustomerId": "${call_customer_service_from.output.response.body.customerId}", - "http_request": { - "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${call_customer_service_from.output.response.body.customerId}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 - } - } - }, - { - "name": "call_account_service", - "taskReferenceName": "call_account_service_to", - "type": "HTTP", - "inputParameters": { - "toCustomerId": "${call_customer_service_to.output.response.body.customerId}", - "http_request": { - "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${call_customer_service_to.output.response.body.customerId}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 - } - } - }, - { - "name": "jq_cleanup", - "taskReferenceName": "jq_cleanup_ref", - "type": "JSON_JQ_TRANSFORM", - "inputParameters": { - "fromAccountList": "${call_account_service_from.output.response.body}", - "queryExpression": "[.starfromAccountList[]]" - } - }, - { - "name": "call_transfer_service", - "taskReferenceName": "call_transfer_service", - "type": "HTTP", - "inputParameters": { - "fromAccount": "1", - "toAccount": "2", - "http_request": { - "uri": "http://transfer.application.svc.cluster.local:8080/api/v1/transfer?fromAccount=22&toAccount=21&amount=${workflow.input.amount}", - "method": "POST" - } - } - } - ], - "outputParameters": { - "transferMessage": "${call_transfer_service.output.response.body}" - }, - "schemaVersion": 2, - "restartable": true, - "workflowStatusListenerEnabled": false, - "ownerEmail": "example@email.com", - "timeoutPolicy": "ALERT_ONLY", - "timeoutSeconds": 0 -} \ No newline at end of file diff --git a/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json b/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json deleted file mode 100644 index add3600c5..000000000 --- a/cloudbank-v2/spring-apps/workflow/ip_weather_workflow.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "ip_weather_workflow", - "description": "Sample Workflow", - "version": 1, - "inputParameters": [ - "my_ip" - ], - "tasks": [ - { - "name": "Get_IP", - "taskReferenceName": "get_IP_ref", - "inputParameters": { - "http_request": { - "uri": "http://ip-api.com/json/${workflow.input.ipaddress}?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,offset,isp,org,as,query", - "method": "GET" - } - }, - "type": "HTTP", - "decisionCases": {}, - "defaultCase": [], - "forkTasks": [], - "startDelay": 0, - "joinOn": [], - "optional": false, - "defaultExclusiveJoinTask": [], - "asyncComplete": false, - "loopOver": [], - "retryCount": 3 - }, - { - "name": "Get_weather", - "taskReferenceName": "get_weather_ref", - "inputParameters": { - "zip_code": "${get_IP_ref.output.response.body.zip}", - "http_request": { - "uri": "https://weatherdbi.herokuapp.com/data/weather/${get_IP_ref.output.response.body.zip}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 - } - }, - "type": "HTTP", - "decisionCases": {}, - "defaultCase": [], - "forkTasks": [], - "startDelay": 0, - "joinOn": [], - "optional": false, - "defaultExclusiveJoinTask": [], - "asyncComplete": false, - "loopOver": [] - } - ], - "outputParameters": { - "zipcode": "${get_IP_ref.output.response.body.zip}", - "forecast": "${get_weather_ref.output.response.body.currentConditions.comment}" - }, - "schemaVersion": 2, - "restartable": true, - "workflowStatusListenerEnabled": true, - "ownerEmail": "example@email.com", - "timeoutPolicy": "ALERT_ONLY", - "timeoutSeconds": 0 -} \ No newline at end of file From b192b1886e7c14e46f92c03d7761a5100443876b Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Thu, 20 Jul 2023 22:09:23 -0300 Subject: [PATCH 4/6] WIP new workflow for Demo Signed-off-by: Paulo Alberto Simoes --- .../workflow/cbank_workflow_demo.json | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json diff --git a/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json b/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json new file mode 100644 index 000000000..c36fdbcaf --- /dev/null +++ b/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json @@ -0,0 +1,42 @@ +{ + "name": "cbank_workflow_demo", + "description": "Cloud Bank Demo Workflow", + "version": 1, + "inputParameters": [ + "object" + ], + "tasks": [ + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_from", + "type": "HTTP", + "inputParameters": { + "fromCustomerId": "${jq_get_fromCustomerId.output.result}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${workflow.input.object.fromAccount}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_cloudCashPaymentObj", + "taskReferenceName": "jq_get_cloudCashPaymentObj", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "paymentObj": "${workflow.input.object}", + "queryExpression": ".paymentObj.amount" + } + } + ], + "outputParameters": { + "amount": "${jq_get_cloudCashPaymentObj.output.result}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": true, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 +} From adfdef50f10de667a83c2e09833dd48b407b0aea Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Wed, 2 Aug 2023 01:07:51 -0600 Subject: [PATCH 5/6] Add CloudBank Demo Workflow Signed-off-by: Paulo Alberto Simoes --- .../workflow/cbank_workflow_demo.json | 144 +++++++++++++----- 1 file changed, 104 insertions(+), 40 deletions(-) diff --git a/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json b/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json index c36fdbcaf..fb7b1906a 100644 --- a/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json +++ b/cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json @@ -1,42 +1,106 @@ -{ - "name": "cbank_workflow_demo", - "description": "Cloud Bank Demo Workflow", - "version": 1, - "inputParameters": [ - "object" - ], - "tasks": [ - { - "name": "call_account_service", - "taskReferenceName": "call_account_service_from", - "type": "HTTP", - "inputParameters": { - "fromCustomerId": "${jq_get_fromCustomerId.output.result}", - "http_request": { - "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${workflow.input.object.fromAccount}", - "method": "GET", - "connectionTimeOut": 3000, - "readTimeOut": 3000 +[ + { + "name": "cbank_workflow_demo", + "description": "Cloud Bank Demo Workflow", + "version": 1, + "inputParameters": [ + "object" + ], + "tasks": [ + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_from", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${workflow.input.object.fromAccount}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_fromAccountId", + "taskReferenceName": "jq_get_fromAccountId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_account_service_from.output.response.body}", + "queryExpression": ".fromAccountList[] | select (.accountType == \"SA\") | .accountId" + } + }, + { + "name": "call_customer_service", + "taskReferenceName": "call_customer_service_to", + "type": "HTTP", + "inputParameters": { + "http_request": { + "uri": "http://customer.application.svc.cluster.local:8080/api/v1/customer/byemail/${workflow.input.object.destination}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_toCustomerId", + "taskReferenceName": "jq_get_toCustomerId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "fromAccountList": "${call_customer_service_to.output.response.body}", + "queryExpression": ".fromAccountList[] | .customerId" + } + }, + { + "name": "call_account_service", + "taskReferenceName": "call_account_service_to", + "type": "HTTP", + "inputParameters": { + "toCustomerId": "${jq_get_toCustomerId.output.result}", + "http_request": { + "uri": "http://account.application.svc.cluster.local:8080/api/v1/account/getAccounts/${jq_get_toCustomerId.output.result}", + "method": "GET", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } + } + }, + { + "name": "jq_get_toAccountId", + "taskReferenceName": "jq_get_toAccountId", + "type": "JSON_JQ_TRANSFORM", + "inputParameters": { + "toAccountList": "${call_account_service_to.output.response.body}", + "queryExpression": ".toAccountList[] | select (.accountType == \"SA\") | .accountId" + } + }, + { + "name": "call_transfer_service", + "taskReferenceName": "call_transfer_service", + "type": "HTTP", + "inputParameters": { + "fromAccountId": "${jq_get_fromAccountId.output.result}", + "toAccountId": "${jq_get_toAccountId.output.result}", + "http_request": { + "uri": "http://transfer.application.svc.cluster.local:8080/transfer?fromAccount=${jq_get_fromAccountId.output.result}&toAccount=${jq_get_toAccountId.output.result}&amount=${workflow.input.object.amount}", + "method": "POST", + "connectionTimeOut": 3000, + "readTimeOut": 3000 + } } } - }, - { - "name": "jq_get_cloudCashPaymentObj", - "taskReferenceName": "jq_get_cloudCashPaymentObj", - "type": "JSON_JQ_TRANSFORM", - "inputParameters": { - "paymentObj": "${workflow.input.object}", - "queryExpression": ".paymentObj.amount" - } - } - ], - "outputParameters": { - "amount": "${jq_get_cloudCashPaymentObj.output.result}" - }, - "schemaVersion": 2, - "restartable": true, - "workflowStatusListenerEnabled": true, - "ownerEmail": "example@email.com", - "timeoutPolicy": "ALERT_ONLY", - "timeoutSeconds": 0 -} + ], + "outputParameters": { + "fromAccountId": "${jq_get_fromAccountId.output.result}", + "toAccountId": "${jq_get_toAccountId.output.result}", + "amount": "${jq_get_cloudCashPaymentObj.output.result}", + "transferMessage": "${call_transfer_service.output.body}" + }, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": false, + "ownerEmail": "example@email.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0 + } +] \ No newline at end of file From 7807b68503b02300a5e83e7862d2421908f243e6 Mon Sep 17 00:00:00 2001 From: Paulo Alberto Simoes Date: Wed, 2 Aug 2023 01:29:47 -0600 Subject: [PATCH 6/6] Add test description. Signed-off-by: Paulo Alberto Simoes --- cloudbank-v2/spring-apps/workflow/README.md | 74 +++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/cloudbank-v2/spring-apps/workflow/README.md b/cloudbank-v2/spring-apps/workflow/README.md index e69de29bb..36db2179f 100644 --- a/cloudbank-v2/spring-apps/workflow/README.md +++ b/cloudbank-v2/spring-apps/workflow/README.md @@ -0,0 +1,74 @@ +# Create CloudBank Demo Workflow for Conductor + +- cbank_workflow_demo: cloudbank demo workflow for integration with Parser +- first_cbank_workflow: cloudbank demo workflow +- first_sample_workflow: conductor sample workflow + +To get access to Conductor Server create a port-forward for Conductor Service. + +1- Adding the Workflow metadata + +```shell +curl --location --request PUT 'http://localhost:8080/api/metadata/workflow' \ +--header 'Content-Type: application/json' \ +--data-raw '' +``` + +2- Exec the workflow. + +```shell +curl --location 'http://localhost:8080/api/workflow/cbank_workflow_demo' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "triggerName": "afterSave", + "object": { + "amount": 800, + "destination": "andy@andy.com", + "fromAccount": "bkzLp8cozi", + "createdAt": "2023-06-20T15:48:41.730Z", + "updatedAt": "2023-06-20T15:48:41.730Z", + "objectId": "yH8iuP59Ct", + "className": "CloudCashPayment" + }, + "master": true, + "log": { + "options": { + "jsonLogs": false, + "logsFolder": "./logs", + "verbose": false + }, + "appId": "69uBOlaFBWds1KlMpcvSy5sPxsGNF0RXnkLqiO09" + }, + "headers": { + "host": "129.213.192.16", + "x-request-id": "8d5d8a49ea6f7f842499f41865278fa1", + "x-real-ip": "10.74.2.60", + "x-forwarded-for": "10.74.2.60", + "x-forwarded-host": "129.213.192.16", + "x-forwarded-port": "80", + "x-forwarded-proto": "http", + "x-forwarded-scheme": "http", + "x-scheme": "http", + "x-original-forwarded-for": "85.146.237.253", + "content-length": "342", + "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", + "content-type": "text/plain", + "accept": "*/*", + "origin": "http://obaas", + "referer": "http://obaas/", + "accept-encoding": "gzip, deflate", + "accept-language": "en,it;q=0.9" + }, + "ip": "10.74.2.60", + "context": {}, + "installationId": "b4bad867-de84-46ff-a531-b6c2e791ec83" +}' +``` + +The result should be the workflow instance ID : 1acc2a2f-8e38-49d7-b17d-e0a7b8e36d31 (for example) + +3- Check the workflow State using instance ID + +```shell +curl --location 'http://localhost:8080/api/workflow/1acc2a2f-8e38-49d7-b17d-e0a7b8e36d31?includeTasks=true' +```