Skip to content

Commit

Permalink
Add S3BatchEventV2 class
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerfort committed Jul 22, 2024
1 parent 70467ba commit 16533b0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.amazonaws.services.lambda.runtime.events;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
* Event to represent the payload which is sent to Lambda by S3 Batch to perform a custom
* action when using invocation schema version 2.0.
*
* https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html
*/

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public class S3BatchEventV2 {

private String invocationSchemaVersion;
private String invocationId;
private Job job;
private List<Task> tasks;

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public static class Job {

private String id;
private Map<String, String> userArguments;
}

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public static class Task {

private String taskId;
private String s3Key;
private String s3VersionId;
private String s3BucketName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEvent s3BatchEvent)
.withInvocationId(s3BatchEvent.getInvocationId())
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
}
}

public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEventV2 s3BatchEvent) {
return S3BatchResponse.builder()
.withInvocationId(s3BatchEvent.getInvocationId())
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
}
}

0 comments on commit 16533b0

Please sign in to comment.