Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CloudBank Demo Workflow #727

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions cloudbank-v2/spring-apps/workflow/README.md
Original file line number Diff line number Diff line change
@@ -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 '<cbank_workflow_demo.json content>'
```

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": "[email protected]",
"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'
```
106 changes: 106 additions & 0 deletions cloudbank-v2/spring-apps/workflow/cbank_workflow_demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +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": {
"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
}
}
}
],
"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": "[email protected]",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0
}
]
128 changes: 128 additions & 0 deletions cloudbank-v2/spring-apps/workflow/first_cbank_workflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"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"
}
},
{
"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}",
"toAccountId": "${jq_get_toAccountId.output.result}",
"transferMessage": "${call_transfer_service.output.body}"
},
"schemaVersion": 2,
"restartable": true,
"workflowStatusListenerEnabled": true,
"ownerEmail": "[email protected]",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0
}
31 changes: 31 additions & 0 deletions cloudbank-v2/spring-apps/workflow/first_sample_workflow.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0
}
]