Skip to content

initial class to represent the EventBridge message format. #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.amazonaws.services.lambda.runtime.events;

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

import java.util.List;

/**
* Class to represent the EventBridge event. This is also the CloudWatch Events event format.
*
* @see <a href="https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html">CloudWatch Events</a>
*/

@Data
@Builder(setterPrefix = "with")
@NoArgsConstructor
@AllArgsConstructor
public class EventBridgeEvent {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the EventBridge "Download code bindings" feature actually provides an AWSEvent (below). Is it useful to have it in the lib, and if so, why not simply use the generic one below?

public class AWSEvent<T> {

  @JsonProperty("detail")
  private T detail = null;

  @JsonProperty("detail-type")
  private String detailType = null;

  @JsonProperty("resources")
  private List resources = null;

  @JsonProperty("id")
  private String id = null;

  @JsonProperty("source")
  private String source = null;

  @JsonProperty("time")
  private Date time = null;

  @JsonProperty("region")
  private String region = null;

  @JsonProperty("version")
  private String version = null;

  @JsonProperty("account")
  private String account = null;

// ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the Lambda service would be able to handle the typing.

@carlzogh

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not at this point, the Java runtime needs to handle @JsonProperty annotations internally


private String version;
private String id;
private String detailType;
Copy link

@aashutoshbane aashutoshbane Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this will get serialized as the field which comes in event looks like detail-type.
Untill and unless jackson understands the hypen to get converted into camelCase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely correct. I'm working with the Lambda team to sort this out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private String source;
private String account;
private String time;
private String region;
private List<String> resources;
private Object detail;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an object here while it is a map in 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.
Actually, I agree with the object more than the map... maybe I miss something.

}