aws / aws-lambda-java-libs

Official mirror for interface definitions and helper classes for Java code running on the AWS Lambda platform.
https://aws.amazon.com/lambda/
Apache License 2.0
521 stars 230 forks source link

Any plan to add EventBridge event? #109

Open alicanguclukol opened 4 years ago

alicanguclukol commented 4 years ago

Hi there.

I'm using a lambda function to process events from an event bus.

I'm not able to find out which is the runtime event class to access these events. There does not seem to be any EventBridge* class in the following link:

https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events

I think a class extending com.amazonaws.services.eventbridge.model.PutEventsRequestEntry may do the work. Do you have any plan to add something like that?

Thanks!

msailes commented 4 years ago

Hi,

EventBridge is a new service based on CloudWatch Events.

Does the CloudWatch scheduled event object meet your requirements?

https://github.com/aws/aws-lambda-java-libs/blob/master/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledEvent.java

nanodeath commented 3 years ago

Unfortunately if you drop in ScheduledEvent instead, you get this:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "version" (class com.amazonaws.services.lambda.runtime.events.ScheduledEvent), not marked as ignorable (8 known properties: "detail", "region", "resources", "detailType", "account", "source", "time", "id"])

If you deserialize the object yourself, using Jackson, and add this:

.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

it seems to work well enough. Not ideal though.

msailes commented 2 years ago

Hi @nanodeath,

I'll add support for EventBridge events after v4 has been released.

Thanks,

Mark

polaskj commented 2 years ago

Going to offer a suggestion since this is still open to being implemented. I've seen many uses of Object rather than strongly typing fields (as an example detail in ScheduledEvent). This leaves the rest of the deserializing efforts up to the caller and can be error-prone.

I'd like to see something more along the lines of this, so a caller-provided generic can represent the detail, instead of just Object

public class EventBridgeEvent<T extends EventBridgeDetail> implements Serializable, Cloneable {
    ....
    private T detail;

Eg callsite:

public Context handleRequest(EventBridgeEvent<EventBridgeS3EventDetail> event, Context context) {
...
return context;
}

I'd be happy to continue the discussion on this.

msailes commented 2 years ago

@polaskj, Great suggestion, let me try that out.

StFS commented 2 years ago

Any news on this? I see that the PR has been open since January.

javiortizmol commented 2 years ago

Any news about this?, can some help us merging the PR opened since January?

msailes commented 2 years ago

Hi @StFS, @javiortizmol,

This will go out either with v4 of the events library or soon after, customer interest is clear.

StFS commented 2 years ago

@msailes any ETA on when v4 of the events library will be released?

StFS commented 1 year ago

I ask again, is there any ETA on v4 of the events library?

einarjohnson commented 1 year ago

Any news on this?

evgromva commented 1 year ago

Any updates about v4 ?

msailes commented 1 year ago

I don’t currently have a date we can share. The team is aware of the difficulties this causes and are working to improve the process.