Last active
April 17, 2018 12:23
-
-
Save jweisman/afb41a2d59afd7e99ff422d816dee33d to your computer and use it in GitHub Desktop.
Azure Logic App for Alma Webhooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$connections": { | |
"value": { | |
"sftp": { | |
"connectionId": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/resourceGroups/DefaultResourceGroup/providers/Microsoft.Web/connections/sftp-1", | |
"connectionName": "sftp-1", | |
"id": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/providers/Microsoft.Web/locations/eastus/managedApis/sftp" | |
} | |
} | |
}, | |
"definition": { | |
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", | |
"actions": { | |
"Is_Valid_Signature": { | |
"actions": { | |
"Is_Publishing_Job": { | |
"actions": { | |
"Create_file": { | |
"inputs": { | |
"body": "@join(outputs('Compose'),'\n')", | |
"host": { | |
"api": { | |
"runtimeUrl": "https://logic-apis-eastus.azure-apim.net/apim/sftp" | |
}, | |
"connection": { | |
"name": "@parameters('$connections')['sftp']['connectionId']" | |
} | |
}, | |
"method": "post", | |
"path": "/datasets/default/files", | |
"queries": { | |
"folderPath": "Public/TR_INTEGRATION_INST/pickup", | |
"name": "@{triggerBody()?['job_instance']?['id']}.txt" | |
} | |
}, | |
"runAfter": { | |
"For_each": [ | |
"Succeeded" | |
] | |
}, | |
"type": "ApiConnection" | |
}, | |
"Filter_files": { | |
"inputs": { | |
"from": "@body('List_files_in_folder')", | |
"where": "@contains(item()?['Name'], triggerBody()['job_instance']?['external_id'])" | |
}, | |
"runAfter": { | |
"List_files_in_folder": [ | |
"Succeeded" | |
] | |
}, | |
"type": "Query" | |
}, | |
"For_each": { | |
"actions": { | |
"Compose": { | |
"inputs": "@item()['Name']", | |
"runAfter": {}, | |
"type": "Compose" | |
} | |
}, | |
"foreach": "@body('Filter_files')", | |
"runAfter": { | |
"Filter_files": [ | |
"Succeeded" | |
] | |
}, | |
"type": "Foreach" | |
}, | |
"List_files_in_folder": { | |
"inputs": { | |
"host": { | |
"api": { | |
"runtimeUrl": "https://logic-apis-eastus.azure-apim.net/apim/sftp" | |
}, | |
"connection": { | |
"name": "@parameters('$connections')['sftp']['connectionId']" | |
} | |
}, | |
"method": "get", | |
"path": "/datasets/default/folders/@{encodeURIComponent(encodeURIComponent('Public/TR_INTEGRATION_INST/export'))}" | |
}, | |
"runAfter": {}, | |
"type": "ApiConnection" | |
} | |
}, | |
"expression": "@and(\n and(\n equals(triggerBody()?['action'], 'JOB_END'), \n equals(triggerBody()['job_instance']?['job_info']['category']['value'], 'PUBLISHING')\n ), \n equals(triggerBody()['job_instance']['status']['value'], 'COMPLETED_SUCCESS')\n)\n", | |
"runAfter": {}, | |
"type": "If" | |
}, | |
"Success_Response": { | |
"inputs": { | |
"body": "@triggerBody()['id']", | |
"statusCode": 200 | |
}, | |
"runAfter": { | |
"Is_Publishing_Job": [ | |
"Succeeded" | |
] | |
}, | |
"type": "Response" | |
} | |
}, | |
"else": { | |
"actions": { | |
"Unauthorized_Response": { | |
"inputs": { | |
"statusCode": 401 | |
}, | |
"runAfter": {}, | |
"type": "Response" | |
} | |
} | |
}, | |
"expression": "@equals(body('sign')['signature'], triggerOutputs()['headers']?['X-Exl-Signature'])", | |
"runAfter": { | |
"sign": [ | |
"Succeeded" | |
] | |
}, | |
"type": "If" | |
}, | |
"sign": { | |
"inputs": { | |
"body": { | |
"body": "@triggerBody()", | |
"secret": "hello" | |
}, | |
"function": { | |
"id": "/subscriptions/78e1da39-3d31-4b09-8636-f49b6fc5223b/resourceGroups/DefaultResourceGroup/providers/Microsoft.Web/sites/exl-utilities/functions/sign" | |
} | |
}, | |
"runAfter": {}, | |
"type": "Function" | |
} | |
}, | |
"contentVersion": "1.0.0.0", | |
"outputs": {}, | |
"parameters": { | |
"$connections": { | |
"defaultValue": {}, | |
"type": "Object" | |
} | |
}, | |
"triggers": { | |
"request": { | |
"inputs": { | |
"method": "POST", | |
"schema": { | |
"properties": { | |
"action": { | |
"type": "string" | |
}, | |
"id": { | |
"type": "string" | |
}, | |
"job_instance": { | |
"properties": { | |
"alert": { | |
"items": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"required": [ | |
"value", | |
"desc" | |
], | |
"type": "object" | |
}, | |
"type": "array" | |
}, | |
"counter": { | |
"items": { | |
"properties": { | |
"type": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"required": [ | |
"type", | |
"value" | |
], | |
"type": "object" | |
}, | |
"type": "array" | |
}, | |
"end_time": { | |
"type": "string" | |
}, | |
"id": { | |
"type": "string" | |
}, | |
"job_info": { | |
"properties": { | |
"category": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
}, | |
"description": { | |
"type": "string" | |
}, | |
"id": { | |
"type": "string" | |
}, | |
"link": { | |
"type": "string" | |
}, | |
"name": { | |
"type": "string" | |
}, | |
"type": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
} | |
}, | |
"type": "object" | |
}, | |
"link": { | |
"type": "string" | |
}, | |
"name": { | |
"type": "string" | |
}, | |
"progress": { | |
"type": "number" | |
}, | |
"start_time": { | |
"type": "string" | |
}, | |
"status": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
}, | |
"status_date": { | |
"type": "string" | |
}, | |
"submit_time": { | |
"type": "string" | |
}, | |
"submitted_by": { | |
"properties": { | |
"desc": { | |
"type": "string" | |
}, | |
"value": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
} | |
}, | |
"type": "object" | |
}, | |
"time": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
} | |
}, | |
"kind": "Http", | |
"type": "Request" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment