前処理式および後処理式と複数のアウトバウンド・リクエスト
この手順では、前処理式または後処理式および複数のアウトバウンド・リクエストを含むフローを実装する方法を示します。
サンプル・コードは、次の方法を示しています:
- タスクを前処理し、テナント情報を構築します。
- 複数のアウトバウンド・リクエストを作成します。
- 最終リクエストを行うために出力を前処理します。
- 2つのリクエストの出力を後処理操作としてマージします。
完全なサンプル・コード:
"flows": {
"compartmentIdFlow" : {
"id": "compartmentIdFlow",
"description": "compartmentIdFlow",
"specVersion": "0.8",
"version": "0.1",
"start": "startState",
"functions": [
{
"name": "generalRestFunc",
"type": "custom",
"operation": "connectivity::rest"
},
{
"name": "getTenantId",
"type": "expression",
"operation": "if .configuration.tenantId then .configuration.tenantId else .connectionProperties.TenancyOCID end"
},
{
"name": "mergeTenantsList",
"type": "expression",
"operation": "[.rootCompartment] + .childCompartments"
}
],
"states":[
{
"name":"startState",
"type":"operation",
"actions":[
{
"functionRef": "getTenantId",
"actionDataFilter": {
"toStateData": "${ .configuration.tenantId }"
}
},
{
"functionRef": {
"refName": "generalRestFunc",
"arguments": {
"uri": "${ \"https://identity.\" + .connectionProperties.region + \".oraclecloud.com/20160918/compartments/\" + .configuration.tenantId }",
"method": "GET"
}
},
"actionDataFilter": {
"results": "${ {keyName:.body.id, displayName:.body.name} }",
"toStateData": "${ .rootCompartment }"
}
},
{
"functionRef": {
"refName": "generalRestFunc",
"arguments": {
"uri": "${ \"https://identity.\" + .connectionProperties.region + \".oraclecloud.com/20160918/compartments\" }",
"method": "GET",
"parameters": {
"compartmentId": "${ .configuration.tenantId }",
"lifecycleState": "ACTIVE",
"compartmentIdInSubtree": true
}
}
},
"actionDataFilter": {
"results": "${ .body | map({keyName:.id, displayName:.name}) }",
"toStateData": "${ .childCompartments }"
}
},
{
"functionRef": "mergeTenantsList",
"actionDataFilter": {
"toStateData": "${ .output }"
}
}
],
"end": true
}
]
}
}