1
+ package com .amazonaws .services .lambda .runtime .events ;
2
+
3
+ import lombok .AllArgsConstructor ;
4
+ import lombok .Builder ;
5
+ import lombok .Data ;
6
+ import lombok .NoArgsConstructor ;
7
+
8
+ import java .util .List ;
9
+
10
+ /**
11
+ * Event to represent the response which should be returned as part of a S3 Batch custom
12
+ * action.
13
+ *
14
+ * https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html
15
+ */
16
+
17
+ @ Data
18
+ @ Builder (setterPrefix = "with" )
19
+ @ NoArgsConstructor
20
+ @ AllArgsConstructor
21
+ public class S3BatchResponse {
22
+
23
+ private String invocationSchemaVersion ;
24
+ private ResultCode treatMissingKeysAs ;
25
+ private String invocationId ;
26
+ private List <Result > results ;
27
+
28
+ @ Data
29
+ @ Builder (setterPrefix = "with" )
30
+ @ NoArgsConstructor
31
+ @ AllArgsConstructor
32
+ public static class Result {
33
+
34
+ private String taskId ;
35
+ private ResultCode resultCode ;
36
+ private String resultString ;
37
+ }
38
+
39
+ public enum ResultCode {
40
+
41
+ /**
42
+ * The task completed normally. If you requested a job completion report,
43
+ * the task's result string is included in the report.
44
+ */
45
+ Succeeded ,
46
+ /**
47
+ * The task suffered a temporary failure and will be redriven before the job
48
+ * completes. The result string is ignored. If this is the final redrive,
49
+ * the error message is included in the final report.
50
+ */
51
+ TemporaryFailure ,
52
+ /**
53
+ * The task suffered a permanent failure. If you requested a job-completion
54
+ * report, the task is marked as Failed and includes the error message
55
+ * string. Result strings from failed tasks are ignored.
56
+ */
57
+ PermanentFailure
58
+ }
59
+
60
+ public static S3BatchResponseBuilder fromS3BatchEvent (S3BatchEvent s3BatchEvent ) {
61
+ return S3BatchResponse .builder ()
62
+ .withInvocationId (s3BatchEvent .getInvocationId ())
63
+ .withInvocationSchemaVersion (s3BatchEvent .getInvocationSchemaVersion ());
64
+ }
65
+ }
0 commit comments