66using System . Text . Json ;
77using Amazon . Lambda . Core ;
88using Amazon . Lambda . RuntimeSupport ;
9+ using Amazon . Lambda . S3Events ;
910using Amazon . Lambda . Serialization . SystemTextJson ;
1011using Amazon . Lambda . SQSEvents ;
1112using Amazon . S3 ;
@@ -106,19 +107,19 @@ static async Task<SQSBatchResponse> Handler(SQSEvent ev, ILambdaContext context)
106107 }
107108}
108109
109- static async Task < IReadOnlyCollection < ( S3EventRecord , LinkReference ) > > GetLinkReferences ( IAmazonS3 s3Client , SQSEvent . SQSMessage message , ILambdaContext context )
110+ static async Task < IReadOnlyCollection < ( S3Event . S3EventNotificationRecord , LinkReference ) > > GetLinkReferences ( IAmazonS3 s3Client , SQSEvent . SQSMessage message , ILambdaContext context )
110111{
111112 if ( string . IsNullOrEmpty ( message . Body ) )
112113 throw new Exception ( "No Body in SQS Message." ) ;
113114 context . Logger . LogDebug ( "Received message {messageBody}" , message . Body ) ;
114- var s3Event = JsonSerializer . Deserialize < S3EventNotification > ( message . Body , LinkIndexUpdaterSerializerContext . Default . S3EventNotification ) ;
115+ var s3Event = JsonSerializer . Deserialize < S3Event > ( message . Body , LinkIndexUpdaterSerializerContext . Default . S3Event ) ;
115116 if ( s3Event ? . Records == null || s3Event . Records . Count == 0 )
116117 throw new Exception ( "Invalid S3 event message format" ) ;
117- var linkReferences = new ConcurrentBag < ( S3EventRecord , LinkReference ) > ( ) ;
118+ var linkReferences = new ConcurrentBag < ( S3Event . S3EventNotificationRecord , LinkReference ) > ( ) ;
118119 await Parallel . ForEachAsync ( s3Event . Records , async ( record , ctx ) =>
119120 {
120121 var s3Bucket = record . S3 . Bucket ;
121- var s3Object = record . S3 . Obj ;
122+ var s3Object = record . S3 . Object ;
122123 context . Logger . LogInformation ( "Get object {key} from bucket {bucketName}" , s3Object . Key , s3Bucket . Name ) ;
123124 var getObjectResponse = await s3Client . GetObjectAsync ( s3Bucket . Name , s3Object . Key , ctx ) ;
124125 await using var stream = getObjectResponse . ResponseStream ;
@@ -130,9 +131,9 @@ await Parallel.ForEachAsync(s3Event.Records, async (record, ctx) =>
130131 return linkReferences ;
131132}
132133
133- static void UpdateLinkIndex ( LinkIndex linkIndex , LinkReference linkReference , S3EventRecord s3EventRecord , ILambdaContext context )
134+ static void UpdateLinkIndex ( LinkIndex linkIndex , LinkReference linkReference , S3Event . S3EventNotificationRecord s3EventRecord , ILambdaContext context )
134135{
135- var s3Object = s3EventRecord . S3 . Obj ;
136+ var s3Object = s3EventRecord . S3 . Object ;
136137 var keyTokens = s3Object . Key . Split ( '/' ) ;
137138 var repository = keyTokens [ 1 ] ;
138139 var branch = keyTokens [ 2 ] ;
0 commit comments