-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphNotificationModels.cs
More file actions
109 lines (89 loc) · 3.67 KB
/
GraphNotificationModels.cs
File metadata and controls
109 lines (89 loc) · 3.67 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* By David Barrett, Microsoft Ltd. Use at your own risk. No warranties are given.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* */
using System.Text.Json;
using System.Text.Json.Serialization;
using Azure;
using Azure.Data.Tables;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
namespace GraphNotificationsAzureFunction;
internal sealed class GraphNotificationEnvelope
{
[JsonPropertyName("value")]
public GraphNotification[]? Value { get; set; }
}
public sealed class GraphNotification
{
[JsonPropertyName("id")]
public string? Id { get; set; }
[JsonPropertyName("subscriptionId")]
public string? SubscriptionId { get; set; }
[JsonPropertyName("subscriptionExpirationDateTime")]
public DateTimeOffset? SubscriptionExpirationDateTime { get; set; }
[JsonPropertyName("clientState")]
public string? ClientState { get; set; }
[JsonPropertyName("changeType")]
public string? ChangeType { get; set; }
[JsonPropertyName("resource")]
public string? Resource { get; set; }
[JsonPropertyName("lifecycleEvent")]
public string? LifecycleEvent { get; set; }
[JsonPropertyName("tenantId")]
public string? TenantId { get; set; }
[JsonPropertyName("resourceData")]
public JsonElement ResourceData { get; set; }
}
/// <summary>Queue message envelope written by the HTTP webhook and read by the queue processor.</summary>
public sealed class NotificationQueueMessage
{
[JsonPropertyName("notification")]
public GraphNotification Notification { get; init; } = default!;
[JsonPropertyName("category")]
public string Category { get; init; } = default!;
}
/// <summary>Multi-output return type for the change-notification HTTP trigger.</summary>
public sealed class ChangeNotificationWebhookOutput
{
[HttpResult]
public IActionResult HttpResponse { get; init; } = default!;
[QueueOutput("graph-change-notifications")]
public IEnumerable<string>? QueueMessages { get; init; }
/// <summary>
/// Lifecycle events that arrived on the change-notification endpoint due to a misconfigured
/// LifecycleNotificationUrl are re-routed here so they still reach the correct processor.
/// </summary>
[QueueOutput("graph-lifecycle-notifications")]
public IEnumerable<string>? LifecycleQueueMessages { get; init; }
}
/// <summary>Multi-output return type for the lifecycle-notification HTTP trigger.</summary>
public sealed class LifecycleNotificationWebhookOutput
{
[HttpResult]
public IActionResult HttpResponse { get; init; } = default!;
[QueueOutput("graph-lifecycle-notifications")]
public IEnumerable<string>? QueueMessages { get; init; }
}
public sealed class NotificationEntity : ITableEntity
{
public string PartitionKey { get; set; } = default!;
public string RowKey { get; set; } = default!;
public DateTimeOffset? Timestamp { get; set; }
public ETag ETag { get; set; }
public string? Category { get; set; }
public string? ChangeType { get; set; }
public string? LifecycleEvent { get; set; }
public string? Resource { get; set; }
public DateTimeOffset? SubscriptionExpirationDateTime { get; set; }
public DateTimeOffset ReceivedUtc { get; set; }
public string? ResourceDataJson { get; set; }
}