in.erail.amazon.lambda.eventsource.DynamoDBEventSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-framework-amazon-lambda Show documentation
Show all versions of api-framework-amazon-lambda Show documentation
Lib to run API Framework code on Amazon Lambda
package in.erail.amazon.lambda.eventsource;
import com.google.common.net.HttpHeaders;
import com.google.common.net.MediaType;
import in.erail.amazon.lambda.EventSource;
import in.erail.glue.common.Util;
import io.vertx.core.json.JsonObject;
/**
*
* @author vinay
*/
public class DynamoDBEventSource implements EventSource {
public static final String URL = "/aws/dynamodb";
public static final String ENV_NAME = "api.framework.lambda.dynamodb.url";
private final String url = Util.getEnvironmentValue(ENV_NAME, URL);
@Override
public EventSourceName getEventSourceName() {
return EventSourceName.DYNAMODB;
}
@Override
public JsonObject transform(JsonObject pEvent) {
JsonObject newRequest = new JsonObject()
.put("path", url)
.put("httpMethod", "POST")
.put("body", pEvent.toString().getBytes())
.put("headers", new JsonObject()
.put(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString())
.put("aws-event-source", getEventSourceName().toString()));
return newRequest;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy