-
Notifications
You must be signed in to change notification settings - Fork 13
/
HttpGetStatusForMany.cs
47 lines (43 loc) · 1.91 KB
/
HttpGetStatusForMany.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
// ReSharper disable once CheckNamespace
namespace DurableFunctions.Demo.DotNetCore.Status
{
public class HttpGetStatusForMany
{
/// <summary>
/// This function retrives the status for several Orchestrators in the same Function App.
/// </summary>
/// <param name="req">The HttpRequestMessage which contains the GetStatusRequest data.</param>
/// <param name="OrchestratorClient">An instance of the DurableOrchestrationClient used to start a new Orchestrator.</param>
/// <param name="log">ILogger implementation.</param>
/// <returns>A collection of DurableOrchestrationStatus messages.</returns>
[FunctionName(nameof(HttpGetStatusForMany))]
public async Task<IList<DurableOrchestrationStatus>> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "status")]HttpRequestMessage req,
[DurableClient]IDurableClient OrchestratorClient,
ILogger log)
{
var getStatusRequest = await req.Content.ReadAsAsync<GetStatusRequest>();
IList<DurableOrchestrationStatus> results = new List<DurableOrchestrationStatus>();
if (getStatusRequest.CreatedFrom.HasValue && getStatusRequest.StatussesToMatch.Any())
{
results = await OrchestratorClient.GetStatusAsync(
getStatusRequest.CreatedFrom.Value,
getStatusRequest.CreatedTo,
getStatusRequest.StatussesToMatch);
}
else
{
results = await OrchestratorClient.GetStatusAsync();
}
return results;
}
}
}