フローを使用した設計時の構成値のフェッチ
この手順では、フローを使用して設計時の構成値を取得する方法の概要を示します。
- Visual Studio Codeエディタでアダプタ定義ドキュメントを開きます。
- ドキュメントの
flowsコード・セクションで、必要なフローのコードを記述します。 たとえば、次のコード・サンプルには、compartmentIdFlow、applicationIdFlowおよびfunctionIdFlowフローが含まれています。ノート:
このコード・サンプルでは、フローは、別のフローの入力として機能する配列出力を返します。"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 } ] }, "applicationIdFlow": { "id": "applicationIdFlow", "description": "applicationIdFlow", "specVersion": "0.8", "version": "0.1", "start": "startState", "functions": [ { "name": "generalRestFunc", "type": "custom", "operation": "connectivity::rest" } ], "states":[ { "name":"startState", "type":"operation", "actions":[ { "functionRef": { "refName": "generalRestFunc", "arguments": { "uri": "${ \"https://functions.\" + .connectionProperties.region + \".oraclecloud.com/20181201/applications\" }", "method": "GET", "parameters": { "compartmentId": "${ .configuration.compartmentId }" } } }, "actionDataFilter": { "results": "${ .body | map({keyName:.id, displayName:.displayName}) }", "toStateData": "${ .output }" } } ], "end": true } ] }, "functionIdFlow": { "id": "functionIdFlow", "description": "functionIdFlow", "specVersion": "0.8", "version": "0.1", "start": "startState", "functions": [ { "name": "generalRestFunc", "type": "custom", "operation": "connectivity::rest" } ], "states":[ { "name":"startState", "type":"operation", "actions":[ { "functionRef": { "refName": "generalRestFunc", "arguments": { "uri": "${ \"https://functions.\" + .connectionProperties.region + \".oraclecloud.com/20181201/functions\" }", "method": "GET", "parameters": { "applicationId": "${ .configuration.applicationId }" } } }, "actionDataFilter": { "results": "${ .body | map({keyName:.id, displayName:.displayName}) }", "toStateData": "${ .output }" } } ], "end": true } ] } } - ドキュメントの
actionsコード・セクションで、設計時から構成値を取得するフローを使用してアクションを定義します。サンプル・コード:
{ "actions":{ "invokeFunctionAction": { "description": "Invoke Function", "summary": "Invoke Function.", "group": "function", "urn": "flow:invokeFunctionFlow", "input": { "userDefined": true }, "output": { "userDefined": true }, "configuration": [ { "name": "tenantId", "displayName": "Override Tenant OCID", "description": "", "type": "TEXT_BOX", "required": false }, { "name": "compartmentId", "displayName": "Compartment Name", "description": "", "type": "COMBO_BOX", "urn": "flow:compartmentIdFlow", "required": true }, { "name": "applicationId", "displayName": "Application Name", "description": "", "type": "COMBO_BOX", "urn": "flow:applicationIdFlow", "required": true, "dependencies": { "compartmentId": { "values": [] } } }, { "name": "functionId", "displayName": "Function Name", "description": "", "type": "COMBO_BOX", "urn": "flow:functionIdFlow", "required": true, "dependencies": { "applicationId": { "values": [] } } } ] } } }