将工作流信息发送到定制连接器

时间:2018-02-11 14:22:39

标签: azure-logic-apps openapi

我需要帮助在自定义连接器的调用的标头/正文中发送工作流信息。我正在尝试使用从API调用返回的值在逻辑应用程序的一个参数中加载下拉列表。 API端点需要基本的工作流信息,例如资源组和工作流名称,这些信息通常在逻辑应用程序执行的http请求标头中可用。

通常当我在逻辑应用程序的json中使用@{workflow().name}时,它会被工作流程名称替换。在自定义连接器的情况下,WDL语法按原样传递,不进行任何转换。

这是一个带有所有相关部分的简化的swagger json。

{
    "swagger": "2.0",
    "info": {
        "title": "{{dynamicHostName}}",
        "version": "1.0.0"
    },
    "host": "{{dynamicHostName}}",
    "basePath": "/",
    "schemes": [
        "https"
    ],
    "paths": {
        "/sftpsource": {
            "post": {
                "operationId": "SftpSource",
                "summary": "Sftp as source system",
                "description": "Use Sftp as source system",
                "produces": [
                    "application/json"
                ],
                "consumes": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "params",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "type": "object",
                            "properties": {
                                "hostName": {
                                    "type": "string",
                                    "x-ms-summary": "Host Name",
                                    "x-ms-visibility": "advanced"
                                },
                                "portNumber": {
                                    "type": "string",
                                    "x-ms-summary": "Port Number",
                                    "x-ms-visibility": "advanced"
                                },
                                "userName": {
                                    "type": "string",
                                    "x-ms-summary": "User Name",
                                    "x-ms-visibility": "advanced"
                                },
                                "password": {
                                    "type": "string",
                                    "x-ms-summary": "Password",
                                    "x-ms-visibility": "advanced"
                                },
                                "filePath": {
                                    "type": "string",
                                    "x-ms-summary": "File Path"
                                },
                                "system": {
                                    "type": "string",
                                    "x-ms-visibility": "advanced",
                                    "x-ms-summary": "System",
                                    "x-ms-dynamic-values": {
                                        "operationId": "GetTaggedSystems",
                                        "parameters": {
                                            "workflow-name": "@{workflow().name}"
                                        },
                                        "value-path": "systemId",
                                        "value-title": "systemName"
                                    }
                                }
                            }
                        }
                    }
                ],
                "responses": {
                    "202": {
                        "description": "Request is queued"
                    },
                    "500": {
                        "description": "Server Error"
                    }
                }
            }
        },
        "/taggedSystems" : {
            "get": {
                "operationId": "GetTaggedSystems",
                "summary": "Tagged Systems",
                "x-ms-visibility": "advanced",
                "description": "Get all systems tagged to this flow",
                "parameters": [
                    {
                        "name": "workflow-name",
                        "in": "header",
                        "required": true,
                        "type":  "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/TaggedSystems"
                        }
                    },
                    "202": {
                        "description": "Work is still in progress"
                    },
                    "500": {
                        "description": "An error occured while trying to fetch tagged systems."
                    }
                }
            }
        }
    },
    "definitions": {
        "TaggedSystems": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "systemId": {
                        "type": "string"
                    },
                    "systemName": {
                        "type": "string"
                    }
                },
                "required": [
                    "systemId",
                    "systemName"
                ]
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以将内部参数定义为header / body,在执行流时,您可以在其中传递工作流环境中所需内容的动态表达式。

有关流的完整信息,可以传递@{workflow()}作为内部参数。

希望有帮助。