66using System . Text . Json ;
77using Amazon . Lambda . Core ;
88using Amazon . Lambda . RuntimeSupport ;
9- using Amazon . Lambda . S3Events ;
109using Amazon . Lambda . Serialization . SystemTextJson ;
1110using Amazon . Lambda . SQSEvents ;
1211using Amazon . S3 ;
1312using Amazon . S3 . Model ;
13+ using Amazon . S3 . Util ;
1414using Elastic . Documentation . Lambda . LinkIndexUploader ;
1515using Elastic . Markdown . IO . State ;
1616using Elastic . Markdown . Links . CrossLinks ;
@@ -107,18 +107,17 @@ static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
107107 }
108108}
109109
110- static async Task < IReadOnlyCollection < ( S3Event . S3EventNotificationRecord , LinkReference ) > > GetLinkReferences ( IAmazonS3 s3Client , SQSEvent . SQSMessage message , ILambdaContext context )
110+ static async Task < IReadOnlyCollection < ( S3EventNotification . S3EventNotificationRecord , LinkReference ) > > GetLinkReferences ( IAmazonS3 s3Client , SQSEvent . SQSMessage message , ILambdaContext context )
111111{
112112 if ( string . IsNullOrEmpty ( message . Body ) )
113113 throw new Exception ( "No Body in SQS Message." ) ;
114114 context . Logger . LogDebug ( "Received message {messageBody}" , message . Body ) ;
115- var s3Event = JsonSerializer . Deserialize < S3Event > ( message . Body , LinkIndexUpdaterSerializerContext . Default . S3Event ) ;
115+ var s3Event = S3EventNotification . ParseJson ( message . Body ) ;
116116 if ( s3Event ? . Records == null || s3Event . Records . Count == 0 )
117117 throw new Exception ( "Invalid S3 event message format" ) ;
118- var linkReferences = new ConcurrentBag < ( S3Event . S3EventNotificationRecord , LinkReference ) > ( ) ;
118+ var linkReferences = new ConcurrentBag < ( S3EventNotification . S3EventNotificationRecord , LinkReference ) > ( ) ;
119119 await Parallel . ForEachAsync ( s3Event . Records , async ( record , ctx ) =>
120120 {
121- context . Logger . LogInformation ( JsonSerializer . Serialize ( record , LinkIndexUpdaterSerializerContext . Default . S3Event ) ) ;
122121 var s3Bucket = record . S3 . Bucket ;
123122 var s3Object = record . S3 . Object ;
124123 context . Logger . LogInformation ( "Get object {key} from bucket {bucketName}" , s3Object . Key , s3Bucket . Name ) ;
@@ -132,7 +131,7 @@ await Parallel.ForEachAsync(s3Event.Records, async (record, ctx) =>
132131 return linkReferences ;
133132}
134133
135- static void UpdateLinkIndex ( LinkIndex linkIndex , LinkReference linkReference , S3Event . S3EventNotificationRecord s3EventRecord , ILambdaContext context )
134+ static void UpdateLinkIndex ( LinkIndex linkIndex , LinkReference linkReference , S3EventNotification . S3EventNotificationRecord s3EventRecord , ILambdaContext context )
136135{
137136 var s3Object = s3EventRecord . S3 . Object ;
138137 var keyTokens = s3Object . Key . Split ( '/' ) ;
0 commit comments