Skip to content

Added Support to Amazon.Lambda.Annotations For Sqs (SQSEvent.SQSMessage) #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
9c2be72
added sqs method and passing
hounddog22030 Jun 10, 2022
790cc89
atp
hounddog22030 Jun 11, 2022
3348e28
added logical id
hounddog22030 Jun 11, 2022
b102002
net6.0
hounddog22030 Jun 11, 2022
5b1bd69
Revert "net6.0"
hounddog22030 Jun 11, 2022
a565b84
just 6.0
hounddog22030 Jun 11, 2022
49b6682
back to netcore3.1
hounddog22030 Jun 11, 2022
224680f
VersionPrefix
hounddog22030 Jun 11, 2022
5975a4d
before deleting report.Queues
hounddog22030 Jun 11, 2022
2050f02
atp
hounddog22030 Jun 11, 2022
4813a50
atp
hounddog22030 Jun 11, 2022
da2e92f
ATP
hounddog22030 Jun 10, 2022
789931a
Merge branch 'feature/annotations-queue' of https://github.com/houndd…
hounddog22030 Jun 11, 2022
9a55418
Broke Queue Testing out into it's very own test and implemented remov…
hounddog22030 Jun 11, 2022
ff30a0c
#if DEBUG
hounddog22030 Jun 11, 2022
2ecaa93
remove launch
hounddog22030 Jun 11, 2022
6f7c945
renames
hounddog22030 Jun 11, 2022
45e90ed
more renames
hounddog22030 Jun 11, 2022
d6449c8
atp
hounddog22030 Jun 11, 2022
7fd40e7
atp
hounddog22030 Jun 11, 2022
ecd0252
atp
hounddog22030 Jun 12, 2022
57b85a1
Debugger.Launch();
hounddog22030 Jun 12, 2022
624a1eb
Revert "Debugger.Launch();"
hounddog22030 Jun 12, 2022
2c0391b
if (!Debugger.IsAttached)
hounddog22030 Jun 12, 2022
d183f58
take out
hounddog22030 Jun 12, 2022
e041f91
atp writing metadata
hounddog22030 Jun 12, 2022
735e8d6
removed the word Root from the event name
hounddog22030 Jun 12, 2022
1f0de6b
fixed again
hounddog22030 Jun 12, 2022
e30f921
stage
hounddog22030 Jun 12, 2022
a2353b8
atp
hounddog22030 Jun 12, 2022
51ead54
rename method
hounddog22030 Jun 12, 2022
93668df
atp
hounddog22030 Jun 12, 2022
eea55e1
added TestServerlessAppMessagingMessageHandlerForNewQueueGenerated
hounddog22030 Jun 12, 2022
b3bfc14
added Existing
hounddog22030 Jun 12, 2022
9225434
messaging passing
hounddog22030 Jun 12, 2022
d7431b3
atp
hounddog22030 Jun 12, 2022
797b296
atp
hounddog22030 Jun 12, 2022
b4b9ca4
Visibility Timeout
hounddog22030 Jun 12, 2022
04bb075
ContentBasedDeduplication
hounddog22030 Jun 12, 2022
6a18294
DeduplicationScope
hounddog22030 Jun 12, 2022
a1d7f7e
DeduplicationScope
hounddog22030 Jun 12, 2022
ec1a1a3
DelaySeconds
hounddog22030 Jun 13, 2022
98af25b
FifoQueue
hounddog22030 Jun 13, 2022
95cacaf
FifoThroughputLimit
hounddog22030 Jun 13, 2022
1636936
KmsDataKeyReusePeriodSeconds
hounddog22030 Jun 13, 2022
cec17d9
KmsMasterKeyId
hounddog22030 Jun 13, 2022
3b3478d
MaximumMessageSize
hounddog22030 Jun 13, 2022
2465d69
MessageRetentionPeriod
hounddog22030 Jun 13, 2022
9044f8d
ReceiveMessageWaitTimeSeconds
hounddog22030 Jun 13, 2022
e56db80
RedriveAllowPolicy
hounddog22030 Jun 13, 2022
058e213
RedrivePolicy
hounddog22030 Jun 13, 2022
8291b0f
Tags
hounddog22030 Jun 13, 2022
eed71f3
rename QueueName to EventQueueName
hounddog22030 Jun 13, 2022
bb7fcaa
Revert "rename QueueName to EventQueueName"
hounddog22030 Jun 13, 2022
62309bb
rename queuename to queue
hounddog22030 Jun 13, 2022
2dc933c
QueueName
hounddog22030 Jun 13, 2022
8c45abb
renamed queue suffix to just queue
hounddog22030 Jun 13, 2022
eb34dda
use queue or queuelogicalid to name the event
hounddog22030 Jun 13, 2022
777f177
WriteOrRemoveAsJson
hounddog22030 Jun 13, 2022
9a2641a
WriteOrRemoveAsJson
hounddog22030 Jun 12, 2022
9006464
Merge branch 'feature/annotations-queue' of https://github.com/houndd…
hounddog22030 Jun 13, 2022
c637fef
error trap and provide message about which item is the problem
hounddog22030 Jun 13, 2022
bccd8b2
throw new Exception($"Failed to create AWS::SQS::Queu…
hounddog22030 Jun 13, 2022
8c8f02a
throw new Exception($"Failed to create AWS::SQS::Queu…
hounddog22030 Jun 13, 2022
a283643
public string[] Tags { get; set; } = new string[] {};
hounddog22030 Jun 13, 2022
8a1c66b
remove bad syntax
hounddog22030 Jun 13, 2022
ab752a4
handle default and null and string.empty as the same
hounddog22030 Jun 13, 2022
0693bd9
cleanup refactor
hounddog22030 Jun 13, 2022
77ed788
atp
hounddog22030 Jun 13, 2022
33acdc3
move "VisibilityTimeout"
hounddog22030 Jun 13, 2022
e820b7f
more cleanup
hounddog22030 Jun 13, 2022
b11aae2
more cleanup
hounddog22030 Jun 13, 2022
3c1c9d8
Merge branch 'feature/annotations-queue' of https://github.com/houndd…
hounddog22030 Jun 13, 2022
5fb93a1
move comment to concrete for usability
hounddog22030 Jun 13, 2022
52ffac1
added xml documentation file
hounddog22030 Jun 13, 2022
ece6ffa
more documenation
hounddog22030 Jun 13, 2022
79e39c0
remove unnecessary comments from concrete passes thru from interface
hounddog22030 Jun 13, 2022
1680417
added some validation
hounddog22030 Jun 13, 2022
1dafe5b
fix test
hounddog22030 Jun 13, 2022
1e03d1a
renamed Queue to EventQueueARN
hounddog22030 Jun 13, 2022
7c0153d
renamed EventBatchSize
hounddog22030 Jun 13, 2022
b281942
DeduplicationScope
hounddog22030 Jun 13, 2022
165355c
DelaySecondsValidation
hounddog22030 Jun 13, 2022
f34d618
DeduplicationScope
hounddog22030 Jun 13, 2022
2e322bc
FifoThroughputLimit
hounddog22030 Jun 13, 2022
1ca98e4
KmsDataKeyReusePeriodSecondsValidation
hounddog22030 Jun 13, 2022
500d309
MaximumMessageSizeValidation
hounddog22030 Jun 13, 2022
a383d0d
MessageRetentionPeriodValidation
hounddog22030 Jun 13, 2022
e642ff5
check for .fifo if fifoqueue = true
hounddog22030 Jun 13, 2022
79ade49
EventBatchSizeValidation
hounddog22030 Jun 13, 2022
74b2f38
VisibilityTimeoutValidation
hounddog22030 Jun 13, 2022
75cfff4
ReceiveMessageWaitTimeSecondsValidation
hounddog22030 Jun 13, 2022
0252e1f
check redrivepolicyallow for valid json
hounddog22030 Jun 13, 2022
447eb7a
cleaned up always true uint comparesrefactored all int to uint
hounddog22030 Jun 13, 2022
f9c6f04
KmsDataKeyReusePeriodSecondsValidation using uint message
hounddog22030 Jun 13, 2022
ff36f9c
MaximumMessageSizeValidation updated to new scheme
hounddog22030 Jun 13, 2022
9afe8f9
DeduplicationScope new styles
hounddog22030 Jun 13, 2022
7cc7fc9
DeduplicationScope new styles
hounddog22030 Jun 13, 2022
280be89
Merge branch 'feature/annotations-queue' of https://github.com/houndd…
hounddog22030 Jun 13, 2022
8f30c37
clean up kruft
hounddog22030 Jun 13, 2022
00047e3
more cleanup
hounddog22030 Jun 13, 2022
e5228cc
clean up template
hounddog22030 Jun 13, 2022
6f89efd
renamed orphaned
hounddog22030 Jun 13, 2022
18f4be4
more formatting cleanup
hounddog22030 Jun 13, 2022
974744f
more formatting
hounddog22030 Jun 13, 2022
39fef9d
more formatting
hounddog22030 Jun 13, 2022
e2c14f4
just a formatting issue
hounddog22030 Jun 13, 2022
3e0f95a
FilterCriteria
hounddog22030 Jun 13, 2022
ad9603d
Fn::GetAtt for queue instead of ref
hounddog22030 Jun 13, 2022
619e8e9
writing BatchingWindowInSeconds
hounddog22030 Jun 14, 2022
3bf70e1
EventMaximumBatchingWindowInSeconds validation
hounddog22030 Jun 14, 2022
a348bce
update to 300
hounddog22030 Jun 14, 2022
fa1e34b
Fix example in readme.md to new parameter type
hounddog22030 Jun 14, 2022
2af02a8
updated readme file
hounddog22030 Jun 14, 2022
a7dcaa8
fix small tick problem
hounddog22030 Jun 14, 2022
9b0d600
Get Rid Of Requirement For Specifying QueueLogicalId
hounddog22030 Jun 14, 2022
c62dc5c
added new method to messaging in order to stage for queuename fnsub
hounddog22030 Jun 14, 2022
1ef0744
ATP with just embedded ${AWS::Stack}MyFifoQueueWithStackEmbedded.fifo…
hounddog22030 Jun 14, 2022
3371fd2
Added Ability To Make Fifo Queue Name use an Fn::Sub expression
hounddog22030 Jun 14, 2022
4732a8c
added MessageHandlerForNewFifoQueueWithoutAQueueName in order to test…
hounddog22030 Jun 14, 2022
15f9f83
Handle FifoQueue = true without ANY QueueName specified
hounddog22030 Jun 14, 2022
c12de06
Fix Fn::Sub
hounddog22030 Jun 15, 2022
f982fa7
Change the event name to simple
hounddog22030 Jun 15, 2022
45a5d10
got rid of fn::sub manually substition and turned queuename into jtok…
hounddog22030 Jun 15, 2022
51374b4
Merge branch 'master' into feature/annotations-queue
hounddog22030 Jun 17, 2022
a4a4e0e
Merge branch 'aws:master' into feature/annotations-queue
hounddog22030 Jun 20, 2022
1baec8e
REMOVE VERSION PREFIX - FOUND A BETTER WAY
hounddog22030 Jun 21, 2022
d305c16
netstandard2.0
hounddog22030 Jun 21, 2022
25d44ea
remove version prefix from project
hounddog22030 Jun 29, 2022
b470066
Merge branch 'aws:master' into feature/annotations-queue
hounddog22030 Jun 29, 2022
8a562e5
Merge branch 'aws:master' into feature/annotations-queue
hounddog22030 Jul 15, 2022
712d723
Create dotnet.yml
hounddog22030 Jul 25, 2022
f643525
Update dotnet.yml
hounddog22030 Jul 25, 2022
e9c3fec
Libraries\Libraries.sln
hounddog22030 Jul 25, 2022
ff5000e
Libraries\Libraries.sln
hounddog22030 Jul 25, 2022
8ae8509
/ instead of \
hounddog22030 Jul 25, 2022
c3fcf69
run: dotnet test Libraries/test/
hounddog22030 Jul 25, 2022
d81d49a
test only 6
hounddog22030 Jul 25, 2022
0a853c6
net6.0
hounddog22030 Jul 25, 2022
cfce620
--framework net6.0
hounddog22030 Jul 25, 2022
49a5493
name: Setup .NET 3.1
hounddog22030 Jul 25, 2022
055a091
no spec framework
hounddog22030 Jul 25, 2022
5571cee
BRANCH_NAME
hounddog22030 Jul 25, 2022
cdbefc3
Update dotnet.yml
hounddog22030 Jul 25, 2022
18ef851
Update dotnet.yml
hounddog22030 Jul 25, 2022
1a8f2fa
Merge branch 'master' into feature/annotations-queue
hounddog22030 Aug 4, 2022
1387d6c
Merge branch 'aws:master' into master
hounddog22030 Aug 4, 2022
bd41a3b
merge in master
hounddog22030 Aug 4, 2022
3563bfe
tick a file to trigger build
hounddog22030 Aug 4, 2022
90b099a
changes to messenging to handle new return type logic and update to 0…
hounddog22030 Aug 4, 2022
e00caff
feature/annotations-queue branch workflow
hounddog22030 Aug 4, 2022
9e3def2
dotnet 7
hounddog22030 Aug 4, 2022
6384cb5
fix version number syntax
hounddog22030 Aug 4, 2022
beb2ea3
bump version to 0.6
hounddog22030 Aug 4, 2022
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
45 changes: 45 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: .NET

on:
push:
branches: [ "master","feature/annotations-enchilada","feature/annotations-queue" ]
jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Get Branch Name
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Setup Version
run: echo "VERSION=0.6.${{ github.run_number }}-$BRANCH_NAME" >> $GITHUB_ENV
- name: Echo Branch Name
run: echo $BRANCH_NAME
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v1
with:
include-prerelease: true
dotnet-version: 7.0.100-preview.6.22352.1
- name: Restore dependencies
run: dotnet restore Libraries/Libraries.sln
- name: Build
run: dotnet build Libraries/Libraries.sln --no-restore
- name: Test
run: dotnet test Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Amazon.Lambda.Annotations.SourceGenerators.Tests.csproj

# - cd Libraries
# - dotnet build -c Release
# - dotnet test test/Amazon.Lambda.Annotations.SourceGenerators.Tests/Amazon.Lambda.Annotations.SourceGenerators.Tests.csproj --results-directory $CODEBUILD_SRC_DIR/TestResults --logger trx
# - VERSION="0.5.1-preview-$CODEBUILD_BUILD_NUMBER-$Branch"
# - dotnet pack -c Release src/Amazon.Lambda.Annotations/Amazon.Lambda.Annotations.csproj -p:NuspecFile=$CODEBUILD_SRC_DIR/Libraries/src/Amazon.Lambda.Annotations.nuspec -p:NuspecProperties="Version=0.5.1-preview-$CODEBUILD_BUILD_NUMBER-$Branch" -p:TargetFrameworks=netstandard2.0
# - dotnet pack -c Release src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj -p:NuspecProperties="Version=0.5.1-preview-$CODEBUILD_BUILD_NUMBER-$Branch" -p:TargetFrameworks=netstandard2.0

15 changes: 9 additions & 6 deletions Libraries/Libraries.sln
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestServerlessApp", "test\TestServerlessApp\TestServerlessApp.csproj", "{3D322CAB-0DDD-4C84-B3ED-0862F244AF5C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.Annotations.SourceGenerators.Tests", "test\Amazon.Lambda.Annotations.SourceGenerators.Tests\Amazon.Lambda.Annotations.SourceGenerators.Tests.csproj", "{D76F2C74-3D7F-4DB3-BA1A-F2EA14749253}"
ProjectSection(ProjectDependencies) = postProject
{3D322CAB-0DDD-4C84-B3ED-0862F244AF5C} = {3D322CAB-0DDD-4C84-B3ED-0862F244AF5C}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.Annotations", "src\Amazon.Lambda.Annotations\Amazon.Lambda.Annotations.csproj", "{ADA9AF37-A8C1-47E6-BBBD-5C7E49C26C0E}"
EndProject
Expand All @@ -126,14 +129,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestMinimalAPIApp", "test\T
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.MQEvents", "src\Amazon.Lambda.MQEvents\Amazon.Lambda.MQEvents.csproj", "{BF85932E-2DFF-41CD-8090-A672468B8FBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.LexV2Events", "src\Amazon.Lambda.LexV2Events\Amazon.Lambda.LexV2Events.csproj", "{3C6AABF5-0372-41E0-874F-DF18ECCC7FB6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.LexV2Events", "src\Amazon.Lambda.LexV2Events\Amazon.Lambda.LexV2Events.csproj", "{3C6AABF5-0372-41E0-874F-DF18ECCC7FB6}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\EventsTests.Shared\EventsTests.Shared.projitems*{44e9d925-b61d-4234-97b7-61424c963ba6}*SharedItemsImports = 5
test\EventsTests.Shared\EventsTests.Shared.projitems*{a2cb78bb-e54f-48ca-bbfb-9553d27ef23d}*SharedItemsImports = 13
test\EventsTests.Shared\EventsTests.Shared.projitems*{c1bb30d2-3237-4cfc-ba93-627471148ec2}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -412,4 +410,9 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {503678A4-B8D1-4486-8915-405A3E9CF0EB}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\EventsTests.Shared\EventsTests.Shared.projitems*{44e9d925-b61d-4234-97b7-61424c963ba6}*SharedItemsImports = 5
test\EventsTests.Shared\EventsTests.Shared.projitems*{a2cb78bb-e54f-48ca-bbfb-9553d27ef23d}*SharedItemsImports = 13
test\EventsTests.Shared\EventsTests.Shared.projitems*{c1bb30d2-3237-4cfc-ba93-627471148ec2}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public static AttributeModel Build(AttributeData att, GeneratorExecutionContext
Type = TypeModelBuilder.Build(att.AttributeClass, context)
};
}
else if (att.AttributeClass.Equals(context.Compilation.GetTypeByMetadataName(TypeFullNames.SqsMessageAttribute), SymbolEqualityComparer.Default))
{
var data = SqsMessageAttributeBuilder.Build(att);
model = new AttributeModel<SqsMessageAttribute>
{
Data = data,
Type = TypeModelBuilder.Build(att.AttributeClass, context)
};
}
else
{
model = new AttributeModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;

namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes
{
internal class SqsMessageAttributeBuilder
{
private const string RedriveAllPolicyNotValidJsonExceptionMessage = "RedriveAllPolicy must be valid Json";

public static SqsMessageAttribute Build(AttributeData att)
{
var data = new SqsMessageAttribute();
foreach (var attNamedArgument in att.NamedArguments)
{
switch (attNamedArgument.Key)
{
case nameof(ISqsMessage.EventQueueARN):
data.EventQueueARN = attNamedArgument.Value.Value.ToString();
break;
case nameof(ISqsMessage.EventBatchSize):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.EventBatchSize = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
case nameof(ISqsMessage.VisibilityTimeout):
data.VisibilityTimeout = uint.Parse(attNamedArgument.Value.Value.ToString());
break;
case nameof(ISqsMessage.ContentBasedDeduplication):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value.ToString()))
{
data.ContentBasedDeduplication = bool.Parse(attNamedArgument.Value.Value.ToString());
}
break;
case nameof(ISqsMessage.DeduplicationScope):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.DeduplicationScope = attNamedArgument.Value.Value.ToString();
}
break;
case nameof(ISqsMessage.DelaySeconds):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.DelaySeconds = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
case nameof(ISqsMessage.FifoQueue):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.FifoQueue = bool.Parse(attNamedArgument.Value.Value.ToString());
}
break;
case nameof(ISqsMessage.FifoThroughputLimit):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.FifoThroughputLimit = attNamedArgument.Value.Value.ToString();
}
break;
case nameof(ISqsMessage.KmsDataKeyReusePeriodSeconds):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.KmsDataKeyReusePeriodSeconds = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
case nameof(ISqsMessage.KmsMasterKeyId):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.KmsMasterKeyId = attNamedArgument.Value.Value.ToString();
}
break;
// MaximumMessageSize
case nameof(ISqsMessage.MaximumMessageSize):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.MaximumMessageSize = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
// Queue
case nameof(ISqsMessage.QueueName):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.QueueName = attNamedArgument.Value.Value.ToString();
}
break;
// MessageRetentionPeriod
case nameof(ISqsMessage.MessageRetentionPeriod):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.MessageRetentionPeriod = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
//ReceiveMessageWaitTimeSeconds
case nameof(ISqsMessage.ReceiveMessageWaitTimeSeconds):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.ReceiveMessageWaitTimeSeconds = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;
//RedriveAllowPolicy
case nameof(ISqsMessage.RedriveAllowPolicy):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
var json = attNamedArgument.Value.Value.ToString();
try
{
JObject.Parse(json);
}
catch (Exception e)
{

throw new ArgumentOutOfRangeException(nameof(ISqsMessage.RedriveAllowPolicy), SqsMessageAttributeBuilder.RedriveAllPolicyNotValidJsonExceptionMessage);
}
data.RedriveAllowPolicy = json;
}
break;
// RedrivePolicy
case nameof(ISqsMessage.RedrivePolicy):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.RedrivePolicy = attNamedArgument.Value.Value.ToString();
}
break;
// Tags
case nameof(ISqsMessage.Tags):
if (attNamedArgument.Value.Values.Any())
{
var final = new List<string>();

foreach (var pair in attNamedArgument.Value.Values)
{
final.Add(pair.Value.ToString());
}

data.Tags = final.ToArray();
}
break;
case nameof(ISqsMessage.EventFilterCriteria):
if (attNamedArgument.Value.Values.Any())
{
var final = new List<string>();

foreach (var pair in attNamedArgument.Value.Values)
{
final.Add(pair.Value.ToString());
}

data.EventFilterCriteria = final.ToArray();
}
break;
/// MaximumBatchingWindowInSeconds
case nameof(ISqsMessage.EventMaximumBatchingWindowInSeconds):
if (!string.IsNullOrEmpty(attNamedArgument.Value.Value?.ToString()))
{
data.EventMaximumBatchingWindowInSeconds = uint.Parse(attNamedArgument.Value.Value.ToString());
}
break;


default:
throw new NotSupportedException(attNamedArgument.Key);
}
}

//if (data.FifoQueue && !string.IsNullOrEmpty(data.QueueName) && !data.QueueName.EndsWith(".fifo"))
//{
// throw new ArgumentOutOfRangeException(nameof(SqsMessageAttribute.QueueName), $"If using {nameof(SqsMessageAttribute.FifoQueue)} = true, {nameof(SqsMessageAttribute.QueueName)} must end in '.fifo'");
//}

return data;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Amazon.Lambda.Annotations.SourceGenerator.Models
{
public interface ISqsMessageSerializable : ISqsMessage
{
string SourceGeneratorVersion { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Linq;

namespace Amazon.Lambda.Annotations.SourceGenerator.Models
{
public interface ISqsQueueSerializable
{
string QueueLogicalId { get; set; }
JToken QueueName { get; set; }
uint EventBatchSize { get; set; }
string[] EventFilterCriteria { get; set; }
string EventQueueARN { get; set; }
bool ContentBasedDeduplication { get; set; }
uint EventMaximumBatchingWindowInSeconds { get; set; }
string DeduplicationScope { get; set; }
uint DelaySeconds { get; set; }
bool FifoQueue { get; set; }
string FifoThroughputLimit { get; set; }
uint KmsDataKeyReusePeriodSeconds { get; set; }
string KmsMasterKeyId { get; set; }
uint MaximumMessageSize { get; set; }
uint MessageRetentionPeriod { get; set; }
uint ReceiveMessageWaitTimeSeconds { get; set; }
string RedriveAllowPolicy { get; set; }
string RedrivePolicy { get; set; }
string[] Tags { get; set; }
uint VisibilityTimeout { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Newtonsoft.Json.Linq;

namespace Amazon.Lambda.Annotations.SourceGenerator.Models
{
public class SqsQueueModel : ISqsQueueSerializable
{
public string QueueLogicalId { get; set; }
public JToken QueueName { get; set; }
public uint EventBatchSize { get; set; }
public string[] EventFilterCriteria { get; set; }
public string EventQueueARN { get; set; }
public bool ContentBasedDeduplication { get; set; }
public uint EventMaximumBatchingWindowInSeconds { get; set; }
public string DeduplicationScope { get; set; }
public uint DelaySeconds { get; set; }
public bool FifoQueue { get; set; }
public string FifoThroughputLimit { get; set; }
public uint KmsDataKeyReusePeriodSeconds { get; set; }
public string KmsMasterKeyId { get; set; }
public uint MaximumMessageSize { get; set; }
public uint MessageRetentionPeriod { get; set; }
public uint ReceiveMessageWaitTimeSeconds { get; set; }
public string RedriveAllowPolicy { get; set; }
public string RedrivePolicy { get; set; }
public string[] Tags { get; set; }
public uint VisibilityTimeout { get; set; }
}
}
Loading