Skip to content

Commit 547d9cc

Browse files
author
Espen Gulbrandsen
committed
Add changes based on feedback
1 parent 4adaf61 commit 547d9cc

File tree

7 files changed

+50
-61
lines changed

7 files changed

+50
-61
lines changed

src/Events.Functions/Clients/EventsClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public async Task LogWebhookHttpStatusCode(CloudEventEnvelope cloudEventEnvelope
147147
StatusCode = statusCode,
148148
};
149149

150-
StringContent httpContent = new(JsonSerializer.Serialize(logEntryData), Encoding.UTF8, "application/cloudevents+json");
150+
StringContent httpContent = new(JsonSerializer.Serialize(logEntryData), Encoding.UTF8, "application/json");
151151
var accessToken = await GenerateAccessToken();
152152

153153
await _client.PostAsync(endpoint, httpContent, accessToken);
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
namespace Altinn.Platform.Events.Functions.Constants
1+
namespace Altinn.Platform.Events.Functions.Constants;
2+
3+
/// <summary>
4+
/// Shared constants for Events.Functions project
5+
/// </summary>
6+
public static class EventConstants
27
{
38
/// <summary>
4-
/// Shared constants for Events.Functions project
9+
/// The cloud event type for subscription validation
510
/// </summary>
6-
public static class EventConstants
7-
{
8-
/// <summary>
9-
/// The cloud event type for subscription validation
10-
/// </summary>
11-
public static string ValidationType => "platform.events.validatesubscription";
12-
}
11+
public const string ValidationType = "platform.events.validatesubscription";
1312
}

src/Events.Functions/EventsOutbound.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Threading.Tasks;
22

3-
using Altinn.Platform.Events.Functions.Clients.Interfaces;
43
using Altinn.Platform.Events.Functions.Models;
54
using Altinn.Platform.Events.Functions.Services.Interfaces;
65

src/Events.Functions/Models/LogEntryDto.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using System;
22
using System.Net;
33

4-
using Altinn.Platform.Events.Models;
5-
6-
using CloudNative.CloudEvents;
7-
84
namespace Altinn.Platform.Events.Functions.Models
95
{
106
/// <summary>
@@ -13,32 +9,32 @@ namespace Altinn.Platform.Events.Functions.Models
139
public record LogEntryDto
1410
{
1511
/// <summary>
16-
/// The cloud event id associated with the logged event <see cref="CloudEvent"/>"/>
12+
/// The cloud event id associated with the logged event
1713
/// </summary>
1814
public string CloudEventId { get; set; }
1915

2016
/// <summary>
21-
/// The resource associated with the cloud event <see cref="CloudEvent"/>
17+
/// The resource associated with the cloud event
2218
/// </summary>
2319
public string CloudEventResource { get; set; }
2420

2521
/// <summary>
26-
/// The type associated with the logged event <see cref="CloudEvent"/>
22+
/// The type associated with the logged event
2723
/// </summary>
2824
public string CloudEventType { get; set; }
2925

3026
/// <summary>
31-
/// The subscription id associated with the post action. <see cref="Subscription"/>"/>
27+
/// The subscription id associated with the post action.
3228
/// </summary>
3329
public int SubscriptionId { get; set; }
3430

3531
/// <summary>
36-
/// The consumer of the event <see cref="Subscription"/>
32+
/// The consumer of the event
3733
/// </summary>
3834
public string Consumer { get; set; }
3935

4036
/// <summary>
41-
/// The consumers webhook endpoint <see cref="Subscription"/>
37+
/// The consumers webhook endpoint
4238
/// </summary>
4339
public Uri Endpoint { get; set; }
4440

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
using System.Net.Http;
21
using System.Threading.Tasks;
32

43
using Altinn.Platform.Events.Functions.Models;
54

6-
namespace Altinn.Platform.Events.Functions.Services.Interfaces
5+
namespace Altinn.Platform.Events.Functions.Services.Interfaces;
6+
7+
/// <summary>
8+
/// Interface to send content to webhooks
9+
/// </summary>
10+
public interface IWebhookService
711
{
812
/// <summary>
9-
/// Interface to send content to webhooks
13+
/// Send cloudevent to webhook
1014
/// </summary>
11-
public interface IWebhookService
12-
{
13-
/// <summary>
14-
/// Send cloudevent to webhook
15-
/// </summary>
16-
/// <param name="envelope">CloudEventEnvelope, includes content and uri</param>
17-
Task Send(CloudEventEnvelope envelope);
18-
}
15+
/// <param name="envelope">CloudEventEnvelope, includes content and uri</param>
16+
Task Send(CloudEventEnvelope envelope);
1917
}

src/Events.Functions/Services/WebhookService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task Send(CloudEventEnvelope envelope)
4343
{
4444
HttpResponseMessage response = await _client.PostAsync(envelope.Endpoint, httpContent);
4545

46-
// log response from webhook to storage
46+
// log response from webhook to Events
4747
await _eventsClient.LogWebhookHttpStatusCode(envelope, response.StatusCode);
4848

4949
if (!response.IsSuccessStatusCode)
Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
using System;
2-
using System.Net;
3-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
42

53
using Altinn.Platform.Events.Models;
64

75
using CloudNative.CloudEvents;
86

9-
namespace Altinn.Platform.Events.Services.Interfaces
7+
namespace Altinn.Platform.Events.Services.Interfaces;
8+
9+
/// <summary>
10+
/// Interface for trace log service.
11+
/// </summary>
12+
public interface ITraceLogService
1013
{
1114
/// <summary>
12-
/// Interface for trace log service.
15+
/// Creates a trace log entry based on registration of a new event
1316
/// </summary>
14-
public interface ITraceLogService
15-
{
16-
/// <summary>
17-
/// Creates a trace log entry based on registration of a new event
18-
/// </summary>
19-
/// <param name="cloudEvent">CloudNative CloudEvent <see cref="CloudEvent"/></param>
20-
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation: Cloud event id.</returns>
21-
Task<string> CreateRegisteredEntry(CloudEvent cloudEvent);
17+
/// <param name="cloudEvent">CloudNative CloudEvent <see cref="CloudEvent"/></param>
18+
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation: Cloud event id.</returns>
19+
Task<string> CreateRegisteredEntry(CloudEvent cloudEvent);
2220

23-
/// <summary>
24-
/// Log response from webhook post to subscriber.
25-
/// </summary>
26-
/// <param name="logEntryDto">Data transfer object associated with cloud event, status code, and subscription</param>
27-
/// <returns>A string representation of the GUID or an empty string</returns>
28-
Task<string> CreateWebhookResponseEntry(LogEntryDto logEntryDto);
21+
/// <summary>
22+
/// Log response from webhook post to subscriber.
23+
/// </summary>
24+
/// <param name="logEntryDto">Data transfer object associated with cloud event, status code, and subscription</param>
25+
/// <returns>A string representation of the GUID or an empty string</returns>
26+
Task<string> CreateWebhookResponseEntry(LogEntryDto logEntryDto);
2927

30-
/// <summary>
31-
/// Creates a trace log entry with information about cloud event and subscription
32-
/// </summary>
33-
/// <param name="cloudEvent">Cloud Event associated with log entry <see cref="CloudEvent"/></param>
34-
/// <param name="subscription">Subscription associated with log entry <see cref="Subscription"/></param>
35-
/// <param name="activity">Type of activity associated with log entry <see cref="TraceLogActivity"/></param>
36-
/// <returns>Returns empty string if a log entry can't be created</returns>
37-
Task<string> CreateLogEntryWithSubscriptionDetails(CloudEvent cloudEvent, Subscription subscription, TraceLogActivity activity);
38-
}
28+
/// <summary>
29+
/// Creates a trace log entry with information about cloud event and subscription
30+
/// </summary>
31+
/// <param name="cloudEvent">Cloud Event associated with log entry <see cref="CloudEvent"/></param>
32+
/// <param name="subscription">Subscription associated with log entry <see cref="Subscription"/></param>
33+
/// <param name="activity">Type of activity associated with log entry <see cref="TraceLogActivity"/></param>
34+
/// <returns>Returns empty string if a log entry can't be created</returns>
35+
Task<string> CreateLogEntryWithSubscriptionDetails(CloudEvent cloudEvent, Subscription subscription, TraceLogActivity activity);
3936
}

0 commit comments

Comments
 (0)