Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
578e237
feat: WIP Add sns channel bindings
Apr 28, 2023
861ee6f
feat!: separate bindings and allow for custom bindings. (#107)
VisualBean May 3, 2023
222ad97
chore: add readme.md to bindings pack
VisualBean May 3, 2023
44354de
feat: WIP bring in line with new bindings wf
May 4, 2023
d856ccc
feat: WIP fix file overwrite
May 4, 2023
1fac669
feat: WIP further attempts at serde
May 4, 2023
0edd5c9
feat: WIP fix typo
May 4, 2023
e7bc0df
feat: WIP more node work
May 4, 2023
980bf81
feat: WIP switch to display enum
May 5, 2023
8221472
feat: WIP fixed lists
May 5, 2023
ab5550f
feat: WIP fix write issues
May 5, 2023
286e64d
feat: WIP remove commented function
May 5, 2023
b8aceea
feat: WIP Complete SNS body
May 5, 2023
d0f0ceb
feat: WIP finish SNS channel binding
May 5, 2023
41ea55d
feat: WIP Add basic SNS operation serialization
May 10, 2023
11755d5
refactor: binding improvement
VisualBean May 11, 2023
9c0f0c6
Merge branch 'main' into feat-add-sns-aws-bindings
May 11, 2023
33769c3
feat: WIP Add sns op fix fields
May 11, 2023
6a9266f
feat: WIP Add correct required properties
May 11, 2023
6bcf4e2
feat: WIP remove constants
May 11, 2023
b4d3a56
feat: WIP move to block scoped namespaces
May 11, 2023
0e1a445
ci: pull_request_target
VisualBean May 12, 2023
2690f4c
ci: add build and test run for forks (#110)
VisualBean May 12, 2023
a7c3305
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean May 12, 2023
b244161
ci: delete new workflow
VisualBean May 12, 2023
7f10a91
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean May 12, 2023
eedb2fa
fix: update AsyncApiTextReader class name (#109)
gokerakc May 12, 2023
e948e3d
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec May 12, 2023
21caee9
feat: fix identifier fixed fields bug
May 15, 2023
e120788
feat: correct type property to be required
May 16, 2023
783a1d2
feat: rename ordering to match spec
May 16, 2023
e01e26c
chore: add bindings to labeler
VisualBean May 18, 2023
30b87fb
test: add 'any' example
VisualBean May 18, 2023
7a28082
Merge remote-tracking branch 'origin/main' into main
VisualBean May 18, 2023
a09cdac
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec May 18, 2023
2277518
feat: add any filter policy handling
May 18, 2023
ce6d084
feat: correct policy effect casing
May 19, 2023
55f22bd
feat: use write any
May 19, 2023
b589e4f
feat!: separate bindings and allow for custom bindings. (#107)
VisualBean May 3, 2023
d242484
ci: force pre-releases
VisualBean Jun 5, 2023
2e4bf25
chore: update readme with pre-release shields
VisualBean Jun 5, 2023
79f11a8
sync changes
Jun 8, 2023
b4f8cb1
feat: sync with main
Jun 9, 2023
2c934e7
feat: update nested extensible objects and tests
Jun 9, 2023
4a2386a
Merge branch 'main' of github.com:dpwdec/AsyncAPI.NET into main
Jun 9, 2023
ea82b09
Merge branch 'main' into feat-add-sns-aws-bindings
VisualBean Jun 9, 2023
bbf391d
feat: merge main
Jun 9, 2023
6c4b0da
feat: integrate StringOrStringList to SNS
Jun 9, 2023
cd94f2c
feat: reformat files
Jun 9, 2023
8a7befe
feat: integrate remote changes
Jun 9, 2023
8f08e2b
feat: update consumer description wording
Jun 12, 2023
57e16d9
Merge branch 'main' into feat-add-sns-aws-bindings
dpwdec Jun 12, 2023
da4e8d6
feat: match wording to spec
Jun 12, 2023
c17f85b
Merge remote-tracking branch 'origin/feat-add-sns-aws-bindings' into …
Jun 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/LEGO.AsyncAPI.Bindings/BindingsCollection.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright (c) The LEGO Group. All rights reserved.

using LEGO.AsyncAPI.Bindings.Sqs;

namespace LEGO.AsyncAPI.Bindings
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Bindings.Http;
using LEGO.AsyncAPI.Bindings.Kafka;
using LEGO.AsyncAPI.Bindings.Pulsar;
using LEGO.AsyncAPI.Bindings.Sns;
using LEGO.AsyncAPI.Bindings.Sqs;
using LEGO.AsyncAPI.Bindings.WebSockets;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers.Interface;
Expand Down Expand Up @@ -43,6 +42,8 @@ public static TCollection Add<TCollection, TItem>(
Kafka,
Http,
Websockets,
Sqs,
Sns,
};

public static IEnumerable<IBindingParser<IBinding>> Http => new List<IBindingParser<IBinding>>
Expand Down Expand Up @@ -75,5 +76,11 @@ public static TCollection Add<TCollection, TItem>(
new SqsChannelBinding(),
new SqsOperationBinding(),
};

public static IEnumerable<IBindingParser<IBinding>> Sns => new List<IBindingParser<IBinding>>
{
new SnsChannelBinding(),
new SnsOperationBinding(),
};
}
}
80 changes: 80 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/Consumer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Attributes;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class Consumer : IAsyncApiExtensible
{
/// <summary>
/// The protocol that this endpoint will receive messages by.
/// </summary>
public Protocol Protocol { get; set; }

/// <summary>
/// The endpoint messages are delivered to.
/// </summary>
public Identifier Endpoint { get; set; }

/// <summary>
/// Only receive a subset of messages from the channel, determined by this policy.
/// </summary>
public FilterPolicy FilterPolicy { get; set; }

/// <summary>
/// If true AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If false the SNS attributes are included in the body.
/// </summary>
public bool RawMessageDelivery { get; set; }

/// <summary>
/// Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue.
/// </summary>
public RedrivePolicy RedrivePolicy { get; set; }

/// <summary>
/// Policy for retries to HTTP. The parameter is for that SNS Subscription and overrides any policy on the SNS Topic.
/// </summary>
public DeliveryPolicy DeliveryPolicy { get; set; }

/// <summary>
/// The display name to use with an SNS subscription.
/// </summary>
public string DisplayName { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteRequiredProperty("protocol", this.Protocol.GetDisplayName());
writer.WriteRequiredObject("endpoint", this.Endpoint, (w, e) => e.Serialize(w));
writer.WriteOptionalObject("filterPolicy", this.FilterPolicy, (w, f) => f.Serialize(w));
writer.WriteRequiredProperty("rawMessageDelivery", this.RawMessageDelivery);
writer.WriteOptionalObject("redrivePolicy", this.RedrivePolicy, (w, p) => p.Serialize(w));
writer.WriteOptionalObject("deliveryPolicy", this.DeliveryPolicy, (w, p) => p.Serialize(w));
writer.WriteOptionalProperty("displayName", this.DisplayName);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}

public enum Protocol
{
[Display("http")] Http,
[Display("https")] Https,
[Display("email")] Email,
[Display("email-json")] EmailJson,
[Display("sms")] Sms,
[Display("sqs")] Sqs,
[Display("application")] Application,
[Display("lambda")] Lambda,
[Display("firehose")] Firehose,
}
}
81 changes: 81 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/DeliveryPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Attributes;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class DeliveryPolicy : IAsyncApiExtensible
{
/// <summary>
/// The minimum delay for a retry in seconds.
/// </summary>
public int? MinDelayTarget { get; set; }

/// <summary>
/// The maximum delay for a retry in seconds.
/// </summary>
public int? MaxDelayTarget { get; set; }

/// <summary>
/// The total number of retries, including immediate, pre-backoff, backoff, and post-backoff retries.
/// </summary>
public int? NumRetries { get; set; }

/// <summary>
/// The number of immediate retries (with no delay).
/// </summary>
public int? NumNoDelayRetries { get; set; }

/// <summary>
/// The number of immediate retries (with delay).
/// </summary>
public int? NumMinDelayRetries { get; set; }

/// <summary>
/// The number of post-backoff phase retries, with the maximum delay between retries.
/// </summary>
public int? NumMaxDelayRetries { get; set; }

/// <summary>
/// The algorithm for backoff between retries.
/// </summary>
public BackoffFunction BackoffFunction { get; set; }

/// <summary>
/// The maximum number of deliveries per second, per subscription.
/// </summary>
public int? MaxReceivesPerSecond { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteOptionalProperty("minDelayTarget", this.MinDelayTarget);
writer.WriteOptionalProperty("maxDelayTarget", this.MaxDelayTarget);
writer.WriteOptionalProperty("numRetries", this.NumRetries);
writer.WriteOptionalProperty("numNoDelayRetries", this.NumNoDelayRetries);
writer.WriteOptionalProperty("numMinDelayRetries", this.NumMinDelayRetries);
writer.WriteOptionalProperty("numMaxDelayRetries", this.NumMaxDelayRetries);
writer.WriteOptionalProperty("backoffFunction", this.BackoffFunction.GetDisplayName());
writer.WriteOptionalProperty("maxReceivesPerSecond", this.MaxReceivesPerSecond);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}

public enum BackoffFunction
{
[Display("arithmetic")] Arithmetic,
[Display("exponential")] Exponential,
[Display("geometric")] Geometric,
[Display("linear")] Linear,
}
}
30 changes: 30 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/FilterPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class FilterPolicy : IAsyncApiExtensible
{
/// <summary>
/// A map of a message attribute to an array of possible matches. The match may be a simple string for an exact match, but it may also be an object that represents a constraint and values for that constraint.
/// </summary>
public IAsyncApiAny Attributes { get; set; }
Copy link
Copy Markdown
Contributor

@VisualBean VisualBean May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put a question in the sns binding PR to get clarification.

But if it's how it is, in the binding it should be Any type, of string, array or object. Which could be solved with a validation rule.

ReadAny exists but is probably still internal in the readers project.


public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteRequiredObject("attributes", this.Attributes, (w, a) => w.WriteAny(a));
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}
39 changes: 39 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/Identifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class Identifier : IAsyncApiExtensible
{
public string Url { get; set; }

public string Email { get; set; }

public string Phone { get; set; }

public string Arn { get; set; }

public string Name { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteOptionalProperty("url", this.Url);
writer.WriteOptionalProperty("email", this.Email);
writer.WriteOptionalProperty("phone", this.Phone);
writer.WriteOptionalProperty("arn", this.Arn);
writer.WriteOptionalProperty("name", this.Name);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}
45 changes: 45 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/Ordering.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Attributes;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class Ordering : IAsyncApiExtensible
{
/// <summary>
/// What type of SNS Topic is this?
/// </summary>
public OrderingType Type { get; set; }

/// <summary>
/// True to turn on de-duplication of messages for a channel.
/// </summary>
public bool ContentBasedDeduplication { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteRequiredProperty("type", this.Type.GetDisplayName());
writer.WriteOptionalProperty("contentBasedDeduplication", this.ContentBasedDeduplication);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}

public enum OrderingType
{
[Display("standard")]
Standard,
[Display("FIFO")]
Fifo,
}
}
31 changes: 31 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/Policy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class Policy : IAsyncApiExtensible
{
/// <summary>
/// An array of statement objects, each of which controls a permission for this topic.
/// </summary>
public List<Statement> Statements { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteOptionalCollection("statements", this.Statements, (w, t) => t.Serialize(w));
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}
36 changes: 36 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sns/RedrivePolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace LEGO.AsyncAPI.Bindings.Sns
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Writers;

public class RedrivePolicy : IAsyncApiExtensible
{
/// <summary>
/// Prevent poison pill messages by moving un-processable messages to an SQS dead letter queue.
/// </summary>
public Identifier DeadLetterQueue { get; set; }

/// <summary>
/// The number of times a message is delivered to the source queue before being moved to the dead-letter queue.
/// </summary>
public int? MaxReceiveCount { get; set; }

public IDictionary<string, IAsyncApiExtension> Extensions { get; set; } = new Dictionary<string, IAsyncApiExtension>();

public void Serialize(IAsyncApiWriter writer)
{
if (writer is null)
{
throw new ArgumentNullException(nameof(writer));
}

writer.WriteStartObject();
writer.WriteRequiredObject("deadLetterQueue", this.DeadLetterQueue, (w, q) => q.Serialize(w));
writer.WriteOptionalProperty("maxReceiveCount", this.MaxReceiveCount);
writer.WriteExtensions(this.Extensions);
writer.WriteEndObject();
}
}
}
Loading