index
int64
0
0
repo_id
stringlengths
26
205
file_path
stringlengths
51
246
content
stringlengths
8
433k
__index_level_0__
int64
0
10k
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/DynamodbEventTransformer.java
package com.amazonaws.services.lambda.runtime.events.transformers.v2; import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; import com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb.DynamodbRecordTransformer; import software.amazon.awssdk.services.dynamodb.model.Record; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; public class DynamodbEventTransformer { public static List<Record> toRecordsV2(final DynamodbEvent dynamodbEvent) { return dynamodbEvent .getRecords() .stream() .filter(record -> !Objects.isNull(record)) .map(DynamodbRecordTransformer::toRecordV2) .collect(Collectors.toList()); } }
1,700
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbIdentityTransformer.java
package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; import software.amazon.awssdk.services.dynamodb.model.Identity; public class DynamodbIdentityTransformer { public static Identity toIdentityV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.Identity identity) { return Identity.builder() .principalId(identity.getPrincipalId()) .type(identity.getType()) .build(); } }
1,701
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbAttributeValueTransformer.java
package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; import software.amazon.awssdk.core.SdkBytes; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; public class DynamodbAttributeValueTransformer { public static AttributeValue toAttributeValueV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue value) { if (Objects.nonNull(value.getS())) { return AttributeValue.builder() .s(value.getS()) .build(); } else if (Objects.nonNull(value.getSS())) { return AttributeValue.builder() .ss(value.getSS().isEmpty() ? null : value.getSS()) .build(); } else if (Objects.nonNull(value.getN())) { return AttributeValue.builder() .n(value.getN()) .build(); } else if (Objects.nonNull(value.getNS())) { return AttributeValue.builder() .ns(value.getNS().isEmpty() ? null : value.getNS()) .build(); } else if (Objects.nonNull(value.getB())) { return AttributeValue.builder() .b(SdkBytes.fromByteBuffer(value.getB())) .build(); } else if (Objects.nonNull(value.getBS())) { return AttributeValue.builder() .bs(value.getBS().isEmpty() ? null : value.getBS().stream() .map(SdkBytes::fromByteBuffer) .collect(Collectors.toList())) .build(); } else if (Objects.nonNull(value.getBOOL())) { return AttributeValue.builder() .bool(value.getBOOL()) .build(); } else if (Objects.nonNull(value.getL())) { return AttributeValue.builder() .l(value.getL().isEmpty() ? Collections.emptyList() : value.getL().stream() .map(DynamodbAttributeValueTransformer::toAttributeValueV2) .collect(Collectors.toList())) .build(); } else if (Objects.nonNull(value.getM())) { return AttributeValue.builder() .m(toAttributeValueMapV2(value.getM())) .build(); } else if (Objects.nonNull(value.getNULL())) { return AttributeValue.builder() .nul(value.getNULL()) .build(); } else { throw new IllegalArgumentException( String.format("Unsupported attributeValue type: %s", value)); } } public static Map<String, AttributeValue> toAttributeValueMapV2( final Map<String, com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue> attributeValueMap ) { return attributeValueMap .entrySet() .stream() .collect(Collectors.toMap( Map.Entry::getKey, entry -> toAttributeValueV2(entry.getValue()) )); } }
1,702
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbRecordTransformer.java
package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; import com.amazonaws.services.lambda.runtime.events.DynamodbEvent; import software.amazon.awssdk.services.dynamodb.model.Record; public class DynamodbRecordTransformer { public static Record toRecordV2(final DynamodbEvent.DynamodbStreamRecord record) { return Record.builder() .awsRegion(record.getAwsRegion()) .dynamodb( DynamodbStreamRecordTransformer.toStreamRecordV2(record.getDynamodb()) ) .eventID(record.getEventID()) .eventName(record.getEventName()) .eventSource(record.getEventSource()) .eventVersion(record.getEventVersion()) .userIdentity( record.getUserIdentity() != null ? DynamodbIdentityTransformer.toIdentityV2(record.getUserIdentity()) : null ) .build(); } }
1,703
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2
Create_ds/aws-lambda-java-libs/aws-lambda-java-events-sdk-transformer/src/main/java/com/amazonaws/services/lambda/runtime/events/transformers/v2/dynamodb/DynamodbStreamRecordTransformer.java
package com.amazonaws.services.lambda.runtime.events.transformers.v2.dynamodb; import software.amazon.awssdk.services.dynamodb.model.StreamRecord; public class DynamodbStreamRecordTransformer { public static StreamRecord toStreamRecordV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord streamRecord) { return StreamRecord.builder() .approximateCreationDateTime( streamRecord.getApproximateCreationDateTime().toInstant() ) .keys( DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getKeys()) ) .newImage( streamRecord.getNewImage() != null ? DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getNewImage()) : null ) .oldImage( streamRecord.getOldImage() != null ? DynamodbAttributeValueTransformer.toAttributeValueMapV2(streamRecord.getOldImage()) : null ) .sequenceNumber(streamRecord.getSequenceNumber()) .sizeBytes(streamRecord.getSizeBytes()) .streamViewType(streamRecord.getStreamViewType()) .build(); } }
1,704
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/PojoSerializer.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization; import java.io.InputStream; import java.io.OutputStream; public interface PojoSerializer<T> { T fromJson(InputStream input); T fromJson(String input); void toJson(T value, OutputStream output); }
1,705
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/Functions.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.util; /** * Interfaces for reflective function calls * R functions return a type R with n number of arguments * V functions are void * A generics represent arguments for a function handle */ public final class Functions { private Functions() {} public interface R0<R> { public R call(); } public interface R1<R, A1> { public R call(A1 arg1); } public interface R2<R, A1, A2> { public R call(A1 arg1, A2 arg2); } public interface R3<R, A1, A2, A3> { public R call(A1 arg1, A2 arg2, A3 arg3); } public interface R4<R, A1, A2, A3, A4> { public R call(A1 arg1, A2 arg2, A3 arg3, A4 arg4); } public interface R5<R, A1, A2, A3, A4, A5> { public R call(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5); } public interface R9<R, A1, A2, A3, A4, A5, A6, A7, A8, A9> { public R call(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6, A7 arg7, A8 arg8, A9 arg9); } public interface V0 { public void call(); } public interface V1<A1> { public void call(A1 arg1); } public interface V2<A1, A2> { public void call(A1 arg1, A2 arg2); } }
1,706
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/LambdaByteArrayOutputStream.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.util; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; /** * java.io.ByteArrayOutputStream that gives raw access to underlying byte array */ final class LambdaByteArrayOutputStream extends ByteArrayOutputStream { public LambdaByteArrayOutputStream(int size) { super(size); } public byte[] getRawBuf() { return super.buf; } public int getValidByteCount() { return super.count; } public void readAll(InputStream input) throws IOException { while(true) { int numToRead = Math.max(input.available(), 1024); ensureSpaceAvailable(numToRead); int rc = input.read(this.buf, this.count, numToRead); if(rc < 0) { break; } else { this.count += rc; } } } private void ensureSpaceAvailable(int space) { if(space <= 0) { return; } int remaining = count - buf.length; if(remaining < space) { int newSize = buf.length * 2; if(newSize < buf.length) { newSize = Integer.MAX_VALUE; } byte[] newBuf = new byte[newSize]; System.arraycopy(this.buf, 0, newBuf, 0, count); this.buf = newBuf; } } }
1,707
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/ReflectUtil.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.util; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.GenericArrayType; import java.lang.reflect.TypeVariable; import java.lang.reflect.Type; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R0; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R1; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R2; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R3; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R4; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R5; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.R9; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.V1; import com.amazonaws.services.lambda.runtime.serialization.util.Functions.V2; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; /** * Class with reflection utilities */ public final class ReflectUtil { private ReflectUtil() { } /** * Copy a class from one class loader to another. Was previously used in AwsJackson class to do some crazy * passing of classes from class loader to class loader. When that class was removed due to excessive complexity, * this method was retained for potential future use. * @param clazz class to copy * @param cl class loader to copy class to * @return Class inside new classloader * @throws UncheckedIOException if class cannot be copied * @throws ReflectException if class cannot be read after copying */ @SuppressWarnings({"unchecked"}) public static Class<?> copyClass(Class<?> clazz, ClassLoader cl) { // if class exists in target class loader then just load that class and return try { return cl.loadClass(clazz.getName()); } catch (ClassNotFoundException e) {} // copy class to target class loader LambdaByteArrayOutputStream stream; // 1 kb final int chunkSize = 1024; final String resourceName = clazz.getName().replace('.', '/') + ".class"; try(InputStream input = clazz.getClassLoader().getResourceAsStream(resourceName)) { int initial = Math.max(chunkSize, input.available()); stream = new LambdaByteArrayOutputStream(initial); stream.readAll(input); } catch (IOException e) { throw new UncheckedIOException(e); } // load class from target class loader try { Functions.R5<Class<?>, ClassLoader, String, byte[], Integer, Integer> defineClassMethod = ReflectUtil.loadInstanceR4(ClassLoader.class, "defineClass", true, (Class<Class<?>>)(Class)Class.class, String.class, byte[].class, int.class, int.class); Class<?> result = defineClassMethod.call(cl, clazz.getName(), stream.getRawBuf(), 0, stream.getValidByteCount()); V2<ClassLoader, Class<?>> resolveClass = ReflectUtil.loadInstanceV1(ClassLoader.class, "resolveClass", true, Class.class); resolveClass.call(cl, result); return result; } catch (ClassFormatError | SecurityException e) { throw new ReflectException(e); } } public static Class<?> loadClass(ClassLoader cl, String name) { try { return Class.forName(name, true, cl); } catch(ClassNotFoundException | LinkageError e) { throw new ReflectException(e); } } public static class ReflectException extends RuntimeException { private static final long serialVersionUID = 1L; public ReflectException() { super(); // TODO Auto-generated constructor stub } public ReflectException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } public ReflectException(String message, Throwable cause) { super(message, cause); } public ReflectException(String message) { super(message); } public ReflectException(Throwable cause) { super(cause); } } private static <T> T newInstance(Constructor<? extends T> constructor, Object... params) { try { return constructor.newInstance(params); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new ReflectException(e); } } public static Class<?> getRawClass(Type type) { if (type instanceof Class) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { return getRawClass(((ParameterizedType)type).getRawType()); } else if (type instanceof GenericArrayType) { Class<?> componentRaw = getRawClass(((GenericArrayType)type).getGenericComponentType()); return Array.newInstance(componentRaw, 0).getClass(); } else if (type instanceof TypeVariable) { throw new ReflectException("type variables not supported"); } else { throw new ReflectException("unsupport type: " + type.getClass().getName()); } } public static R1<Object, Object> makeCaster(Type type) { return makeCaster(getRawClass(type)); } private static <T> R1<T, Object> boxCaster(final Class<? extends T> clazz) { return new R1<T, Object>() { public T call(Object o) { return clazz.cast(o); } }; } @SuppressWarnings("unchecked") public static <T> R1<T, Object> makeCaster(Class<? extends T> clazz) { if(long.class.equals(clazz)) { return (R1)boxCaster(Long.class); } else if (double.class.equals(clazz)) { return (R1)boxCaster(Double.class); } else if (float.class.equals(clazz)) { return (R1)boxCaster(Float.class); } else if (int.class.equals(clazz)) { return (R1)boxCaster(Integer.class); } else if (short.class.equals(clazz)) { return (R1)boxCaster(Short.class); } else if (char.class.equals(clazz)) { return (R1)boxCaster(Character.class); } else if (byte.class.equals(clazz)) { return (R1)boxCaster(Byte.class); } else if (boolean.class.equals(clazz)) { return (R1)boxCaster(Boolean.class); } else { return boxCaster(clazz); } } private static <T> T invoke(Method method, Object instance, Class<? extends T> rType, Object... params) { final R1<T, Object> caster = makeCaster(rType); try { Object result = method.invoke(instance, params); if(rType.equals(Void.TYPE)) { return null; } else { return caster.call(result); } } catch(InvocationTargetException | ExceptionInInitializerError | IllegalAccessException e) { throw new ReflectException(e); } } private static Method lookupMethod(Class<?> clazz, String name, Class<?>... pTypes) { try { try { return clazz.getDeclaredMethod(name, pTypes); } catch (NoSuchMethodException e) { return clazz.getMethod(name, pTypes); } } catch (NoSuchMethodException | SecurityException e) { throw new ReflectException(e); } } private static Method getDeclaredMethod(Class<?> clazz, String name, boolean isStatic, boolean setAccessible, Class<?> rType, Class<?>... pTypes) { final Method method = lookupMethod(clazz, name, pTypes); if (!rType.equals(Void.TYPE) && !rType.isAssignableFrom(method.getReturnType())) { throw new ReflectException("Class=" + clazz.getName() + " method=" + name + " type " + method.getReturnType().getName() + " not assignment-compatible with " + rType.getName()); } int mods = method.getModifiers(); if (Modifier.isStatic(mods) != isStatic) { throw new ReflectException("Class=" + clazz.getName() + " method=" + name + " expected isStatic=" + isStatic); } if (setAccessible) { method.setAccessible(true); } return method; } private static <T> Constructor<? extends T> getDeclaredConstructor(Class<? extends T> clazz, boolean setAccessible, Class<?>... pTypes) { final Constructor<? extends T> constructor; try { constructor = clazz.getDeclaredConstructor(pTypes); } catch (NoSuchMethodException | SecurityException e) { throw new ReflectException(e); } if (setAccessible) { constructor.setAccessible(true); } return constructor; } /** * load instance method that takes no parameters and returns type R * @param clazz Class of instance * @param name name of method * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param <C> instance class type * @param <R> return type * @return function handle */ public static <C, R> R1<R, C> loadInstanceR0(Class<? super C> clazz, String name, boolean setAccessible, final Class<? extends R> rType) { final Method method = getDeclaredMethod(clazz, name, false, setAccessible, rType); return new R1<R, C>() { public R call(C instance) { return invoke(method, instance, rType); } }; } /** * load instance method that takes 4 parameters and return type R * @param clazz class of instance * @param name name of method * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param a1Type argument 1 class * @param a2Type argument 2 class * @param a3Type argument 3 class * @param a4Type argument 4 class * @param <A1> argument 1 type * @param <A2> argument 2 type * @param <A3> argument 3 type * @param <A4> argument 4 type * @param <C> instance class type * @param <R> return type * @return function handle */ public static <A1, A2, A3, A4, C, R> R5<R, C, A1, A2, A3, A4> loadInstanceR4(Class<? super C> clazz, String name, boolean setAccessible, final Class<? extends R> rType, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) { final Method method = getDeclaredMethod(clazz, name, false, setAccessible, rType, a1Type, a2Type, a3Type, a4Type); return new R5<R, C, A1, A2, A3, A4>() { public R call(C instance, A1 a1, A2 a2, A3 a3, A4 a4) { return invoke(method, instance, rType, a1, a2, a3, a4); } }; } /** * load an instance method that take 1 parameter and does not return anything * @param clazz class of instance * @param name name of method * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param <C> instance class type * @param <A1> argument 1 type * @return function handle */ public static <A1, C> V2<C, A1> loadInstanceV1(final Class<? super C> clazz, String name, boolean setAccessible, final Class<? super A1> a1Type) { final Method method = getDeclaredMethod(clazz, name, false, setAccessible, Void.TYPE, a1Type); return new V2<C, A1>() { public void call(C instance, A1 a1) { invoke(method, instance, Void.TYPE, a1); } }; } /** * load an instance method that takes no parameters and return type R * @param instance instance to load method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param <C> instance type * @param <R> return type * @return function handle */ public static <C, R> R0<R> bindInstanceR0(final C instance, String name, boolean setAccessible, final Class<? extends R> rType) { final Method method = getDeclaredMethod(instance.getClass(), name, false, setAccessible, rType); return new R0<R>() { public R call() { return invoke(method, instance, rType); } }; } /** * load an instance method that takes 1 parameter and returns type R * @param instance instance to load method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param a1Type class of argument 1 * @param <C> instance type * @param <A1> argument 1 type * @param <R> return type * @return function handle */ public static <A1, C, R> R1<R, A1> bindInstanceR1(final C instance, String name, boolean setAccessible, final Class<? extends R> rType, Class<? super A1> a1Type) { final Method method = getDeclaredMethod(instance.getClass(), name, false, setAccessible, rType, a1Type); return new R1<R, A1>() { public R call(A1 a1) { return invoke(method, instance, rType, a1); } }; } /** * * load an instance method that takes 1 parameter and returns nothing * @param instance instance to load method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param a1Type class of argument 1 * @param <C> instance type * @param <A1> argument 1 type * @return function handle */ public static <A1, C> V1<A1> bindInstanceV1(final C instance, String name, boolean setAccessible, final Class<? super A1> a1Type) { final Method method = getDeclaredMethod(instance.getClass(), name, false, setAccessible, Void.TYPE, a1Type); return new V1<A1>() { public void call(A1 a1) { invoke(method, instance, Void.TYPE, a1); } }; } /** * load an instance method that takes 2 parameter and returns nothing * @param instance instance to load method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param a1Type class of argument 1 * @param a2Type class of argument 2 * @param <C> instance type * @param <A1> argument 1 type * @param <A2> argument 2 type * @return function handle */ public static <A1, A2, C> V2<A1, A2> bindInstanceV2(final C instance, String name, boolean setAccessible, final Class<? super A1> a1Type, final Class<? super A2> a2Type) { final Method method = getDeclaredMethod(instance.getClass(), name, false, setAccessible, Void.TYPE, a1Type, a2Type); return new V2<A1, A2>() { public void call(A1 a1, A2 a2) { invoke(method, instance, Void.TYPE, a1, a2); } }; } /** * load static method that takes no parameters and returns type R * @param clazz class to load static method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param <R> return type * @return function handle */ public static <R> R0<R> loadStaticR0(Class<?> clazz, String name, boolean setAccessible, final Class<? extends R> rType) { final Method method = getDeclaredMethod(clazz, name, true, setAccessible, rType); return new R0<R>() { public R call() { return invoke(method, null, rType); } }; } /** * load static method that takes one parameter and returns type R * @param clazz class to load static method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param rType class of return type * @param a1Type argument 1 class * @param <R> return type * @param <A1> argument 1 type * @return function handle */ public static <A1, R> R1<R, A1> loadStaticR1(Class<?> clazz, String name, boolean setAccessible, final Class<? extends R> rType, Class<? super A1> a1Type) { final Method method = getDeclaredMethod(clazz, name, true, setAccessible, rType, a1Type); return new R1<R, A1>() { public R call(A1 a1) { return invoke(method, null, rType, a1); } }; } /** * load static method that takes two parameters and return nothing * @param clazz class to load static method from * @param name method name * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param a2Type argument 2 class * @param <A1> argument 1 type * @param <A2> argument 2 type * @return function handle */ public static <A1, A2> V2<A1, A2> loadStaticV2(Class<?> clazz, String name, boolean setAccessible, final Class<? super A1> a1Type, final Class<? super A2> a2Type) { final Method method = getDeclaredMethod(clazz, name, true, setAccessible, Void.TYPE, a1Type, a2Type); return new V2<A1, A2>() { public void call(A1 a1, A2 a2) { invoke(method, null, Void.TYPE, a1, a2); } }; } /** * load default constructor * @param clazz Class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param <C> Class type * @return function handle */ public static <C> R0<C> loadConstructor0(final Class<? extends C> clazz, boolean setAccessible) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible); return new R0<C>() { public C call() { return newInstance(constructor); } }; } /** * load constructor that takes 1 parameter * @param clazz Class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param <C> Class type * @param <A1> argument 1 type * @return function handle */ public static <A1, C> R1<C, A1> loadConstructor1(final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible, a1Type); return new R1<C, A1>() { public C call(A1 a1) { return newInstance(constructor, a1); } }; } /** * load constructor that takes 2 parameters * @param clazz Class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param a2Type argument 2 class * @param <C> Class type * @param <A1> argument 1 type * @param <A2> argument 2 type * @return function handle */ public static <A1, A2, C> R2<C, A1, A2> loadConstructor2(final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible, a1Type, a2Type); return new R2<C, A1, A2>() { public C call(A1 a1, A2 a2) { return newInstance(constructor, a1, a2); } }; } /** * load constuctor that takes 3 parameters * @param clazz class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param a2Type argument 2 class * @param a3Type argument 3 class * @param <C> Class type * @param <A1> argument 1 type * @param <A2> argument 2 type * @param <A3> argument 3 type * @return function handle */ public static <C, A1, A2, A3> R3<C, A1, A2, A3> loadConstuctor3(final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible, a1Type, a2Type, a3Type); return new R3<C, A1, A2, A3>() { public C call(A1 a1, A2 a2, A3 a3) { return newInstance(constructor, a1, a2, a3); } }; } /** * loads constructor that takes 4 parameters * @param clazz class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param a2Type argument 2 class * @param a3Type argument 3 class * @param a4Type argument 4 class * @param <C> Class type * @param <A1> argument 1 type * @param <A2> argument 2 type * @param <A3> argument 3 type * @param <A4> argument 4 type * @return function handle */ public static <C, A1, A2, A3, A4> R4<C, A1, A2, A3, A4> loadConstuctor4(final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible, a1Type, a2Type, a3Type, a4Type); return new R4<C, A1, A2, A3, A4>() { public C call(A1 a1, A2 a2, A3 a3, A4 a4) { return newInstance(constructor, a1, a2, a3, a4); } }; } /** * loads constructor that takes 5 paramters * @param clazz class to load constructor for * @param setAccessible whether method is accessible (public vs private) * @param a1Type argument 1 class * @param a2Type argument 2 class * @param a3Type argument 3 class * @param a4Type argument 4 class * @param a5Type argument 5 class * @param <C> Class type * @param <A1> argument 1 type * @param <A2> argument 2 type * @param <A3> argument 3 type * @param <A4> argument 4 type * @param <A5> argument 5 type * @return function handle */ public static <C, A1, A2, A3, A4, A5> R5<C, A1, A2, A3, A4, A5> loadConstuctor5(final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type) { final Constructor<? extends C> constructor = getDeclaredConstructor(clazz, setAccessible, a1Type, a2Type, a3Type, a4Type, a5Type); return new R5<C, A1, A2, A3, A4, A5>() { public C call(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { return newInstance(constructor, a1, a2, a3, a4, a5); } }; } /** * load constuctor that takes 9 parameters * @param a1Type argument 1 class * @param a2Type argument 2 class * @param a3Type argument 3 class * @param a4Type argument 4 class * @param a5Type argument 5 class * @param a6Type argument 6 class * @param a7Type argument 7 class * @param a8Type argument 8 class * @param a9type argument 9 class * @param <C> Class type * @param <A1> argument 1 type * @param <A2> argument 2 type * @param <A3> argument 3 type * @param <A4> argument 4 type * @param <A5> argument 5 type * @param <A6> argument 6 type * @param <A7> argument 7 type * @param <A8> argument 8 type * @param <A9> argument 9 type * @return function handle */ public static <C, A1, A2, A3, A4, A5, A6, A7, A8, A9> R9<C, A1, A2, A3, A4, A5, A6, A7, A8, A9> loadConstuctor9( final Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type, Class<? super A6> a6Type, Class<? super A7> a7Type, Class<? super A8> a8Type, Class<? super A9> a9type) { final Constructor<?extends C> constructor= getDeclaredConstructor(clazz, setAccessible, a1Type, a2Type, a3Type, a4Type, a5Type, a6Type, a7Type, a8Type, a9type); return new R9<C, A1, A2, A3, A4, A5, A6, A7, A8, A9>(){ public C call(A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9){ return newInstance(constructor,a1,a2,a3,a4,a5,a6,a7,a8,a9); } }; } public static <T> T getStaticField(Class<?> clazz, String name, Class<? extends T> type) { R1<T, Object> caster = makeCaster(type); try { return caster.call(clazz.getField(name).get(null)); } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) { throw new ReflectException(e); } } public static void setStaticField(Class<?> clazz, String name, boolean setAccessible, final Object value) { try { Field field = clazz.getDeclaredField(name); if (setAccessible) { field.setAccessible(true); } field.set(null, value); } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) { throw new ReflectException(e); } } }
1,708
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/SerializeUtil.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.util; import java.io.InputStream; import java.util.HashMap; import java.util.Scanner; /** * Class with Utilities for serializing and deserializing customer classes */ public class SerializeUtil { /** * cached of classes being loaded for faster reflect loading */ private static final HashMap<String, Class> cachedClasses = new HashMap<>(); /** * converts an input stream to a string * @param inputStream InputStream object * @return String with stream contents */ public static String convertStreamToString(InputStream inputStream) { Scanner s = new Scanner(inputStream).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; } /** * load a customer class * @param className name of class to load * @return Class object */ public static Class loadCustomerClass(String className, ClassLoader customerClassLoader) { Class cachedClass = cachedClasses.get(className); if (cachedClass == null) { cachedClass = ReflectUtil.loadClass(customerClassLoader, className); cachedClasses.put(className, cachedClass); } return cachedClass; } /** * deserialize a joda datetime object * Underneath the reflection, this method does the following: * * DateTime.parse(jsonParser.getValueAsString()); * * @param dateTimeClass DateTime class * @param dateTimeString string to deserialize from * @param <T> DateTime type * @return DateTime instance */ public static <T> T deserializeDateTime(Class<T> dateTimeClass, String dateTimeString) { Functions.R1<T, String> parseMethod = ReflectUtil.loadStaticR1(dateTimeClass, "parse", true, dateTimeClass, String.class); return parseMethod.call(dateTimeString); } /** * serialize a DateTime object * Underneath the reflection, this method does the following: * * DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); * jsonGenerator.writeString(formatter.print(customerDateTime) * * @param dateTime DateTime object to serialize * @param <T> DateTime type * @param classLoader ClassLoader used to load DateTime classes * @return timestamp as formatted string */ @SuppressWarnings({"unchecked"}) public static <T> String serializeDateTime(T dateTime, ClassLoader classLoader) { // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 Class dateTimeFormatterClass = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.format.DateTimeFormatter", classLoader); Class dateTimeFormatClass = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.format.ISODateTimeFormat", classLoader); Class readableInstantInterface = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.ReadableInstant", classLoader); return serializeDateTimeHelper(dateTime, dateTimeFormatterClass, dateTimeFormatClass, readableInstantInterface); } /** * Helper method to serialize DateTime objects (We need some way to define generics to get code to compile) * @param dateTime DAteTime object * @param dateTimeFormatterClass DAteTime formatter class * @param dateTimeFormatClass DateTime ISO format class * @param readableInstantInterface DateTime readable instant interface (Needed because reflection is type specific) * @param <S> DAteTime type * @param <T> DateTimeFormatter type * @param <U> DateTimeFormat type * @param <V> ReadableInstant type * @return String with serialized date time */ private static <S extends V, T, U, V> String serializeDateTimeHelper(S dateTime, Class<T> dateTimeFormatterClass, Class<U> dateTimeFormatClass, Class<V> readableInstantInterface) { Functions.R0<T> dateTimeFormatterConstructor = ReflectUtil.loadStaticR0(dateTimeFormatClass, "dateTime", true, dateTimeFormatterClass); T dateTimeFormatter = dateTimeFormatterConstructor.call(); Functions.R1<String, S> printMethod = ReflectUtil.bindInstanceR1(dateTimeFormatter, "print", true, String.class, readableInstantInterface); return printMethod.call(dateTime); } }
1,709
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/GsonFactory.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.factories; import java.io.OutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; import java.io.OutputStreamWriter; import java.io.IOException; import java.io.EOFException; import java.io.UncheckedIOException; import java.lang.reflect.Type; import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class GsonFactory implements PojoSerializerFactory { private static final Charset utf8 = StandardCharsets.UTF_8; private static final Gson gson = new GsonBuilder() .disableHtmlEscaping() .serializeSpecialFloatingPointValues() .create(); private static final GsonFactory instance = new GsonFactory(); public static GsonFactory getInstance() { return instance; } private GsonFactory() { } private static class InternalSerializer<T> implements PojoSerializer<T> { private final TypeAdapter<T> adapter; public InternalSerializer(TypeAdapter<T> adapter) { this.adapter = adapter.nullSafe(); } @SuppressWarnings({"rawtypes", "unchecked"}) public static <T> InternalSerializer<T> create(TypeToken<T> token) { if(Void.TYPE.equals(token.getRawType())) { return new InternalSerializer(gson.getAdapter(Object.class)); } else { return new InternalSerializer<T>(gson.getAdapter(token)); } } public static <T> InternalSerializer<T> create(Class<T> clazz) { return create(TypeToken.get(clazz)); } @SuppressWarnings("unchecked") public static <T> InternalSerializer<Object> create(Type type) { return create((TypeToken<Object>)TypeToken.get(type)); } private T fromJson(JsonReader reader) { reader.setLenient(true); try { try { reader.peek(); } catch(EOFException e) { return null; } return adapter.read(reader); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public T fromJson(InputStream input) { try(JsonReader reader = new JsonReader(new InputStreamReader(input, utf8))) { return fromJson(reader); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public T fromJson(String input) { try(JsonReader reader = new JsonReader(new StringReader(input))) { return fromJson(reader); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public void toJson(T value, OutputStream output) { try { try (JsonWriter writer = new JsonWriter(new OutputStreamWriter((output), utf8))) { writer.setLenient(true); writer.setSerializeNulls(false); writer.setHtmlSafe(false); adapter.write(writer, value); } } catch (IOException e) { throw new UncheckedIOException(e); } } } @Override public <T> PojoSerializer<T> getSerializer(Class<T> clazz) { return InternalSerializer.create(clazz); } @Override public PojoSerializer<Object> getSerializer(Type type) { return InternalSerializer.create(type); } }
1,710
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.factories; import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.json.JsonReadFeature; import com.fasterxml.jackson.core.json.JsonWriteFeature; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.SerializationConfig; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.io.IOException; import java.io.OutputStream; import java.io.InputStream; import java.io.UncheckedIOException; import java.lang.reflect.Constructor; import java.lang.reflect.Type; public class JacksonFactory implements PojoSerializerFactory { private static final ObjectMapper globalMapper = createObjectMapper(); private static final JacksonFactory instance = new JacksonFactory(globalMapper); public static JacksonFactory getInstance() { return instance; } private final ObjectMapper mapper; private JacksonFactory(ObjectMapper mapper) { this.mapper = mapper; } public ObjectMapper getMapper() { return mapper; } private static ObjectMapper createObjectMapper() { ObjectMapper mapper = JsonMapper.builder(createJsonFactory()) .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS) // this is default as of 2.2.0 .enable(MapperFeature.AUTO_DETECT_FIELDS) // this is default as of 2.0.0 .enable(MapperFeature.AUTO_DETECT_GETTERS) // this is default as of 2.0.0 .enable(MapperFeature.AUTO_DETECT_IS_GETTERS) // this is default as of 2.0.0 .enable(MapperFeature.AUTO_DETECT_SETTERS) // this is default as of 2.0.0 .enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS) // this is default as of 2.0.0 .enable(MapperFeature.USE_STD_BEAN_NAMING) .enable(MapperFeature.USE_ANNOTATIONS) // this is default as of 2.0.0 .disable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) // this is default as of 2.5.0 .disable(MapperFeature.AUTO_DETECT_CREATORS) .disable(MapperFeature.INFER_PROPERTY_MUTATORS) .disable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY) // this is default as of 2.0.0 .disable(MapperFeature.USE_GETTERS_AS_SETTERS) .disable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME) // this is default as of 2.1.0 .disable(MapperFeature.USE_STATIC_TYPING) // this is default as of 2.0.0 .disable(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS) // this is default as of 2.0.0 .build(); SerializationConfig scfg = mapper.getSerializationConfig(); scfg = scfg.withFeatures( SerializationFeature.FAIL_ON_SELF_REFERENCES, // this is default as of 2.4.0 SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS, // this is default as of 2.4.0 SerializationFeature.WRAP_EXCEPTIONS // this is default as of 2.0.0 ); scfg = scfg.withoutFeatures( SerializationFeature.CLOSE_CLOSEABLE, // this is default as of 2.0.0 SerializationFeature.EAGER_SERIALIZER_FETCH, SerializationFeature.FAIL_ON_EMPTY_BEANS, SerializationFeature.FLUSH_AFTER_WRITE_VALUE, SerializationFeature.INDENT_OUTPUT, // this is default as of 2.5.0 SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, // this is default as of 2.0.0 SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID, // this is default as of 2.3.0 SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS, // this is default as of 2.0.0 SerializationFeature.WRAP_ROOT_VALUE // this is default as of 2.2.0 ); mapper.setConfig(scfg); DeserializationConfig dcfg = mapper.getDeserializationConfig(); dcfg = dcfg.withFeatures( DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, // this is default as of 2.2.0 DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS, // this is default as of 2.5.0 DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, DeserializationFeature.WRAP_EXCEPTIONS // this is default as of 2.0.0 ); dcfg = dcfg.withoutFeatures( DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, // this is default as of 2.3.0 DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, // this is default as of 2.0.0 DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, // this is default as of 2.0.0 DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, // this is default as of 2.3.0 DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); mapper.setConfig(dcfg); mapper.setSerializationInclusion(Include.NON_NULL); mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new Jdk8Module()); return mapper; } private static JsonFactory createJsonFactory() { JsonFactory factory = JsonFactory.builder() //Json Read enabled .enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS) .enable(JsonReadFeature.ALLOW_LEADING_ZEROS_FOR_NUMBERS) .enable(JsonReadFeature.ALLOW_SINGLE_QUOTES) .enable(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER) .enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS) .enable(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES) //Json Read disabled .disable(JsonReadFeature.ALLOW_JAVA_COMMENTS) // this is default as of 2.10.0 .disable(JsonReadFeature.ALLOW_YAML_COMMENTS) // this is default as of 2.10.0 //Json Write enabled .enable(JsonWriteFeature.QUOTE_FIELD_NAMES) // this is default as of 2.10.0 .enable(JsonWriteFeature.WRITE_NAN_AS_STRINGS) // this is default as of 2.10.0 //Json Write disabled .disable(JsonWriteFeature.ESCAPE_NON_ASCII) // this is default as of 2.10.0 .disable(JsonWriteFeature.WRITE_NUMBERS_AS_STRINGS) // this is default as of 2.10.0 .build(); //Json Parser disabled factory.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE); factory.disable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION); //Json Generator enabled factory.enable(JsonGenerator.Feature.IGNORE_UNKNOWN); //Json Generator disabled factory.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); factory.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); factory.disable(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM); factory.disable(JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION); // this is default as of 2.3.0 factory.disable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN); // this is default as of 2.3.0 return factory; } private static class InternalSerializer<T> implements PojoSerializer<T> { private final ObjectReader reader; private final ObjectWriter writer; public InternalSerializer(ObjectReader reader, ObjectWriter writer) { this.reader = reader; this.writer = writer; } @Override public T fromJson(InputStream input) { try { return reader.readValue(input); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public T fromJson(String input) { try { return reader.readValue(input); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public void toJson(T value, OutputStream output) { try { writer.writeValue(output, value); } catch (IOException e) { throw new UncheckedIOException(e); } } } private static final class TypeSerializer extends InternalSerializer<Object> { public TypeSerializer(ObjectMapper mapper, JavaType type) { super(mapper.readerFor(type), mapper.writerFor(type)); } public TypeSerializer(ObjectMapper mapper, Type type) { this(mapper, mapper.constructType(type)); } } private static final class ClassSerializer<T> extends InternalSerializer<T> { public ClassSerializer(ObjectMapper mapper, Class<T> clazz) { super(mapper.readerFor(clazz), mapper.writerFor(clazz)); } } public <T> PojoSerializer<T> getSerializer(Class<T> clazz) { return new ClassSerializer<T>(this.mapper, clazz); } public PojoSerializer<Object> getSerializer(Type type) { return new TypeSerializer(this.mapper, type); } public JacksonFactory withNamingStrategy(PropertyNamingStrategy strategy) { return new JacksonFactory(this.mapper.copy().setPropertyNamingStrategy(strategy)); } public JacksonFactory withMixin(Class<?> clazz, Class<?> mixin) { return new JacksonFactory(this.mapper.copy().addMixIn(clazz, mixin)); } }
1,711
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/PojoSerializerFactory.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.factories; import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; import java.lang.reflect.Type; public interface PojoSerializerFactory { <T> PojoSerializer<T> getSerializer(Class<T> clazz); PojoSerializer<Object> getSerializer(Type type); }
1,712
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializers.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.CloudFormationCustomResourceEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.CloudFrontEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.CloudWatchLogsEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.CodeCommitEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.ConnectEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.DynamodbEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.DynamodbTimeWindowEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.KinesisEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.KinesisTimeWindowEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.SNSEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.SQSEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.ScheduledEventMixin; import com.amazonaws.services.lambda.runtime.serialization.events.mixins.SecretsManagerRotationEventMixin; import com.amazonaws.services.lambda.runtime.serialization.factories.JacksonFactory; import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; import com.amazonaws.services.lambda.runtime.serialization.util.ReflectUtil; import com.amazonaws.services.lambda.runtime.serialization.util.SerializeUtil; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.amazonaws.services.lambda.runtime.serialization.events.modules.DateModule; import com.amazonaws.services.lambda.runtime.serialization.events.modules.DateTimeModule; import com.amazonaws.services.lambda.runtime.serialization.events.serializers.OrgJsonSerializer; import com.amazonaws.services.lambda.runtime.serialization.events.serializers.S3EventSerializer; import java.util.AbstractMap.SimpleEntry; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; /** * This class provides serializers for Lambda supported events. * * HOW TO ADD SUPPORT FOR A NEW EVENT MODEL: * * Option 1 (Preferred): * 1. Add Class name to SUPPORTED_EVENTS * 2. Add Mixin Class to com.amazonaws.services.lambda.runtime.serialization.events.mixins package (if needed) * 3. Add entries to MIXIN_MAP for event class and sub classes (if needed) * 4. Add entries to NESTED_CLASS_MAP for event class and sub classes (if needed) * 5. Add entry to NAMING_STRATEGY_MAP (if needed i.e. Could be used in place of a mixin) * * Option 2 (longer - for event models that do not work with Jackson or GSON): * 1. Add Class name to SUPPORTED_EVENTS * 2. Add serializer (using org.json) to com.amazonaws.services.lambda.runtime.serialization.events.serializers * 3. Add class name and serializer to SERIALIZER_MAP */ public class LambdaEventSerializers { /** * list of supported events */ private static final List<String> SUPPORTED_EVENTS = Stream.of( "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent", "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent", "com.amazonaws.services.lambda.runtime.events.CloudFormationCustomResourceEvent", "com.amazonaws.services.lambda.runtime.events.CloudFrontEvent", "com.amazonaws.services.lambda.runtime.events.CloudWatchLogsEvent", "com.amazonaws.services.lambda.runtime.events.CodeCommitEvent", "com.amazonaws.services.lambda.runtime.events.CognitoEvent", "com.amazonaws.services.lambda.runtime.events.ConfigEvent", "com.amazonaws.services.lambda.runtime.events.ConnectEvent", "com.amazonaws.services.lambda.runtime.events.DynamodbEvent", "com.amazonaws.services.lambda.runtime.events.DynamodbTimeWindowEvent", "com.amazonaws.services.lambda.runtime.events.IoTButtonEvent", "com.amazonaws.services.lambda.runtime.events.KinesisEvent", "com.amazonaws.services.lambda.runtime.events.KinesisTimeWindowEvent", "com.amazonaws.services.lambda.runtime.events.KinesisFirehoseEvent", "com.amazonaws.services.lambda.runtime.events.LambdaDestinationEvent", "com.amazonaws.services.lambda.runtime.events.LexEvent", "com.amazonaws.services.lambda.runtime.events.ScheduledEvent", "com.amazonaws.services.lambda.runtime.events.SecretsManagerRotationEvent", "com.amazonaws.services.s3.event.S3EventNotification", "com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification", "com.amazonaws.services.lambda.runtime.events.S3Event", "com.amazonaws.services.lambda.runtime.events.SNSEvent", "com.amazonaws.services.lambda.runtime.events.SQSEvent") .collect(Collectors.toList()); /** * list of events incompatible with Jackson, with serializers explicitly defined * Classes are incompatible with Jackson for any of the following reasons: * 1. different constructor/setter types from getter types * 2. various bugs within Jackson */ private static final Map<String, OrgJsonSerializer> SERIALIZER_MAP = Stream.of( new SimpleEntry<>("com.amazonaws.services.s3.event.S3EventNotification", new S3EventSerializer<>()), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification", new S3EventSerializer<>()), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.S3Event", new S3EventSerializer<>())) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); /** * Maps supported event classes to mixin classes with Jackson annotations. * Jackson annotations are not loaded through the ClassLoader so if a Java field is serialized or deserialized from a * json field that does not match the Jave field name, then a Mixin is required. */ @SuppressWarnings("rawtypes") private static final Map<String, Class> MIXIN_MAP = Stream.of( new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CloudFormationCustomResourceEvent", CloudFormationCustomResourceEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CloudFrontEvent", CloudFrontEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CloudWatchLogsEvent", CloudWatchLogsEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent", CodeCommitEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent$Record", CodeCommitEventMixin.RecordMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent", ConnectEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent$Details", ConnectEventMixin.DetailsMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent$ContactData", ConnectEventMixin.ContactDataMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent$CustomerEndpoint", ConnectEventMixin.CustomerEndpointMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent$SystemEndpoint", ConnectEventMixin.SystemEndpointMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbEvent", DynamodbEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord", DynamodbEventMixin.DynamodbStreamRecordMixin.class), new SimpleEntry<>("com.amazonaws.services.dynamodbv2.model.StreamRecord", DynamodbEventMixin.StreamRecordMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord", DynamodbEventMixin.StreamRecordMixin.class), new SimpleEntry<>("com.amazonaws.services.dynamodbv2.model.AttributeValue", DynamodbEventMixin.AttributeValueMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue", DynamodbEventMixin.AttributeValueMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbTimeWindowEvent", DynamodbTimeWindowEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.KinesisEvent", KinesisEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.KinesisEvent$Record", KinesisEventMixin.RecordMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.KinesisTimeWindowEvent", KinesisTimeWindowEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ScheduledEvent", ScheduledEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SecretsManagerRotationEvent", SecretsManagerRotationEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SNSEvent", SNSEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SNSEvent$SNSRecord", SNSEventMixin.SNSRecordMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SQSEvent", SQSEventMixin.class), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SQSEvent$SQSMessage", SQSEventMixin.SQSMessageMixin.class)) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); /** * If mixins are required for inner classes of an event, then those nested classes must be specified here. */ @SuppressWarnings("rawtypes") private static final Map<String, List<NestedClass>> NESTED_CLASS_MAP = Stream.of( new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent$Record"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CognitoEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.CognitoEvent$DatasetRecord"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ConnectEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.ConnectEvent$Details"), new NestedClass("com.amazonaws.services.lambda.runtime.events.ConnectEvent$ContactData"), new NestedClass("com.amazonaws.services.lambda.runtime.events.ConnectEvent$CustomerEndpoint"), new NestedClass("com.amazonaws.services.lambda.runtime.events.ConnectEvent$SystemEndpoint"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbEvent", Arrays.asList( new AlternateNestedClass( "com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue", "com.amazonaws.services.dynamodbv2.model.AttributeValue"), new AlternateNestedClass( "com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord", "com.amazonaws.services.dynamodbv2.model.StreamRecord"), new NestedClass("com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbTimeWindowEvent", Arrays.asList( new AlternateNestedClass( "com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue", "com.amazonaws.services.dynamodbv2.model.AttributeValue"), new AlternateNestedClass( "com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord", "com.amazonaws.services.dynamodbv2.model.StreamRecord"), new NestedClass("com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.KinesisEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.KinesisEvent$Record"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SNSEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.SNSEvent$SNSRecord"))), new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SQSEvent", Arrays.asList( new NestedClass("com.amazonaws.services.lambda.runtime.events.SQSEvent$SQSMessage")))) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); /** * If event requires a naming strategy. For example, when someone names the getter method getSNS and the setter * method setSns, for some magical reasons, using both mixins and a naming strategy works */ private static final Map<String, PropertyNamingStrategy> NAMING_STRATEGY_MAP = Stream.of( new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SNSEvent", new PropertyNamingStrategy.PascalCaseStrategy())) .collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue)); /** * Returns whether the class name is a Lambda supported event model. * @param className class name as string * @return whether the event model is supported */ public static boolean isLambdaSupportedEvent(String className) { return SUPPORTED_EVENTS.contains(className); } /** * Return a serializer for the event class * @return a specific PojoSerializer or modified JacksonFactory instance with mixins and modules added in */ @SuppressWarnings({"unchecked"}) public static <T> PojoSerializer<T> serializerFor(Class<T> eventClass, ClassLoader classLoader) { // if serializer specifically defined for event then use that if (SERIALIZER_MAP.containsKey(eventClass.getName())) { return SERIALIZER_MAP.get(eventClass.getName()).withClass(eventClass).withClassLoader(classLoader); } // else use a Jackson ObjectMapper instance JacksonFactory factory = JacksonFactory.getInstance(); // if mixins required for class, then apply if (MIXIN_MAP.containsKey(eventClass.getName())) { factory = factory.withMixin(eventClass, MIXIN_MAP.get(eventClass.getName())); } // if event model has nested classes then load those classes and check if mixins apply if (NESTED_CLASS_MAP.containsKey(eventClass.getName())) { List<NestedClass> nestedClasses = NESTED_CLASS_MAP.get(eventClass.getName()); for (NestedClass nestedClass: nestedClasses) { // if mixin exists for nested class then apply if (MIXIN_MAP.containsKey(nestedClass.className)) { factory = tryLoadingNestedClass(classLoader, factory, nestedClass); } } } // load DateModules factory.getMapper().registerModules(new DateModule(), new DateTimeModule(classLoader)); // load naming strategy if needed if (NAMING_STRATEGY_MAP.containsKey(eventClass.getName())) { factory = factory.withNamingStrategy(NAMING_STRATEGY_MAP.get(eventClass.getName())); } return factory.getSerializer(eventClass); } /** * Tries to load a nested class with its defined mixin from {@link #MIXIN_MAP} into the {@link JacksonFactory} object. * Will allow initial failure for {@link AlternateNestedClass} objects and try again with their alternate class name * @return a modified JacksonFactory instance with mixins added in */ private static JacksonFactory tryLoadingNestedClass(ClassLoader classLoader, JacksonFactory factory, NestedClass nestedClass) { Class<?> eventClazz; Class<?> mixinClazz; try { eventClazz = SerializeUtil.loadCustomerClass(nestedClass.getClassName(), classLoader); mixinClazz = MIXIN_MAP.get(nestedClass.getClassName()); } catch (ReflectUtil.ReflectException e) { if (nestedClass instanceof AlternateNestedClass) { AlternateNestedClass alternateNestedClass = (AlternateNestedClass) nestedClass; eventClazz = SerializeUtil.loadCustomerClass(alternateNestedClass.getAlternateClassName(), classLoader); mixinClazz = MIXIN_MAP.get(alternateNestedClass.getAlternateClassName()); } else { throw e; } } return factory.withMixin(eventClazz, mixinClazz); } private static class NestedClass { private final String className; protected NestedClass(String className) { this.className = className; } protected String getClassName() { return className; } } private static class AlternateNestedClass extends NestedClass { private final String alternateClassName; private AlternateNestedClass(String className, String alternateClassName) { super(className); this.alternateClassName = alternateClassName; } private String getAlternateClassName() { return alternateClassName; } } }
1,713
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/DynamodbEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.nio.ByteBuffer; import java.util.Date; import java.util.List; import java.util.Map; public abstract class DynamodbEventMixin { // needed because jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); public abstract class DynamodbStreamRecordMixin { // needed because Jackson cannot distinguish between Enum eventName from String eventName @JsonProperty("eventName") abstract String getEventName(); @JsonProperty("eventName") abstract void setEventName(String eventName); // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); } public abstract class StreamRecordMixin { // needed because Jackson expects "keys" instead of "Keys" @JsonProperty("Keys") abstract Map<String, ?> getKeys(); @JsonProperty("Keys") abstract void setKeys(Map<String, ?> keys); // needed because Jackson expects "sizeBytes" instead of "SizeBytes" @JsonProperty("SizeBytes") abstract Long getSizeBytes(); @JsonProperty("SizeBytes") abstract void setSizeBytes(Long sizeBytes); // needed because Jackson expects "sequenceNumber" instead of "SequenceNumber" @JsonProperty("SequenceNumber") abstract String getSequenceNumber(); @JsonProperty("SequenceNumber") abstract void setSequenceNumber(String sequenceNumber); // needed because Jackson expects "streamViewType" instead of "StreamViewType" @JsonProperty("StreamViewType") abstract String getStreamViewType(); @JsonProperty("StreamViewType") abstract void setStreamViewType(String streamViewType); // needed because Jackson expects "newImage" instead of "NewImage" @JsonProperty("NewImage") abstract Map<String, ?> getNewImage(); @JsonProperty("NewImage") abstract void setNewImage(Map<String, ?> newImage); // needed because Jackson expects "oldImage" instead of "OldImage" @JsonProperty("OldImage") abstract Map<String, ?> getOldImage(); @JsonProperty("OldImage") abstract void setOldImage(Map<String, ?> oldImage); // needed because Jackson expects "approximateCreationDateTime" instead of "ApproximateCreationDateTime" @JsonProperty("ApproximateCreationDateTime") abstract Date getApproximateCreationDateTime(); @JsonProperty("ApproximateCreationDateTime") abstract void setApproximateCreationDateTime(Date approximateCreationDateTime); } public abstract class AttributeValueMixin { // needed because Jackson expects "s" instead of "S" @JsonProperty("S") abstract String getS(); @JsonProperty("S") abstract void setS(String s); // needed because Jackson expects "n" instead of "N" @JsonProperty("N") abstract String getN(); @JsonProperty("N") abstract void setN(String n); // needed because Jackson expects "b" instead of "B" @JsonProperty("B") abstract ByteBuffer getB(); @JsonProperty("B") abstract void setB(ByteBuffer b); // needed because Jackson expects "null" instead of "NULL" @JsonProperty("NULL") abstract Boolean isNULL(); @JsonProperty("NULL") abstract void setNULL(Boolean nU); // needed because Jackson expects "bool" instead of "BOOL" @JsonProperty("BOOL") abstract Boolean getBOOL(); @JsonProperty("BOOL") abstract void setBOOL(Boolean bO); // needed because Jackson expects "ss" instead of "SS" @JsonProperty("SS") abstract List<String> getSS(); @JsonProperty("SS") abstract void setSS(List<String> sS); // needed because Jackson expects "ns" instead of "NS" @JsonProperty("NS") abstract List<String> getNS(); @JsonProperty("NS") abstract void setNS(List<String> nS); // needed because Jackson expects "bs" instead of "BS" @JsonProperty("BS") abstract List<String> getBS(); @JsonProperty("BS") abstract void setBS(List<String> bS); // needed because Jackson expects "m" instead of "M" @JsonProperty("M") abstract Map<String, ?> getM(); @JsonProperty("M") abstract void setM(Map<String, ?> val); // needed because Jackson expects "l" instead of "L" @JsonProperty("L") abstract List<?> getL(); @JsonProperty("L") abstract void setL(List<?> val); } }
1,714
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/ScheduledEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; /** * Jackson annotations for ScheduledEvent */ public abstract class ScheduledEventMixin { // needed because Jackson expects "detailType" instead of "detail-type" @JsonProperty("detail-type") abstract String getDetailType(); @JsonProperty("detail-type") abstract void setDetailType(String detailType); }
1,715
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SecretsManagerRotationEventMixin.java
/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; /** * Jackson annotations for SecretsManagerRotationEvent */ public abstract class SecretsManagerRotationEventMixin { // needed because Jackson expects "step" instead of "Step" @JsonProperty("Step") abstract String getStep(); @JsonProperty("Step") abstract void setStep(String step); // needed because Jackson expects "secretId" instead of "SecretId" @JsonProperty("SecretId") abstract String getSecretId(); @JsonProperty("SecretId") abstract void setSecretId(String secretId); // needed because Jackson expects "clientRequestToken" instead of "ClientRequestToken" @JsonProperty("ClientRequestToken") abstract String getClientRequestToken(); @JsonProperty("ClientRequestToken") abstract void setClientRequestToken(String clientRequestToken); }
1,716
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/ConnectEventMixin.java
/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; /** * Jackson annotations for ConnectEvent */ public abstract class ConnectEventMixin { // needed because Jackson expects "details" instead of "Details" @JsonProperty("Details") abstract Map<String,?> getDetails(); @JsonProperty("Details") abstract void setDetails(Map<String,?> details); // needed because Jackson expects "name" instead of "Name" @JsonProperty("Name") abstract String getName(); @JsonProperty("Name") abstract void setName(String name); public abstract class DetailsMixin { // needed because Jackson expects "contactData" instead of "ContactData" @JsonProperty("ContactData") abstract Map<String,?> getContactData(); @JsonProperty("ContactData") abstract void setContactData(Map<String,?> contactData); // needed because Jackson expects "parameters" instead of "Parameters" @JsonProperty("Parameters") abstract Map<String,Object> getParameters(); @JsonProperty("Parameters") abstract void setParameters(Map<String,Object> parameters); } public abstract class ContactDataMixin { // needed because Jackson expects "attributes" instead of "Attributes" @JsonProperty("Attributes") abstract Map<String,String> getAttributes(); @JsonProperty("Attributes") abstract void setAttributes(Map<String,String> attributes); // needed because Jackson expects "channel" instead of "Channel" @JsonProperty("Channel") abstract String getChannel(); @JsonProperty("Channel") abstract void setChannel(String channel); // needed because Jackson expects "contactId" instead of "ContactId" @JsonProperty("ContactId") abstract String getContactId(); @JsonProperty("ContactId") abstract void setContactId(String contactId); // needed because Jackson expects "customerEndpoint" instead of "CustomerEndpoint" @JsonProperty("CustomerEndpoint") abstract Map<String,String> getCustomerEndpoint(); @JsonProperty("CustomerEndpoint") abstract void setCustomerEndpoint(Map<String,String> systemEndpoint); // needed because Jackson expects "initialContactId" instead of "InitialContactId" @JsonProperty("InitialContactId") abstract String getInitialContactId(); @JsonProperty("InitialContactId") abstract void setInitialContactId(String initialContactId); // needed because Jackson expects "initiationMethod" instead of "InitiationMethod" @JsonProperty("InitiationMethod") abstract String getInitiationMethod(); @JsonProperty("InitiationMethod") abstract void setInitiationMethod(String initiationMethod); // needed because Jackson expects "instanceARN" instead of "InstanceARN" @JsonProperty("InstanceARN") abstract String getInstanceArn(); @JsonProperty("InstanceARN") abstract void setInstanceArn(String instanceArn); // needed because Jackson expects "previousContactId" instead of "PreviousContactId" @JsonProperty("PreviousContactId") abstract String getPreviousContactId(); @JsonProperty("PreviousContactId") abstract void setPreviousContactId(String previousContactId); // needed because Jackson expects "queue" instead of "Queue" @JsonProperty("Queue") abstract String getQueue(); @JsonProperty("Queue") abstract void setQueue(String queue); // needed because Jackson expects "systemEndpoint" instead of "SystemEndpoint" @JsonProperty("SystemEndpoint") abstract Map<String,String> getSystemEndpoint(); @JsonProperty("SystemEndpoint") abstract void setSystemEndpoint(Map<String,String> systemEndpoint); } public abstract class CustomerEndpointMixin { // needed because Jackson expects "address" instead of "Address" @JsonProperty("Address") abstract String getAddress(); @JsonProperty("Address") abstract void setAddress(String previousContactId); // needed because Jackson expects "type" instead of "Type" @JsonProperty("Type") abstract String getType(); @JsonProperty("Type") abstract void setType(String type); } public abstract class SystemEndpointMixin { // needed because Jackson expects "address" instead of "Address" @JsonProperty("Address") abstract String getAddress(); @JsonProperty("Address") abstract void setAddress(String previousContactId); // needed because Jackson expects "type" instead of "Type" @JsonProperty("Type") abstract String getType(); @JsonProperty("Type") abstract void setType(String type); } }
1,717
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CloudFormationCustomResourceEventMixin.java
/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; public abstract class CloudFormationCustomResourceEventMixin { // needed because jackson expects "requestType" instead of "RequestType" @JsonProperty("RequestType") abstract String getRequestType(); @JsonProperty("RequestType") abstract void setRequestType(String requestType); // needed because jackson expects "serviceToken" instead of "ServiceToken" @JsonProperty("ServiceToken") abstract String getServiceToken(); @JsonProperty("ServiceToken") abstract void setServiceToken(String serviceToken); // needed because jackson expects "physicalResourceId" instead of "PhysicalResourceId" @JsonProperty("PhysicalResourceId") abstract String getPhysicalResourceId(); @JsonProperty("PhysicalResourceId") abstract void setPhysicalResourceId(String physicalResourceId); // needed because jackson expects "responseUrl" instead of "ResponseURL" @JsonProperty("ResponseURL") abstract String getResponseUrl(); @JsonProperty("ResponseURL") abstract void setResponseUrl(String responseUrl); // needed because jackson expects "stackId" instead of "StackId" @JsonProperty("StackId") abstract String getStackId(); @JsonProperty("StackId") abstract void setStackId(String stackId); // needed because jackson expects "requestId" instead of "RequestId" @JsonProperty("RequestId") abstract String getRequestId(); @JsonProperty("RequestId") abstract void setRequestId(String requestId); // needed because jackson expects "logicalResourceId" instead of "LogicalResourceId" @JsonProperty("LogicalResourceId") abstract String getLogicalResourceId(); @JsonProperty("LogicalResourceId") abstract void setLogicalResourceId(String logicalResourceId); // needed because jackson expects "resourceType" instead of "ResourceType" @JsonProperty("ResourceType") abstract String getResourceType(); @JsonProperty("ResourceType") abstract void setResourceType(String resourceType); // needed because jackson expects "resourceProperties" instead of "ResourceProperties" @JsonProperty("ResourceProperties") abstract Map<String, Object> getResourceProperties(); @JsonProperty("ResourceProperties") abstract void setResourceProperties(Map<String, Object> resourceProperties); // needed because jackson expects "oldResourceProperties" instead of "OldResourceProperties" @JsonProperty("OldResourceProperties") abstract Map<String, Object> getOldResourceProperties(); @JsonProperty("OldResourceProperties") abstract void setOldResourceProperties(Map<String, Object> oldResourceProperties); }
1,718
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SQSEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; public abstract class SQSEventMixin { // Needed because Jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); public abstract class SQSMessageMixin { // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); } }
1,719
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/KinesisEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; public abstract class KinesisEventMixin { // needed because Jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); public abstract class RecordMixin { // needed because Jackson cannot distinguish between Enum encryptionType and String encryptionType @JsonProperty("encryptionType") abstract String getEncryptionType(); @JsonProperty("encryptionType") abstract void setEncryptionType(String encryptionType); } }
1,720
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CodeCommitEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; /** * interface with Jackson annotations for CodeCommitEvent */ public abstract class CodeCommitEventMixin { // needed because Jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); public abstract class RecordMixin { // needed because Jackson expects "codeCommit" instead of "codeCommit" @JsonProperty("codecommit") abstract Object getCodeCommit(); @JsonProperty("codecommit") abstract void setCodeCommit(Object codeCommit); // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); // needed because Jackson expects "userIdentityArn" instead of "UserIdentityArn" @JsonProperty("userIdentityARN") abstract String getUserIdentityArn(); @JsonProperty("userIdentityARN") abstract void setUserIdentityArn(String userIdentityArn); } }
1,721
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CloudFrontEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; /** * Mixin for CloudFrontEvent */ public abstract class CloudFrontEventMixin { // needed because jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); }
1,722
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/DynamodbTimeWindowEventMixin.java
/* * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; public abstract class DynamodbTimeWindowEventMixin extends DynamodbEventMixin { // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); }
1,723
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/KinesisTimeWindowEventMixin.java
/* * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; public abstract class KinesisTimeWindowEventMixin extends KinesisEventMixin { // needed because Jackson expects "eventSourceArn" instead of "eventSourceARN" @JsonProperty("eventSourceARN") abstract String getEventSourceArn(); @JsonProperty("eventSourceARN") abstract void setEventSourceArn(String eventSourceArn); }
1,724
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/CloudWatchLogsEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; /** * Interface with Jackson annotations for CloudWatchLogsEvent */ public abstract class CloudWatchLogsEventMixin { // needed because jackson expects "awsLogs" instead of "awslogs" @JsonProperty("awslogs") abstract Object getAwsLogs(); @JsonProperty("awslogs") abstract void setAwsLogs(Object awsLogs); }
1,725
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/mixins/SNSEventMixin.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.mixins; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; public abstract class SNSEventMixin { // needed because Jackson expects "records" instead of "Records" @JsonProperty("Records") abstract List<?> getRecords(); @JsonProperty("Records") abstract void setRecords(List<?> records); public abstract class SNSRecordMixin { // needed because Jackson expects "getSns" instead of "getSNS" @JsonProperty("Sns") abstract Object getSNS(); @JsonProperty("Sns") abstract void setSns(Object sns); } }
1,726
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/OrgJsonSerializer.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.serializers; import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; import java.io.InputStream; import java.io.OutputStream; /** * Interface for event serializers that use org json */ public interface OrgJsonSerializer<T> extends PojoSerializer<T> { /** * @param eventClass event class object * @return OrgJsonSerializer with event type */ OrgJsonSerializer<T> withClass(Class<T> eventClass); /** * @param classLoader to use if the implementation needs to load any classes * @return OrgJsonSerializer with the supplied classLoader */ OrgJsonSerializer<T> withClassLoader(ClassLoader classLoader); /** * defined in PojoSerializer * @param input input stream * @return deserialized object of type T */ T fromJson(InputStream input); /** * defined in PojoSerializer * @param input String input * @return deserialized object of type T */ T fromJson(String input); /** * defined in PojoSerializer * @param value instance of type T to be serialized * @param output OutputStream to serialize object to */ void toJson(T value, OutputStream output); }
1,727
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.serializers; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UncheckedIOException; import java.io.Writer; import java.util.ArrayList; import java.util.List; import com.amazonaws.services.lambda.runtime.serialization.util.Functions; import com.amazonaws.services.lambda.runtime.serialization.util.ReflectUtil; import com.amazonaws.services.lambda.runtime.serialization.util.SerializeUtil; import org.json.JSONArray; import org.json.JSONObject; /** * Serializer for S3 event * NOTE: Because the s3 event class provided by the SDK does not play well with Jackson through a class laoder, * this class uses the low level org json library to serialize and deserialize the event. If new events are added * that do not work well with Jackson or GSON, this is the fallback method that will always work but is more verbose. */ public class S3EventSerializer<T> implements OrgJsonSerializer<T> { /** * As part of https://github.com/aws/aws-lambda-java-libs/issues/74 the `com.amazonaws.services.s3.event.S3EventNotification` * class used by the aws-lambda-java-events library was adapted from the AWSS3JavaClient library into * `com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification`, hence the need to support both classes * in the runtime * @see com.amazonaws.services.lambda.runtime.events.S3Event; * @see com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; * @see com.amazonaws.services.s3.event.S3EventNotification; */ private static final String S3_EVENT_NOTIFICATION_CLASS_V3 = "com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification"; private static final String S3_EVENT_NOTIFICATION_CLASS_V2 = "com.amazonaws.services.s3.event.S3EventNotification"; /** * S3 event class * @see com.amazonaws.services.lambda.runtime.events.S3Event; * @see com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; * @see com.amazonaws.services.s3.event.S3EventNotification; */ private Class<T> eventClass; /** * ClassLoader to be used when loading S3 event classes */ private ClassLoader classLoader; /** * Construct s3Event Serialize from specific s3 event class from user * @param eventClass s3 event class * @see com.amazonaws.services.lambda.runtime.events.S3Event; * @see com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; * @see com.amazonaws.services.s3.event.S3EventNotification; */ @Override public S3EventSerializer<T> withClass(Class<T> eventClass) { this.eventClass = eventClass; return this; } /** * Sets the ClassLoader that will be used to load S3 event classes * @param classLoader - ClassLoader that S3 event classes will be loaded from */ @Override public S3EventSerializer<T> withClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; return this; } /** * deserialize an instance of an s3 event from an input stream * @param input InputStream reading from * @return S3Event Object */ public T fromJson(InputStream input) { return fromJson(SerializeUtil.convertStreamToString(input)); } /** * deserialize an instance of an s3 event from a string * @param input String with JSON * @return s3Event object */ public T fromJson(String input) { JSONObject jsonObject = new JSONObject((input)); return deserializeEvent(jsonObject); } /** * serialize an S3 event object to the output stream * @param value S3 event object * @param output OutputStream serializing to */ public void toJson(T value, OutputStream output) { JSONObject jsonObject; try { // Try to load newer version of S3EventNotification from aws-lambda-java-events v3+ Class eventNotificationRecordClass = SerializeUtil.loadCustomerClass( S3_EVENT_NOTIFICATION_CLASS_V3 + "$S3EventNotificationRecord", classLoader); jsonObject = serializeEvent(eventNotificationRecordClass, value, S3_EVENT_NOTIFICATION_CLASS_V3); } catch (Exception ex) { // Fallback to aws-lambda-java-events pre-v3 (relies on aws-s3-sdk) Class eventNotificationRecordClass = SerializeUtil.loadCustomerClass( S3_EVENT_NOTIFICATION_CLASS_V2 + "$S3EventNotificationRecord", classLoader); jsonObject = serializeEvent(eventNotificationRecordClass, value, S3_EVENT_NOTIFICATION_CLASS_V2); } // Writer in try block so that writer gets flushed and closed try (Writer writer = new OutputStreamWriter(output)) { writer.write(jsonObject.toString()); } catch (IOException e) { throw new UncheckedIOException(e); } } /** * serialize an s3 event * @param eventNotificationRecordClass class holding the s3 event notification record * @param value s3 event object * @param baseClassName base class name * @return JSONObject that contains s3 event */ @SuppressWarnings({"unchecked"}) private JSONObject serializeEvent(Class eventNotificationRecordClass, T value, String baseClassName) { JSONObject jsonObject = new JSONObject(); Functions.R0<List> getRecordsMethod = ReflectUtil.bindInstanceR0(value, "getRecords", true, List.class); jsonObject.put("Records", serializeEventNotificationRecordList(getRecordsMethod.call(), eventNotificationRecordClass, baseClassName)); return jsonObject; } /** * deserialize an s3 event * @param jsonObject JSONObject with s3 data * @return S3 Event Object */ @SuppressWarnings({"unchecked"}) private T deserializeEvent(JSONObject jsonObject) { Functions.R1<T, List> constructor = ReflectUtil.loadConstructor1(eventClass, true, List.class); JSONArray records = jsonObject.optJSONArray("Records"); try { // Try to load newer version of S3EventNotification from aws-lambda-java-events v3+ Class recordClass = SerializeUtil.loadCustomerClass( S3_EVENT_NOTIFICATION_CLASS_V3 + "$S3EventNotificationRecord", classLoader); return (T) constructor.call(deserializeEventNotificationRecordList(records, recordClass, S3_EVENT_NOTIFICATION_CLASS_V3)); } catch (Exception ex) { // Fallback to aws-lambda-java-events pre-v3 (relies on aws-s3-sdk) Class eventNotificationRecordClass = SerializeUtil.loadCustomerClass( S3_EVENT_NOTIFICATION_CLASS_V2 + "$S3EventNotificationRecord", classLoader); return (T) constructor.call(deserializeEventNotificationRecordList(records, eventNotificationRecordClass, S3_EVENT_NOTIFICATION_CLASS_V2)); } } /** * serialize an s3 event notification record list * @param eventNotificationRecords List of event notification records * @param <A> EventNotificationRecord * @return JSONArray with s3 event records */ @SuppressWarnings({"unchecked"}) private <A> JSONArray serializeEventNotificationRecordList(List eventNotificationRecords, Class<A> eventNotificationRecordClass, String baseClassName) { JSONArray jsonRecords = new JSONArray(); for (Object eventNotificationRecord: eventNotificationRecords) { jsonRecords.put(serializeEventNotificationRecord((A) eventNotificationRecord, baseClassName)); } return jsonRecords; } /** * deserialize an s3 event notification record * @param jsonRecords JSONArray of event notification records * @param eventNotificiationRecordClass Event notification record class * @param <A> Event notification record type * @return List of event notification records */ @SuppressWarnings({"unchecked"}) private <A> List<A> deserializeEventNotificationRecordList(JSONArray jsonRecords, Class<A> eventNotificiationRecordClass, String baseClassName) { if (jsonRecords == null) { jsonRecords = new JSONArray(); } Class s3EntityClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3Entity", classLoader); Class s3BucketClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3BucketEntity", classLoader); Class s3ObjectClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3ObjectEntity", classLoader); Class requestParametersClass = SerializeUtil.loadCustomerClass(baseClassName + "$RequestParametersEntity", classLoader); Class responseElementsClass = SerializeUtil.loadCustomerClass(baseClassName + "$ResponseElementsEntity", classLoader); Class userIdentityClass = SerializeUtil.loadCustomerClass(baseClassName + "$UserIdentityEntity", classLoader); List<A> records = new ArrayList<>(); for (int i=0; i < jsonRecords.length(); i++) { records.add((A) deserializeEventNotificationRecord( jsonRecords.getJSONObject(i), eventNotificiationRecordClass, s3EntityClass, s3BucketClass, s3ObjectClass, requestParametersClass, responseElementsClass, userIdentityClass)); } return records; } /** * serialize an s3 event notification record * @param eventNotificationRecord Event notification record * @param <A> Event notification record type * @return JSONObject */ private <A> JSONObject serializeEventNotificationRecord(A eventNotificationRecord, String baseClassName) { // reflect load all the classes we need Class s3EntityClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3Entity", classLoader); Class requestParametersClass = SerializeUtil.loadCustomerClass(baseClassName + "$RequestParametersEntity", classLoader); Class responseElementsClass = SerializeUtil.loadCustomerClass(baseClassName + "$ResponseElementsEntity", classLoader); Class userIdentityClass = SerializeUtil.loadCustomerClass(baseClassName + "$UserIdentityEntity", classLoader); // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 Class dateTimeClass = SerializeUtil.loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.DateTime", classLoader); // serialize object JSONObject jsonObject = new JSONObject(); Functions.R0<String> getAwsRegionMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getAwsRegion", true, String.class); jsonObject.put("awsRegion", getAwsRegionMethod.call()); Functions.R0<String> getEventNameMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventName", true, String.class); jsonObject.put("eventName", getEventNameMethod.call()); Functions.R0<String> getEventSourceMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventSource", true, String.class); jsonObject.put("eventSource", getEventSourceMethod.call()); Functions.R0<?> getEventTimeMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventTime", true, dateTimeClass); jsonObject.put("eventTime", SerializeUtil.serializeDateTime(getEventTimeMethod.call(), classLoader)); Functions.R0<String> getEventVersionMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventVersion", true, String.class); jsonObject.put("eventVersion", getEventVersionMethod.call()); Functions.R0<?> getRequestParametersMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getRequestParameters", true, requestParametersClass); jsonObject.put("requestParameters", serializeRequestParameters(getRequestParametersMethod.call())); Functions.R0<?> getResponseElementsMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getResponseElements", true, responseElementsClass); jsonObject.put("responseElements", serializeResponseElements(getResponseElementsMethod.call())); Functions.R0<?> getS3EntityMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getS3", true, s3EntityClass); jsonObject.put("s3", serializeS3Entity(getS3EntityMethod.call(), baseClassName)); Functions.R0<?> getUserIdentityMethod = ReflectUtil.bindInstanceR0(eventNotificationRecord, "getUserIdentity", true, userIdentityClass); jsonObject.put("userIdentity", serializeUserIdentity(getUserIdentityMethod.call())); return jsonObject; } /** * deserialize an event notification record * NOTE: Yes there are a lot of generics. They are needed for the compiler to correctly associate instance types * with class types * @param jsonObject JSONObject to deserialize from * @param eventNotificationRecordClass event notification record class * @param s3EntityClass s3 entity class * @param s3BucketClass s3 bucket class * @param s3ObjectClass s3 object class * @param requestParametersClass request parameters class * @param responseElementsClass response elements class * @param userIdentityClass user identity class * @param <A> event notification record type * @param <B> s3 entity type * @param <C> s3 bucket type * @param <D> s3 object type * @param <E> request parameters type * @param <F> response elements type * @param <G> user identity class * @return event notification record object */ private <A, B, C, D, E, F, G> A deserializeEventNotificationRecord(JSONObject jsonObject, Class<A> eventNotificationRecordClass, Class<B> s3EntityClass, Class<C> s3BucketClass, Class<D> s3ObjectClass, Class<E> requestParametersClass, Class<F> responseElementsClass, Class<G> userIdentityClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String awsRegion = jsonObject.optString("awsRegion"); String eventName = jsonObject.optString("eventName"); String eventSource = jsonObject.optString("eventSource"); String eventTime = jsonObject.optString("eventTime"); String eventVersion = jsonObject.optString("eventVersion"); E requestParameters = deserializeRequestParameters(jsonObject.optJSONObject("requestParameters"), requestParametersClass); F responseElements = deserializeResponseElements(jsonObject.optJSONObject("responseElements"), responseElementsClass); B s3 = deserializeS3Entity(jsonObject.optJSONObject("s3"), s3EntityClass, s3BucketClass, s3ObjectClass, userIdentityClass); G userIdentity = deserializeUserIdentity(jsonObject.optJSONObject("userIdentity"), userIdentityClass); Functions.R9<A, String, String, String, String, String, E, F, B, G> constructor = ReflectUtil.loadConstuctor9(eventNotificationRecordClass, true, String.class, String.class, String.class, String.class, String.class, requestParametersClass, responseElementsClass, s3EntityClass, userIdentityClass); return constructor.call(awsRegion, eventName, eventSource, eventTime, eventVersion, requestParameters, responseElements, s3, userIdentity); } /** * serialize an s3 entity * @param s3Entity S3 entity object * @param <A> S3 entity type * @return JSONObject with serialized s3 entity */ private <A> JSONObject serializeS3Entity(A s3Entity, String baseClassName) { Class s3BucketClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3BucketEntity", classLoader); Class s3ObjectClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3ObjectEntity", classLoader); JSONObject jsonObject = new JSONObject(); Functions.R0<String> getConfigurationIdMethod = ReflectUtil.bindInstanceR0(s3Entity, "getConfigurationId", true, String.class); jsonObject.put("configurationId", getConfigurationIdMethod.call()); Functions.R0<?> getBucketMethod = ReflectUtil.bindInstanceR0(s3Entity, "getBucket", true, s3BucketClass); jsonObject.put("bucket", serializeS3Bucket(getBucketMethod.call(), baseClassName)); Functions.R0<?> getObjectMethod = ReflectUtil.bindInstanceR0(s3Entity, "getObject", true, s3ObjectClass); jsonObject.put("object", serializeS3Object(getObjectMethod.call())); Functions.R0<String> getSchemaVersionMethod = ReflectUtil.bindInstanceR0(s3Entity, "getS3SchemaVersion", true, String.class); jsonObject.put("s3SchemaVersion", getSchemaVersionMethod.call()); return jsonObject; } /** * deserialize an S3 entity object * @param jsonObject json object to deserialize from * @param s3EntityClass s3 entity class * @param s3BucketClass s3 bucket class * @param s3ObjectClass s3 object class * @param userIdentityClass s3 user identity class * @param <A> s3 entity type * @param <B> s3 bucket type * @param <C> s3 object type * @param <D> s3 user identity type * @return s3 entity object */ private <A, B, C, D> A deserializeS3Entity(JSONObject jsonObject, Class<A> s3EntityClass, Class<B> s3BucketClass, Class<C> s3ObjectClass, Class<D> userIdentityClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String configurationId = jsonObject.optString("configurationId"); B bucket = deserializeS3Bucket(jsonObject.optJSONObject("bucket"), s3BucketClass, userIdentityClass); C object = deserializeS3Object(jsonObject.optJSONObject("object"), s3ObjectClass); String schemaVersion = jsonObject.optString("s3SchemaVersion"); Functions.R4<A, String, B, C, String> constructor = ReflectUtil.loadConstuctor4(s3EntityClass, true, String.class, s3BucketClass, s3ObjectClass, String.class); return constructor.call(configurationId, bucket, object, schemaVersion); } /** * serialize an s3 bucket object * @param s3Bucket S3 bucket object * @param <A> S3 bucket type * @return JSONObject */ private <A> JSONObject serializeS3Bucket(A s3Bucket, String baseClassName) { Class userIdentityClass = SerializeUtil.loadCustomerClass(baseClassName + "$UserIdentityEntity", classLoader); JSONObject jsonObject = new JSONObject(); Functions.R0<String> getNameMethod = ReflectUtil.bindInstanceR0(s3Bucket, "getName", true, String.class); jsonObject.put("name", getNameMethod.call()); Functions.R0<?> getOwnerIdentityMethod = ReflectUtil.bindInstanceR0(s3Bucket, "getOwnerIdentity", true, userIdentityClass); jsonObject.put("ownerIdentity", serializeUserIdentity(getOwnerIdentityMethod.call())); Functions.R0<String> getArnMethod = ReflectUtil.bindInstanceR0(s3Bucket, "getArn", true, String.class); jsonObject.put("arn", getArnMethod.call()); return jsonObject; } /** * deserialize an s3 bucket object * @param jsonObject JSONObject to deserialize from * @param s3BucketClass S3Bucket class * @param userIdentityClass user identity class * @param <A> s3 bucket type * @param <B> user identity type * @return s3 bucket object */ private <A, B> A deserializeS3Bucket(JSONObject jsonObject, Class<A> s3BucketClass, Class<B> userIdentityClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String name = jsonObject.optString("name"); B ownerIdentity = deserializeUserIdentity(jsonObject.optJSONObject("ownerIdentity"), userIdentityClass); String arn = jsonObject.optString("arn"); Functions.R3<A, String, B, String> constructor = ReflectUtil.loadConstuctor3(s3BucketClass, true, String.class, userIdentityClass, String.class); return constructor.call(name, ownerIdentity, arn); } /** * serialize an s3 object * @param s3Object s3Object object * @param <A> s3 object type * @return s3Object object */ private <A> JSONObject serializeS3Object(A s3Object) { JSONObject jsonObject = new JSONObject(); Functions.R0<String> getKeyMethod = ReflectUtil.bindInstanceR0(s3Object, "getKey", true, String.class); jsonObject.put("key", getKeyMethod.call()); Functions.R0<Long> getSizeMethod = ReflectUtil.bindInstanceR0(s3Object, "getSizeAsLong", true, Long.class); jsonObject.put("size", getSizeMethod.call().longValue()); Functions.R0<String> getETagMethod = ReflectUtil.bindInstanceR0(s3Object, "geteTag", true, String.class); jsonObject.put("eTag", getETagMethod.call()); Functions.R0<String> getVersionIdMethod = ReflectUtil.bindInstanceR0(s3Object, "getVersionId", true, String.class); jsonObject.put("versionId", getVersionIdMethod.call()); // legacy s3 event models do not have these methods try { Functions.R0<String> getUrlEncodedKeyMethod = ReflectUtil.bindInstanceR0(s3Object, "getUrlDecodedKey", true, String.class); jsonObject.put("urlDecodedKey", getUrlEncodedKeyMethod.call()); Functions.R0<String> getSequencerMethod = ReflectUtil.bindInstanceR0(s3Object, "getSequencer", true, String.class); jsonObject.put("sequencer", getSequencerMethod.call()); } catch (Exception ignored) {} return jsonObject; } /** * deserialize an s3Object * @param jsonObject json object to deserialize from * @param s3ObjectClass class of s3Object * @param <A> s3Object type * @return s3Object object */ private <A> A deserializeS3Object(JSONObject jsonObject, Class<A> s3ObjectClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String key = jsonObject.optString("key"); Long size = jsonObject.optLong("size"); String eTag = jsonObject.optString("eTag"); String versionId = jsonObject.optString("versionId"); String sequencer = jsonObject.optString("sequencer"); // legacy s3 event uses constructor in catch statement try { Functions.R5<A, String, Long, String, String, String> constructor = ReflectUtil.loadConstuctor5(s3ObjectClass, true, String.class, Long.class, String.class, String.class, String.class); return constructor.call(key, size, eTag, versionId, sequencer); } catch (Exception e) { Functions.R4<A, String, Long, String, String> constructor = ReflectUtil.loadConstuctor4(s3ObjectClass, true, String.class, Long.class, String.class, String.class); return constructor.call(key, size, eTag, versionId); } } /** * serialize an s3 user identity * @param userIdentity user identity object * @param <A> user identity type * @return JSONObject with serialized user identity */ private <A> JSONObject serializeUserIdentity(A userIdentity) { JSONObject jsonObject = new JSONObject(); Functions.R0<String> getPrincipalIdMethod = ReflectUtil.bindInstanceR0(userIdentity, "getPrincipalId", true, String.class); jsonObject.put("principalId", getPrincipalIdMethod.call()); return jsonObject; } /** * deserialize a user identity * @param jsonObject JSONObject to deserialize from * @param userIdentityClass User Identity Class * @param <A> User Identity Type * @return User Identity Object */ private <A> A deserializeUserIdentity(JSONObject jsonObject, Class<A> userIdentityClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String principalId = jsonObject.optString("principalId"); Functions.R1<A, String> constructor = ReflectUtil.loadConstructor1(userIdentityClass, true, String.class); return constructor.call(principalId); } /** * serialize request parameters * @param requestParameters request parameters object * @param <A> request parameters type * @return JSONObject with serialized request parameters */ private <A> JSONObject serializeRequestParameters(A requestParameters) { JSONObject jsonObject = new JSONObject(); Functions.R0<String> getSourceIpMethod = ReflectUtil.bindInstanceR0(requestParameters, "getSourceIPAddress", true, String.class); jsonObject.put("sourceIPAddress", getSourceIpMethod.call()); return jsonObject; } /** * deserialize request parameters * @param jsonObject JSONObject to deserialize from * @param requestParametersClass RequestParameters class * @param <A> RequestParameters type * @return RequestParameters object */ private <A> A deserializeRequestParameters(JSONObject jsonObject, Class<A> requestParametersClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String sourceIpAddress = jsonObject.optString("sourceIPAddress"); Functions.R1<A, String> constructor = ReflectUtil.loadConstructor1(requestParametersClass, true, String.class); return constructor.call(sourceIpAddress); } /** * serialize response elements object * @param responseElements response elements object * @param <A> response elements type * @return JSONObject with serialized responseElements */ private <A> JSONObject serializeResponseElements(A responseElements) { JSONObject jsonObject = new JSONObject(); Functions.R0<String> getXAmzId2Method = ReflectUtil.bindInstanceR0(responseElements, "getxAmzId2", true, String.class); jsonObject.put("x-amz-id-2", getXAmzId2Method.call()); Functions.R0<String> getXAmzRequestId = ReflectUtil.bindInstanceR0(responseElements, "getxAmzRequestId", true, String.class); jsonObject.put("x-amz-request-id", getXAmzRequestId.call()); return jsonObject; } /** * deserialize response elements * @param jsonObject JSONObject deserializing from * @param responseElementsClass response elements class * @param <A> response elements type * @return Response elements object */ private <A> A deserializeResponseElements(JSONObject jsonObject, Class<A> responseElementsClass) { if (jsonObject == null) { jsonObject = new JSONObject(); } String xAmzId2 = jsonObject.optString("x-amz-id-2"); String xAmzRequestId = jsonObject.optString("x-amz-request-id"); Functions.R2<A, String, String> constructor = ReflectUtil.loadConstructor2(responseElementsClass, true, String.class, String.class); return constructor.call(xAmzId2, xAmzRequestId); } }
1,728
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateTimeModule.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.modules; import com.amazonaws.services.lambda.runtime.serialization.util.SerializeUtil; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.datatype.joda.JodaModule; import java.io.IOException; /** * Class that is used to load customer DateTime class */ public class DateTimeModule extends JodaModule { /** * creates a DateTimeModule using customer class loader to pull org.joda.time.DateTime */ public DateTimeModule(ClassLoader classLoader) { // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 Class dateTimeClass = SerializeUtil.loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.DateTime", classLoader); this.addSerializer(dateTimeClass, getSerializer(dateTimeClass, classLoader)); this.addDeserializer(dateTimeClass, getDeserializer(dateTimeClass)); } /** * @param <T> refers to type org.joda.time.DateTime * @param dateTimeClass org.joda.time.DateTime class of the customer * @param classLoader classLoader that's used to load any DateTime classes * @return JsonSerializer with generic DateTime */ private <T> JsonSerializer<T> getSerializer(Class<T> dateTimeClass, ClassLoader classLoader) { return new JsonSerializer<T>() { /** * @param dateTime customer DateTime class * @param jsonGenerator json generator * @param serializerProvider serializer provider * @throws IOException when unable to write * @throws JsonProcessingException when unable to parse */ @Override public void serialize(T dateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeString(SerializeUtil.serializeDateTime(dateTime, classLoader)); } }; } /** * @param dateTimeClass org.joda.time.DateTime class of the customer * @param <T> refers to type org.joda.time.DateTime * @return JsonDeserializer with generic DateTime */ private <T> JsonDeserializer<T> getDeserializer(Class<T> dateTimeClass) { return new JsonDeserializer<T>() { /** * @param jsonParser json parser * @param deserializationContext deserialization context * @return DateTime instance * @throws IOException error when reading * @throws JsonProcessingException error when processing json */ @Override public T deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { return SerializeUtil.deserializeDateTime(dateTimeClass, jsonParser.getValueAsString()); } }; } }
1,729
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events
Create_ds/aws-lambda-java-libs/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateModule.java
/* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.serialization.events.modules; import java.io.IOException; import java.util.Date; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.json.PackageVersion; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.module.SimpleModule; /** * The AWS API represents a date as a double, which specifies the fractional * number of seconds since the epoch. Java's Date, however, represents a date as * a long, which specifies the number of milliseconds since the epoch. This * class is used to translate between these two formats. * * This class is copied from LambdaEventBridgeservice * com.amazon.aws.lambda.stream.ddb.DateModule */ public class DateModule extends SimpleModule { private static final long serialVersionUID = 1L; public static final class Serializer extends JsonSerializer<Date> { @Override public void serialize(Date date, JsonGenerator generator, SerializerProvider serializers) throws IOException { if (date != null) { generator.writeNumber(millisToSeconds(date.getTime())); } } } public static final class Deserializer extends JsonDeserializer<Date> { @Override public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException { double dateSeconds = parser.getValueAsDouble(); if (dateSeconds == 0.0) { return null; } else { return new Date((long) secondsToMillis(dateSeconds)); } } } private static double millisToSeconds(double millis) { return millis / 1000.0; } private static double secondsToMillis(double seconds) { return seconds * 1000.0; } public DateModule() { super(PackageVersion.VERSION); addSerializer(Date.class, new Serializer()); addDeserializer(Date.class, new Deserializer()); } }
1,730
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaLogger.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; import com.amazonaws.services.lambda.runtime.logging.LogLevel; /** * A low level Lambda runtime logger * */ public interface LambdaLogger { /** * Logs a string to AWS CloudWatch Logs * * <p> * Logging will not be done: * <ul> * <li> * If the container is not configured to log to CloudWatch. * </li> * <li> * If the role provided to the function does not have sufficient permissions. * </li> * </ul> * </p> * * @param message A string containing the event to log. */ void log(String message); /** * Logs a byte array to AWS CloudWatch Logs * @param message byte array containing logs */ void log(byte[] message); /** * LogLevel aware logging backend function. * * @param message in String format * @param logLevel */ default void log(String message, LogLevel logLevel) { log(message); } /** * LogLevel aware logging backend function. * * @param message in byte[] format * @param logLevel */ default void log(byte[] message, LogLevel logLevel) { log(message); } }
1,731
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Client.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; /** * Contains information about the client application that invoked the Lambda function. * */ public interface Client { /** * Gets the application's installation id */ String getInstallationId(); /** * Gets the application's title * */ String getAppTitle(); /** * Gets the application's version * */ String getAppVersionName(); /** * Gets the application's version code * */ String getAppVersionCode(); /** * Gets the application's package name */ String getAppPackageName(); }
1,732
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaRuntimeInternal.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; /** * This class is used internally by Lambda Runtime. */ public final class LambdaRuntimeInternal { private LambdaRuntimeInternal() {} private static boolean useLog4jAppender; public static void setUseLog4jAppender(boolean useLog4j) { useLog4jAppender = useLog4j; } public static boolean getUseLog4jAppender() { return useLog4jAppender; } }
1,733
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestHandler.java
package com.amazonaws.services.lambda.runtime; import com.amazonaws.services.lambda.runtime.Context; /** * * Lambda request handlers implement AWS Lambda Function application logic using plain old java objects * as input and output. * * @param <I> The input parameter type * @param <O> The output parameter type */ public interface RequestHandler<I, O> { /** * Handles a Lambda Function request * @param input The Lambda Function input * @param context The Lambda execution environment context object. * @return The Lambda Function output */ O handleRequest(I input, Context context); }
1,734
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/Context.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; /** * * The context object allows you to access useful information available within * the Lambda execution environment * */ public interface Context { /** * Gets the AWS request ID associated with the request. * <p> * This is the same ID returned to the client that called invoke(). This ID * is reused for retries on the same request. * </p> */ String getAwsRequestId(); /** * Gets the CloudWatch log group that this container is configured to log * to. * <p> * The return value may be null: * <ul> * <li> * If the container is not configured to log to CloudWatch.</li> * <li> * If the role provided to the function does not have sufficient * permissions.</li> * </ul> * </p> */ String getLogGroupName(); /** * Gets the CloudWatch log stream that this container is configured to log * to. * <p> * The return value may be null: * <ul> * <li> * If the container is not configured to log to CloudWatch.</li> * <li> * If the role provided to the function does not have sufficient * permissions.</li> * </ul> * </p> */ String getLogStreamName(); /** * Gets the name of the function being executed. * */ String getFunctionName(); /** * Gets the version of the function being executed. * */ String getFunctionVersion(); /** * Gets the function Arn of the resource being invoked. * */ String getInvokedFunctionArn(); /** * Gets information about the Amazon Cognito identity provider when invoked * through the AWS Mobile SDK. It can be null * */ CognitoIdentity getIdentity(); /** * Gets information about the client application and device when invoked * through the AWS Mobile SDK. It can be null. * */ ClientContext getClientContext(); /** * Gets the time remaining for this execution in milliseconds */ int getRemainingTimeInMillis(); /** * Gets the memory size configured for the Lambda function * */ int getMemoryLimitInMB(); /** * Gets the lambda logger instance associated with the context object * */ LambdaLogger getLogger(); }
1,735
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/CustomPojoSerializer.java
/* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Type; /** * Interface required to implement a custom plain old java objects serializer */ public interface CustomPojoSerializer { /** * Deserializes from input stream to plain old java object * @param input input stream * @param type plain old java object type * @return deserialized plain old java object of type T */ <T> T fromJson(InputStream input, Type type); /** * Deserializes from String to plain old java object * @param input input string * @param type plain old java object type * @return deserialized plain old java object of type T */ <T> T fromJson(String input, Type type); /** * Serializes plain old java object to output stream * @param value instance of type T to be serialized * @param output OutputStream to serialize plain old java object to * @param type plain old java object type */ <T> void toJson(T value, OutputStream output, Type type); }
1,736
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/LambdaRuntime.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; import java.io.IOException; public final class LambdaRuntime { private LambdaRuntime() {} private static volatile LambdaLogger logger = new LambdaLogger() { public void log(String message) { System.out.print(message); } public void log(byte[] message) { try { System.out.write(message); } catch (IOException e) { // NOTE: When actually running on AWS Lambda, an IOException would never happen e.printStackTrace(); } } }; /** * Returns the global lambda logger instance * */ public static LambdaLogger getLogger() { return logger; } }
1,737
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/RequestStreamHandler.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; /** * Low-level request-handling interface, Lambda stream request handlers implement AWS Lambda Function application logic * using input and output stream */ public interface RequestStreamHandler { /** * Handles a Lambda Function request * @param input The Lambda Function input stream * @param output The Lambda function output stream * @param context The Lambda execution environment context object. * @throws IOException */ void handleRequest(InputStream input, OutputStream output, Context context) throws IOException; }
1,738
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/CognitoIdentity.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; /** * Provides information related to Amazon Congnito identities. * */ public interface CognitoIdentity { /** * Gets the Amazon Cognito identity ID * */ String getIdentityId(); /** * Gets the Amazon Cognito identity pool ID * */ String getIdentityPoolId(); }
1,739
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/ClientContext.java
/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime; import java.util.Map; /** * * Provides information about client configuration and execution environment. * */ public interface ClientContext { /** * Gets the client information provided by the AWS Mobile SDK * */ Client getClient(); /** * Gets custom values set by the client application * <p> * This map is mutable (and not thread-safe if mutated) * </p> */ Map<String, String> getCustom(); /** * Gets environment information provided by mobile SDK, immutable. * */ Map<String, String> getEnvironment(); }
1,740
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/logging/LogLevel.java
/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.logging; public enum LogLevel { // UNDEFINED log level is used when the legacy LambdaLogger::log(String) function is called // where the loglevel is not defined. In this case we're not filtering the message in the runtime UNDEFINED, TRACE, DEBUG, INFO, WARN, ERROR, FATAL; public static LogLevel fromString(String logLevel) { try { return LogLevel.valueOf(logLevel.toUpperCase()); } catch (Exception e) { throw new IllegalArgumentException( "Invalid log level: '" + logLevel + "' expected one of [TRACE, DEBUG, INFO, WARN, ERROR, FATAL]"); } } }
1,741
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-core/src/main/java/com/amazonaws/services/lambda/runtime/logging/LogFormat.java
/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.logging; public enum LogFormat { JSON, TEXT; public static LogFormat fromString(String logFormat) { try { return LogFormat.valueOf(logFormat.toUpperCase()); } catch (Exception e) { throw new IllegalArgumentException("Invalid log format: '" + logFormat + "' expected one of [JSON, TEXT]"); } } }
1,742
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseTest.java
package com.amazonaws.services.lambda.runtime.events; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponse.ALLOW; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponse.EXECUTE_API_INVOKE; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponse.VERSION_2012_10_17; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponse.allowStatement; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponse.denyStatement; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; public class IamPolicyResponseTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Test public void testAllowStatement() throws JsonProcessingException { IamPolicyResponse iamPolicyResponse = IamPolicyResponse.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponse.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(allowStatement("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"))) .build()) .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyResponses/allow.json")); } @Test public void testDenyStatement() throws JsonProcessingException { IamPolicyResponse iamPolicyResponse = IamPolicyResponse.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponse.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(denyStatement("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"))) .build()) .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyResponses/deny.json")); } @Test public void testStatementWithCondition() throws JsonProcessingException { Map<String, Map<String, Object>> conditions = new HashMap<>(); conditions.put("DateGreaterThan", singletonMap("aws:TokenIssueTime", "2020-01-01T00:00:01Z")); IamPolicyResponse iamPolicyResponse = IamPolicyResponse.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponse.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(IamPolicyResponse.Statement.builder() .withAction(EXECUTE_API_INVOKE) .withEffect(ALLOW) .withResource(singletonList("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*")) .withCondition(conditions) .build())) .build()) .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyResponses/allow-with-condition.json")); } private String readResource(String name) { Path filePath = Paths.get("src", "test", "resources", name); byte[] bytes = new byte[0]; try { bytes = Files.readAllBytes(filePath); } catch (IOException e) { e.printStackTrace(); } return new String(bytes, StandardCharsets.UTF_8); } }
1,743
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseV1Test.java
package com.amazonaws.services.lambda.runtime.events; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponseV1.ALLOW; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponseV1.EXECUTE_API_INVOKE; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponseV1.VERSION_2012_10_17; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponseV1.allowStatement; import static com.amazonaws.services.lambda.runtime.events.IamPolicyResponseV1.denyStatement; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; public class IamPolicyResponseV1Test { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Test public void testAllowStatement() throws JsonProcessingException { IamPolicyResponseV1 iamPolicyResponse = IamPolicyResponseV1.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponseV1.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(allowStatement("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"))) .build()) .withUsageIdentifierKey("123ABC") .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyV1Responses/allow.json")); } @Test public void testDenyStatement() throws JsonProcessingException { IamPolicyResponseV1 iamPolicyResponse = IamPolicyResponseV1.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponseV1.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(denyStatement("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*"))) .build()) .withUsageIdentifierKey("123ABC") .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyV1Responses/deny.json")); } @Test public void testStatementWithCondition() throws JsonProcessingException { Map<String, Map<String, Object>> conditions = new HashMap<>(); conditions.put("DateGreaterThan", singletonMap("aws:TokenIssueTime", "2020-01-01T00:00:01Z")); IamPolicyResponseV1 iamPolicyResponse = IamPolicyResponseV1.builder() .withPrincipalId("me") .withPolicyDocument(IamPolicyResponseV1.PolicyDocument.builder() .withVersion(VERSION_2012_10_17) .withStatement(singletonList(IamPolicyResponseV1.Statement.builder() .withAction(EXECUTE_API_INVOKE) .withEffect(ALLOW) .withResource(singletonList("arn:aws:execute-api:eu-west-1:123456789012:1234abc/$deafult/*/*")) .withCondition(conditions) .build())) .build()) .withUsageIdentifierKey("123ABC") .build(); String json = OBJECT_MAPPER.writeValueAsString(iamPolicyResponse); assertThatJson(json).isEqualTo(readResource("iamPolicyV1Responses/allow-with-condition.json")); } private String readResource(String name) { Path filePath = Paths.get("src", "test", "resources", name); byte[] bytes = new byte[0]; try { bytes = Files.readAllBytes(filePath); } catch (IOException e) { e.printStackTrace(); } return new String(bytes, StandardCharsets.UTF_8); } }
1,744
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java
package com.amazonaws.services.lambda.runtime.events; import org.junit.jupiter.api.Test; import java.time.Instant; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; public class APIGatewayV2CustomAuthorizerEventTest { private static final long TIME_EPOCH = 1601306426515L; private static final String TIME = "28/Sep/2020:15:14:43 +0000"; @Test public void testEpochLongAsAnInstant() { APIGatewayV2CustomAuthorizerEvent customAuthorizerEvent = APIGatewayV2CustomAuthorizerEvent.builder() .withRequestContext(APIGatewayV2CustomAuthorizerEvent.RequestContext.builder() .withTimeEpoch(TIME_EPOCH) .build()) .build(); assertEquals(Instant.ofEpochMilli(1601306426515L), customAuthorizerEvent.getRequestContext().getTimeEpoch()); } @Test public void testTimeStringAsDateTime() { APIGatewayV2CustomAuthorizerEvent customAuthorizerEvent = APIGatewayV2CustomAuthorizerEvent.builder() .withRequestContext(APIGatewayV2CustomAuthorizerEvent.RequestContext.builder() .withTime(TIME) .build()) .build(); assertNotNull(customAuthorizerEvent.getRequestContext().getTime()); } }
1,745
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/HttpUtils.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class HttpUtils { private static final String DEFAULT_ENCODING = "UTF-8"; /** * Regex which matches any of the sequences that we need to fix up after * URLEncoder.encode(). */ private static final Pattern ENCODED_CHARACTERS_PATTERN; static { StringBuilder pattern = new StringBuilder() .append(Pattern.quote("+")) .append("|") .append(Pattern.quote("*")) .append("|") .append(Pattern.quote("%7E")) .append("|") .append(Pattern.quote("%2F")); ENCODED_CHARACTERS_PATTERN = Pattern.compile(pattern.toString()); } /** * Encode a string for use in the path of a URL; uses URLEncoder.encode, * (which encodes a string for use in the query portion of a URL), then * applies some postfilters to fix things up per the RFC. Can optionally * handle strings which are meant to encode a path (ie include '/'es * which should NOT be escaped). * * @param value the value to encode * @param path true if the value is intended to represent a path * @return the encoded value */ public static String urlEncode(final String value, final boolean path) { if (value == null) { return ""; } try { String encoded = URLEncoder.encode(value, DEFAULT_ENCODING); Matcher matcher = ENCODED_CHARACTERS_PATTERN.matcher(encoded); StringBuffer buffer = new StringBuffer(encoded.length()); while (matcher.find()) { String replacement = matcher.group(0); if ("+".equals(replacement)) { replacement = "%20"; } else if ("*".equals(replacement)) { replacement = "%2A"; } else if ("%7E".equals(replacement)) { replacement = "~"; } else if (path && "%2F".equals(replacement)) { replacement = "/"; } matcher.appendReplacement(buffer, replacement); } matcher.appendTail(buffer); return buffer.toString(); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } }
1,746
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/models/s3/S3EventNotificationTest.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events.models.s3; import com.amazonaws.services.lambda.runtime.events.HttpUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; public class S3EventNotificationTest { private List<String> KEYS_REQUIRING_URL_ENCODE = Arrays.asList("foo bar.jpg", "foo/bar.csv", "foo<>bar"); @Test public void testGetUrlDecodedKey() { for (String testKey : KEYS_REQUIRING_URL_ENCODE) { String urlEncoded = HttpUtils.urlEncode(testKey, false); S3EventNotification.S3ObjectEntity entity = new S3EventNotification.S3ObjectEntity( urlEncoded, 1L, "E-Tag", "versionId"); Assertions.assertEquals(testKey, entity.getUrlDecodedKey()); } } }
1,747
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ApplicationLoadBalancerRequestEvent.java
package com.amazonaws.services.lambda.runtime.events; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Class to represent the request event from Application Load Balancer. * * @see <a href="https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html">Using AWS Lambda with an Application Load Balancer</a> * * @author msailes <msailes@amazon.co.uk> */ @NoArgsConstructor @Data public class ApplicationLoadBalancerRequestEvent implements Serializable, Cloneable { @NoArgsConstructor @Data public static class Elb implements Serializable, Cloneable { private String targetGroupArn; } @NoArgsConstructor @Data public static class RequestContext implements Serializable, Cloneable { private Elb elb; } private RequestContext requestContext; private String httpMethod; private String path; private Map<String, String> queryStringParameters; private Map<String, List<String>> multiValueQueryStringParameters; private Map<String, String> headers; private Map<String, List<String>> multiValueHeaders; private String body; private boolean isBase64Encoded; }
1,748
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/DynamodbTimeWindowEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import com.amazonaws.services.lambda.runtime.events.models.TimeWindow; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Represents an Amazon Dynamodb event when using <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows">time windows</a>. */ @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public class DynamodbTimeWindowEvent extends DynamodbEvent implements Serializable, Cloneable { private static final long serialVersionUID = -5449871161108629510L; /** * Time window for the records in the event. */ private TimeWindow window; /** * State being built up to this invoke in the time window. */ private Map<String, String> state; /** * Shard id of the records */ private String shardId; /** * Dynamodb stream arn. */ private String eventSourceArn; /** * Set to true for the last invoke of the time window. Subsequent invoke will start a new time window along with a fresh state. */ private Boolean isFinalInvokeForWindow; /** * Set to true if window is terminated prematurely. Subsequent invoke will continue the same window with a fresh state. */ private Boolean isWindowTerminatedEarly; @Builder(setterPrefix = "with") public DynamodbTimeWindowEvent( final List<DynamodbStreamRecord> records, final TimeWindow window, final Map<String, String> state, final String shardId, final String eventSourceArn, final Boolean isFinalInvokeForWindow, final Boolean isWindowTerminatedEarly) { this.setRecords(records); this.window = window; this.state = state; this.shardId = shardId; this.eventSourceArn = eventSourceArn; this.isFinalInvokeForWindow = isFinalInvokeForWindow; this.isWindowTerminatedEarly = isWindowTerminatedEarly; } }
1,749
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SQSBatchResponse.java
/* * Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * Function response type to report batch item failures for {@link SQSEvent}. */ @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public class SQSBatchResponse implements Serializable { private static final long serialVersionUID = 5075170615239078773L; /** * A list of messageIds that failed processing. These messageIds will be retried. */ private List<BatchItemFailure> batchItemFailures; @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public static class BatchItemFailure implements Serializable { private static final long serialVersionUID = 40727862494377907L; /** * MessageId that failed processing */ String itemIdentifier; } }
1,750
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/LexEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.Map; /** * represents a Lex event */ public class LexEvent implements Serializable, Cloneable { private static final long serialVersionUID = 8660021082133163891L; private String messageVersion; private String invocationSource; private String userId; private Map<String, String> sessionAttributes; private String outputDialogMode; private CurrentIntent currentIntent; private Bot bot; /** * Represents a Lex bot */ public class Bot implements Serializable, Cloneable { private static final long serialVersionUID = -5764739951985883358L; private String name; private String alias; private String version; /** * default constructor */ public Bot() {} /** * @return name of bot */ public String getName() { return this.name; } /** * @param name name of bot */ public void setName(String name) { this.name = name; } /** * @param name name of bot * @return Bot object */ public Bot withName(String name) { setName(name); return this; } /** * @return alias of bot */ public String getAlias() { return this.alias; } /** * @param alias alias of bot */ public void setAlias(String alias) { this.alias = alias; } public Bot withAlias(String alias) { setAlias(alias); return this; } /** * @return version of bot */ public String getVersion() { return this.version; } /** * @param version set version of bot */ public void setVersion(String version) { this.version = version; } /** * @param version version of bot * @return Bot */ public Bot withVersion(String version) { setVersion(version); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("name: ").append(getName()).append(","); if (getAlias() != null) sb.append("alias: ").append(getAlias()).append(","); if (getVersion() != null) sb.append("version: ").append(getVersion()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Bot == false) return false; Bot other = (Bot) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getAlias() == null ^ this.getAlias() == null) return false; if (other.getAlias() != null && other.getAlias().equals(this.getAlias()) == false) return false; if (other.getVersion() == null ^ this.getVersion() == null) return false; if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getAlias() == null) ? 0 : getAlias().hashCode()); hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); return hashCode; } @Override public Bot clone() { try { return (Bot) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * models CurrentIntent of Lex event */ public class CurrentIntent implements Serializable, Cloneable { private static final long serialVersionUID = 7405357938118538229L; private String name; private Map<String, String> slots; private String confirmationStatus; /** * default constructor */ public CurrentIntent() {} /** * @return name of bot */ public String getName() { return this.name; } /** * @param name name of bot */ public void setName(String name) { this.name = name; } /** * @param name name of intent * @return Current Intent */ public CurrentIntent withName(String name) { setName(name); return this; } /** * @return map of slots */ public Map<String, String> getSlots() { return this.slots; } /** * @param slots map of slots */ public void setSlots(Map<String, String> slots) { this.slots = slots; } /** * @param slots slots in CurrentIntent * @return CurrentIntent */ public CurrentIntent withSlots(Map<String, String> slots) { setSlots(slots); return this; } /** * @return confirmation status */ public String getConfirmationStatus() { return this.confirmationStatus; } /** * @param confirmationStatus confirmation status */ public void setConfirmationStatus(String confirmationStatus) { this.confirmationStatus = confirmationStatus; } /** * @param confirmationStatus confirmation status * @return CurrentIntent */ public CurrentIntent withConfirmationStatus(String confirmationStatus) { setConfirmationStatus(confirmationStatus); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("name: ").append(getName()).append(","); if (getSlots() != null) sb.append("slots: ").append(getSlots().toString()).append(","); if (getConfirmationStatus() != null) sb.append("confirmationStatus: ").append(getConfirmationStatus()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CurrentIntent == false) return false; CurrentIntent other = (CurrentIntent) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getSlots() == null ^ this.getSlots() == null) return false; if (other.getSlots() != null && other.getSlots().equals(this.getSlots()) == false) return false; if (other.getConfirmationStatus() == null ^ this.getConfirmationStatus() == null) return false; if (other.getConfirmationStatus() != null && other.getConfirmationStatus().equals(this.getConfirmationStatus()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getSlots() == null) ? 0 : getSlots().hashCode()); hashCode = prime * hashCode + ((getConfirmationStatus() == null) ? 0 : getConfirmationStatus().hashCode()); return hashCode; } @Override public CurrentIntent clone() { try { return (CurrentIntent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public LexEvent() {} /** * @return message version */ public String getMessageVersion() { return this.messageVersion; } /** * @param messageVersion message version */ public void setMessageVersion(String messageVersion) { this.messageVersion = messageVersion; } /** * @param messageVersion message version * @return LexEvent */ public LexEvent withMessageVersion(String messageVersion) { setMessageVersion(messageVersion); return this; } /** * @return source of invocation */ public String getInvocationSource() { return this.invocationSource; } /** * @param invocationSource source of invocation */ public void setInvocationSource(String invocationSource) { this.invocationSource = invocationSource; } /** * @param invocationSource invokation source * @return LexEvent */ public LexEvent withInvocationSource(String invocationSource) { setInvocationSource(invocationSource); return this; } /** * @return user id */ public String getUserId() { return this.userId; } /** * @param userId user id */ public void setUserId(String userId) { this.userId = userId; } /** * @param userId user id * @return LexEvent */ public LexEvent withUserId(String userId) { setUserId(userId); return this; } /** * @return session attributes */ public Map<String, String> getSessionAttributes() { return this.sessionAttributes; } /** * @param sessionAttributes session attributes */ public void setSessionAttributes(Map<String, String> sessionAttributes) { this.sessionAttributes = sessionAttributes; } /** * @param sessionAttributes session attributes * @return LexEvent */ public LexEvent withSessionAttributes(Map<String, String> sessionAttributes) { setSessionAttributes(sessionAttributes); return this; } /** * @return output dialog mode */ public String getOutputDialogMode() { return this.outputDialogMode; } /** * @param outputDialogMode output dialog mode */ public void setOutputDialogMode(String outputDialogMode) { this.outputDialogMode = outputDialogMode; } /** * @param outputDialogMode output dialog mode * @return LexEvent */ public LexEvent withOutputDialogMode(String outputDialogMode) { setOutputDialogMode(outputDialogMode); return this; } /** * @return current intent */ public CurrentIntent getCurrentIntent() { return this.currentIntent; } /** * @param currentIntent current intent */ public void setCurrentIntent(CurrentIntent currentIntent) { this.currentIntent = currentIntent; } /** * @param currentIntent current intent * @return LexEvent */ public LexEvent withCurrentIntent(CurrentIntent currentIntent) { setCurrentIntent(currentIntent); return this; } /** * @return bot */ public Bot getBot() { return this.bot; } /** * @param bot Bot object of Lex message */ public void setBot(Bot bot) { this.bot = bot; } /** * @param bot Bot object of message * @return LexEvent */ public LexEvent withBot(Bot bot) { setBot(bot); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getMessageVersion() != null) sb.append("messageVersion: ").append(getMessageVersion()).append(","); if (getInvocationSource() != null) sb.append("invocationSource: ").append(getInvocationSource()).append(","); if (getUserId() != null) sb.append("userId: ").append(getUserId()).append(","); if (getSessionAttributes() != null) sb.append("sessionAttributes: ").append(getSessionAttributes().toString()).append(","); if (getOutputDialogMode() != null) sb.append("outputDialogMode: ").append(getOutputDialogMode()).append(","); if (getCurrentIntent() != null) sb.append("currentIntent: ").append(getCurrentIntent().toString()).append(","); if (getBot() != null) sb.append("bot: ").append(getBot().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof LexEvent == false) return false; LexEvent other = (LexEvent) obj; if (other.getMessageVersion() == null ^ this.getMessageVersion() == null) return false; if (other.getMessageVersion() != null && other.getMessageVersion().equals(this.getMessageVersion()) == false) return false; if (other.getInvocationSource() == null ^ this.getInvocationSource() == null) return false; if (other.getInvocationSource() != null && other.getInvocationSource().equals(this.getInvocationSource()) == false) return false; if (other.getUserId() == null ^ this.getUserId() == null) return false; if (other.getUserId() != null && other.getUserId().equals(this.getUserId()) == false) return false; if (other.getSessionAttributes() == null ^ this.getSessionAttributes() == null) return false; if (other.getSessionAttributes() != null && other.getSessionAttributes().equals(this.getSessionAttributes()) == false) return false; if (other.getOutputDialogMode() == null ^ this.getOutputDialogMode() == null) return false; if (other.getOutputDialogMode() != null && other.getOutputDialogMode().equals(this.getOutputDialogMode()) == false) return false; if (other.getCurrentIntent() == null ^ this.getCurrentIntent() == null) return false; if (other.getCurrentIntent() != null && other.getCurrentIntent().equals(this.getCurrentIntent()) == false) return false; if (other.getBot() == null ^ this.getBot() == null) return false; if (other.getBot() != null && other.getBot().equals(this.getBot()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getMessageVersion() == null) ? 0 : getMessageVersion().hashCode()); hashCode = prime * hashCode + ((getInvocationSource() == null) ? 0 : getInvocationSource().hashCode()); hashCode = prime * hashCode + ((getUserId() == null) ? 0 : getUserId().hashCode()); hashCode = prime * hashCode + ((getSessionAttributes() == null) ? 0 : getSessionAttributes().hashCode()); hashCode = prime * hashCode + ((getOutputDialogMode() == null) ? 0 : getOutputDialogMode().hashCode()); hashCode = prime * hashCode + ((getCurrentIntent() == null) ? 0 : getCurrentIntent().hashCode()); hashCode = prime * hashCode + ((getBot() == null) ? 0 : getBot().hashCode()); return hashCode; } @Override public LexEvent clone() { try { return (LexEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,751
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisTimeWindowEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import com.amazonaws.services.lambda.runtime.events.models.TimeWindow; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Represents an Amazon Kinesis event when using <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-windows">time windows</a>. */ @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = true) public class KinesisTimeWindowEvent extends KinesisEvent implements Serializable, Cloneable { private static final long serialVersionUID = 8926430039233062266L; /** * Time window for the records in the event. */ private TimeWindow window; /** * State being built up to this invoke in the time window. */ private Map<String, String> state; /** * Shard id of the records */ private String shardId; /** * Kinesis stream or consumer arn. */ private String eventSourceArn; /** * Set to true for the last invoke of the time window. Subsequent invoke will start a new time window along with a fresh state. */ private Boolean isFinalInvokeForWindow; /** * Set to true if window is terminated prematurely. Subsequent invoke will continue the same window with a fresh state. */ private Boolean isWindowTerminatedEarly; @Builder(setterPrefix = "with") public KinesisTimeWindowEvent( final List<KinesisEventRecord> records, final TimeWindow window, final Map<String, String> state, final String shardId, final String eventSourceArn, final Boolean isFinalInvokeForWindow, final Boolean isWindowTerminatedEarly) { this.setRecords(records); this.window = window; this.state = state; this.shardId = shardId; this.eventSourceArn = eventSourceArn; this.isFinalInvokeForWindow = isFinalInvokeForWindow; this.isWindowTerminatedEarly = isWindowTerminatedEarly; } }
1,752
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CloudWatchLogsEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; /** * Class representing CloudWatchLogs event (callback when cloud watch logs something) */ public class CloudWatchLogsEvent implements Serializable, Cloneable { private static final long serialVersionUID = -1617470828168156271L; private AWSLogs awsLogs; /** * Represents AWSLogs object in CloudWatch Evenet */ public static class AWSLogs implements Serializable, Cloneable { private static final long serialVersionUID = -7793438350437169987L; private String data; /** * default constructor */ public AWSLogs() {} /** * @return String with data */ public String getData() { return this.data; } /** * @param data String with log data */ public void setData(String data) { this.data = data; } /** * @param data String with log data * @return */ public AWSLogs withData(String data) { setData(data); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getData() != null) sb.append("data: ").append(getData()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AWSLogs == false) return false; AWSLogs other = (AWSLogs) obj; if (other.getData() == null ^ this.getData() == null) return false; if (other.getData() != null && other.getData().equals(this.getData()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode()); return hashCode; } @Override public AWSLogs clone() { try { return (AWSLogs) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public CloudWatchLogsEvent() {} /** * @return AWSLogs object */ public AWSLogs getAwsLogs() { return this.awsLogs; } /** * @param awsLogs AWSLogs object */ public void setAwsLogs(AWSLogs awsLogs) { this.awsLogs = awsLogs; } /** * @param awsLogs AWSLogs object * @return */ public CloudWatchLogsEvent withAwsLogs(AWSLogs awsLogs) { setAwsLogs(awsLogs); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAwsLogs() != null) sb.append("awslogs: ").append(getAwsLogs().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CloudWatchLogsEvent == false) return false; CloudWatchLogsEvent other = (CloudWatchLogsEvent) obj; if (other.getAwsLogs() == null ^ this.getAwsLogs() == null) return false; if (other.getAwsLogs() != null && other.getAwsLogs().equals(this.getAwsLogs()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAwsLogs() == null) ? 0 : getAwsLogs().hashCode()); return hashCode; } @Override public CloudWatchLogsEvent clone() { try { return (CloudWatchLogsEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,753
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolDefineAuthChallengeEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Define Auth Challenge Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html">Define Auth Challenge Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolDefineAuthChallengeEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolDefineAuthChallengeEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the define auth challenge trigger. */ private Map<String, String> clientMetadata; private ChallengeResult[] session; /** * A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client. * A value of true means that the user id (user name, email address, etc.) did not match any existing users. */ private boolean userNotFound; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, ChallengeResult[] session, boolean userNotFound) { super(userAttributes); this.clientMetadata = clientMetadata; this.session = session; this.userNotFound = userNotFound; } } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class ChallengeResult { /** * The challenge type. One of: CUSTOM_CHALLENGE, SRP_A, PASSWORD_VERIFIER, SMS_MFA, DEVICE_SRP_AUTH, DEVICE_PASSWORD_VERIFIER, or ADMIN_NO_SRP_AUTH. */ private String challengeName; /** * Set to true if the user successfully completed the challenge, or false otherwise. */ private boolean challengeResult; /** * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE. */ private String challengeMetadata; } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class Response { /** * Name of the next challenge, if you want to present a new challenge to your user. */ private String challengeName; /** * Set to true if you determine that the user has been sufficiently authenticated by completing the challenges, or false otherwise. */ private boolean issueTokens; /** * Set to true if you want to terminate the current authentication process, or false otherwise. */ private boolean failAuthentication; } }
1,754
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyResponseEvent.java
package com.amazonaws.services.lambda.runtime.events; /** * @deprecated * This class is for responding to API Gateway WebSocket events, and has been renamed explicitly as {@link APIGatewayV2WebSocketResponse} * To response to API Gateway's HTTP API Events, use {@link APIGatewayV2HTTPResponse} */ @Deprecated public class APIGatewayV2ProxyResponseEvent extends APIGatewayV2WebSocketResponse {}
1,755
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2ProxyRequestEvent.java
package com.amazonaws.services.lambda.runtime.events; /** * @deprecated * This class is for use with API Gateway WebSockets, and has been renamed explicitly as {@link APIGatewayV2WebSocketEvent} * To integrate with API Gateway's HTTP API Events, use one of: * * {@link APIGatewayV2HTTPEvent} (payload version 2.0) * * {@link APIGatewayProxyRequestEvent} (payload version 1.0) */ @Deprecated() public class APIGatewayV2ProxyRequestEvent extends APIGatewayV2WebSocketEvent {}
1,756
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisAnalyticsInputPreprocessingResponse.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.List; /** * Response model for Kinesis Analytics Preprocessing Lambda function. */ public class KinesisAnalyticsInputPreprocessingResponse implements Serializable { public enum Result { /** * Indicates that processing of this item succeeded. */ Ok, /** * Indicate that the processing of this item failed */ ProcessingFailed, /** * Indicates that this item should be silently dropped */ Dropped } private static final long serialVersionUID = -4651154757825854471L; public List<Record> records; public KinesisAnalyticsInputPreprocessingResponse() { super(); } public KinesisAnalyticsInputPreprocessingResponse(List<Record> records) { super(); this.records = records; } public List<Record> getRecords() { return records; } public void setRecords(List<Record> records) { this.records = records; } public static class Record implements Serializable { private static final long serialVersionUID = -1583558686451236985L; public String recordId; public Result result; public Record() { super(); } public Record(String recordId, Result result, ByteBuffer data) { super(); this.recordId = recordId; this.result = result; this.data = data; } public ByteBuffer data; public String getRecordId() { return recordId; } public void setRecordId(String recordId) { this.recordId = recordId; } public Result getResult() { return result; } public void setResult(Result result) { this.result = result; } public ByteBuffer getData() { return data; } public void setData(ByteBuffer data) { this.data = data; } } }
1,757
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCustomMessageEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Custom Message Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html">Custom Message Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolCustomMessageEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolCustomMessageEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the custom message trigger. */ private Map<String, String> clientMetadata; /** * A string for you to use as the placeholder for the verification code in the custom message. */ private String codeParameter; /** * The username parameter. It is a required request parameter for the admin create user flow. */ private String usernameParameter; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, String codeParameter, String usernameParameter) { super(userAttributes); this.clientMetadata = clientMetadata; this.codeParameter = codeParameter; this.usernameParameter = usernameParameter; } } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class Response { /** * The custom SMS message to be sent to your users. Must include the codeParameter value received in the request. */ private String smsMessage; /** * The custom email message to be sent to your users. Must include the codeParameter value received in the request. */ private String emailMessage; /** * The subject line for the custom message. */ private String emailSubject; } }
1,758
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KafkaEvent.java
/* * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ 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; @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") /** Represents a Kafka Event. **/ public class KafkaEvent { private Map<String, List<KafkaEventRecord>> records; private String eventSource; private String eventSourceArn; private String bootstrapServers; @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public static class KafkaEventRecord { private String topic; private int partition; private long offset; private long timestamp; private String timestampType; private String key; private String value; private List<Map<String, byte[]>> headers; } @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public static class TopicPartition { private String topic; private int partition; @Override public String toString() { //Kafka also uses '-' for toString() return topic + "-" + partition; } } }
1,759
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolCreateAuthChallengeEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Create Auth Challenge Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html">Create Auth Challenge Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolCreateAuthChallengeEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolCreateAuthChallengeEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the create auth challenge trigger. */ private Map<String, String> clientMetadata; /** * The name of the new challenge. */ private String challengeName; private ChallengeResult[] session; /** * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client. */ private boolean userNotFound; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, String challengeName, ChallengeResult[] session, boolean userNotFound) { super(userAttributes); this.clientMetadata = clientMetadata; this.session = session; this.userNotFound = userNotFound; this.challengeName = challengeName; } } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class ChallengeResult { /** * The challenge type. One of: "CUSTOM_CHALLENGE", "PASSWORD_VERIFIER", "SMS_MFA", "DEVICE_SRP_AUTH", "DEVICE_PASSWORD_VERIFIER", or "ADMIN_NO_SRP_AUTH". */ private String challengeName; /** * Set to true if the user successfully completed the challenge, or false otherwise. */ private boolean challengeResult; /** * Your name for the custom challenge. Used only if challengeName is CUSTOM_CHALLENGE. */ private String challengeMetadata; } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Response { /** * One or more key-value pairs for the client app to use in the challenge to be presented to the user. * Contains the question that is presented to the user. */ private Map<String, String> publicChallengeParameters; /** * Contains the valid answers for the question in publicChallengeParameters */ private Map<String, String> privateChallengeParameters; /** * Your name for the custom challenge, if this is a custom challenge. */ private String challengeMetadata; } }
1,760
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisAnalyticsStreamsInputPreprocessingEvent.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.List; /** * Event model for pre-processing Kinesis Streams records through Kinesis * Analytics Lambda pre-processing function. */ public class KinesisAnalyticsStreamsInputPreprocessingEvent implements Serializable { private static final long serialVersionUID = 1770320710876513596L; public String invocationId; public String applicationArn; public String streamArn; public List<Record> records; public KinesisAnalyticsStreamsInputPreprocessingEvent() { } public KinesisAnalyticsStreamsInputPreprocessingEvent(String invocationId, String applicationArn, String streamArn, List<Record> records) { super(); this.invocationId = invocationId; this.applicationArn = applicationArn; this.streamArn = streamArn; this.records = records; } public String getInvocationId() { return invocationId; } public void setInvocationId(String invocationId) { this.invocationId = invocationId; } public String getApplicationArn() { return applicationArn; } public void setApplicationArn(String applicationArn) { this.applicationArn = applicationArn; } public String getStreamArn() { return streamArn; } public void setStreamArn(String streamArn) { this.streamArn = streamArn; } public List<Record> getRecords() { return records; } public void setRecords(List<Record> records) { this.records = records; } public static class Record implements Serializable { private static final long serialVersionUID = -2070268774061223434L; public String recordId; public KinesisStreamRecordMetadata kinesisStreamRecordMetadata; public ByteBuffer data; public Record() { } public Record(String recordId, KinesisStreamRecordMetadata kinesisStreamRecordMetadata, ByteBuffer data) { super(); this.recordId = recordId; this.kinesisStreamRecordMetadata = kinesisStreamRecordMetadata; this.data = data; } public String getRecordId() { return recordId; } public void setRecordId(String recordId) { this.recordId = recordId; } public ByteBuffer getData() { return data; } public void setData(ByteBuffer data) { this.data = data; } public KinesisStreamRecordMetadata getKinesisStreamRecordMetadata() { return kinesisStreamRecordMetadata; } public void setKinesisStreamRecordMetadata(KinesisStreamRecordMetadata kinesisStreamRecordMetadata) { this.kinesisStreamRecordMetadata = kinesisStreamRecordMetadata; } public static class KinesisStreamRecordMetadata implements Serializable { private static final long serialVersionUID = 8831719215562345916L; public String sequenceNumber; public String partitionKey; public String shardId; public Long approximateArrivalTimestamp; public KinesisStreamRecordMetadata() { } public KinesisStreamRecordMetadata(String sequenceNumber, String partitionKey, String shardId, Long approximateArrivalTimestamp) { super(); this.sequenceNumber = sequenceNumber; this.partitionKey = partitionKey; this.shardId = shardId; this.approximateArrivalTimestamp = approximateArrivalTimestamp; } public String getSequenceNumber() { return sequenceNumber; } public void setSequenceNumber(String sequenceNumber) { this.sequenceNumber = sequenceNumber; } public String getPartitionKey() { return partitionKey; } public void setPartitionKey(String partitionKey) { this.partitionKey = partitionKey; } public String getShardId() { return shardId; } public void setShardId(String shardId) { this.shardId = shardId; } public Long getApproximateArrivalTimestamp() { return approximateArrivalTimestamp; } public void setApproximateArrivalTimestamp(Long approximateArrivalTimestamp) { this.approximateArrivalTimestamp = approximateArrivalTimestamp; } } } }
1,761
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CloudFrontEvent.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Class that represents a CloudFront event */ public class CloudFrontEvent implements Serializable, Cloneable { private static final long serialVersionUID = -7169297388214516660L; private List<Record> records; /** * class that represents a header */ public static class Header implements Serializable, Cloneable { private static final long serialVersionUID = 7041042740552686996L; private String key; private String value; /** * default constructor */ public Header() {} /** * @return key value of header */ public String getKey() { return this.key; } /** * @param key value of header */ public void setKey(String key) { this.key = key; } /** * @param key value of header * @return Header object */ public Header withKey(String key) { setKey(key); return this; } /** * @return value of header value */ public String getValue() { return this.value; } /** * @param value of header value */ public void setValue(String value) { this.value = value; } /** * @param value of header value * @return Header object */ public Header withValue(String value) { setValue(value); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKey() != null) sb.append("key: ").append(getKey()).append(","); if (getValue() != null) sb.append("value: ").append(getValue()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Header == false) return false; Header other = (Header) obj; if (other.getKey() == null ^ this.getKey() == null) return false; if (other.getKey() != null && other.getKey().equals(this.getKey()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); return hashCode; } @Override public Header clone() { try { return (Header) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * Class that represents the configuration of a CloudFront message */ public static class Config implements Serializable, Cloneable { private static final long serialVersionUID = -286083903805870299L; private String distributionId; /** * default constructor */ public Config() {} /** * @return distribution id of cloud front entity */ public String getDistributionId() { return this.distributionId; } /** * @param distributionId distribution id of cloud front entity */ public void setDistributionId(String distributionId) { this.distributionId = distributionId; } /** * @param distributionId distribution id of cloud front entity * @return Config */ public Config withDistributionId(String distributionId) { setDistributionId(distributionId); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDistributionId() != null) sb.append("distributionId: ").append(getDistributionId()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Config == false) return false; Config other = (Config) obj; if (other.getDistributionId() == null ^ this.getDistributionId() == null) return false; if (other.getDistributionId() != null && other.getDistributionId().equals(this.getDistributionId()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDistributionId() == null) ? 0 : getDistributionId().hashCode()); return hashCode; } @Override public Config clone() { try { return (Config) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * class that represents a CLoudFront request */ public static class Request implements Serializable, Cloneable { private static final long serialVersionUID = 3245036101075464149L; private String uri; private String method; private String httpVersion; private String clientIp; private Map<String, List<Header>> headers; /** * default constructor */ public Request() {} /** * @return uri of cloud front endpoint */ public String getUri() { return this.uri; } /** * @param uri uri of cloud front endpoint */ public void setUri(String uri) { this.uri = uri; } /** * @param uri uri of cloud front endpoint * @return Request object */ public Request withUri(String uri) { setUri(uri); return this; } /** * @return method used by cloud front entity */ public String getMethod() { return this.method; } /** * @param method method used by cloud front entity */ public void setMethod(String method) { this.method = method; } /** * @param method method used by cloud front entity * @return Request object */ public Request withMethod(String method) { setMethod(method); return this; } /** * @return httpVersion http version used by cloud front */ public String getHttpVersion() { return this.httpVersion; } /** * @param httpVersion http version used by cloud front */ public void setHttpVersion(String httpVersion) { this.httpVersion = httpVersion; } /** * @param httpVersion http version used by cloud front * @return Request */ public Request withHttpVersion(String httpVersion) { setHttpVersion((httpVersion)); return this; } /** * @return client ip address */ public String getClientIp() { return this.clientIp; } /** * @param clientIp client ip address */ public void setClientIp(String clientIp) { this.clientIp = clientIp; } /** * @param clientIp client ip address * @return Request object */ public Request withClientIp(String clientIp) { setClientIp(clientIp); return this; } /** * @return headers used in the cloud front request */ public Map<String, List<Header>> getHeaders() { return this.headers; } /** * @param headers headers used in the cloud front request */ public void setHeaders(Map<String, List<Header>> headers) { this.headers = headers; } /** * @param headers used in the cloud front request * @return Response object */ public Request withHeaders(Map<String, List<Header>> headers) { setHeaders(headers); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getUri() != null) sb.append("uri: ").append(getUri()).append(","); if (getMethod() != null) sb.append("method: ").append(getMethod()).append(","); if (getHttpVersion() != null) sb.append("httpVersion: ").append(getHttpVersion()).append(","); if (getClientIp() != null) sb.append("clientIp: ").append(getClientIp()).append(","); if (getHeaders() != null) sb.append("headers: ").append(getHeaders().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Request == false) return false; Request other = (Request) obj; if (other.getUri() == null ^ this.getUri() == null) return false; if (other.getUri() != null && other.getUri().equals(this.getUri()) == false) return false; if (other.getMethod() == null ^ this.getMethod() == null) return false; if (other.getMethod() != null && other.getMethod().equals(this.getMethod()) == false) return false; if (other.getHttpVersion() == null ^ this.getHttpVersion() == null) return false; if (other.getHttpVersion() != null && other.getHttpVersion().equals(this.getHttpVersion()) == false) return false; if (other.getClientIp() == null ^ this.getClientIp() == null) return false; if (other.getClientIp() != null && other.getClientIp().equals(this.getClientIp()) == false) return false; if (other.getHeaders() == null ^ this.getHeaders() == null) return false; if (other.getHeaders() != null && other.getHeaders().equals(this.getHeaders()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getUri() == null) ? 0 : getUri().hashCode()); hashCode = prime * hashCode + ((getMethod() == null) ? 0 : getMethod().hashCode()); hashCode = prime * hashCode + ((getHttpVersion() == null) ? 0 : getHttpVersion().hashCode()); hashCode = prime * hashCode + ((getClientIp() == null) ? 0 : getClientIp().hashCode()); hashCode = prime * hashCode + ((getHeaders() == null) ? 0 : getHeaders().hashCode()); return hashCode; } @Override public Request clone() { try { return (Request) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * class that represents a Response object */ public static class Response implements Serializable, Cloneable { private static final long serialVersionUID = -3711565862079053710L; private String status; private String statusDescription; private String httpVersion; private Map<String, List<Header>> headers; /** * default constructor */ public Response() {} /** * @return status code returned by cloud front */ public String getStatus() { return this.status; } /** * @param status status code returned by cloud front */ public void setStatus(String status) { this.status = status; } /** * @param status status code returned by cloud front * @return Response */ public Response withStatus(String status) { setStatus(status); return this; } /** * @return status description returned by cloud front */ public String getStatusDescription() { return this.statusDescription; } /** * @param statusDescription status description returned by cloud front */ public void setStatusDescription(String statusDescription) { this.statusDescription = statusDescription; } /** * @param statusDescription status description returned by cloud front * @return Response */ public Response withStatusDescription(String statusDescription) { setStatusDescription(statusDescription); return this; } /** * @return http version used by cloud front */ public String getHttpVersion() { return this.httpVersion; } /** * @param httpVersion http version used by cloud front */ public void setHttpVersion(String httpVersion) { this.httpVersion = httpVersion; } /** * @param httpVersion http version used by cloud front * @return Response object */ public Response withHttpVersion(String httpVersion) { setHttpVersion(httpVersion); return this; } /** * @return headers included with the Cloud front response */ public Map<String, List<Header>> getHeaders() { return this.headers; } /** * @param headers headers included with the Cloud front response */ public void setHeaders(Map<String, List<Header>> headers) { this.headers = headers; } /** * @param headers headers included with the Cloud front response * @return Response object */ public Response withHeaders(Map<String, List<Header>> headers) { setHeaders(headers); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStatus() != null) sb.append("status: ").append(getStatus()).append(","); if (getStatusDescription() != null) sb.append("statusDescription: ").append(getStatusDescription()).append(","); if (getHttpVersion() != null) sb.append("httpVersion: ").append(getHttpVersion()).append(","); if (getHeaders() != null) sb.append("headers: ").append(getHeaders().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Response == false) return false; Response other = (Response) obj; if (other.getStatus() == null ^ this.getStatus() == null) return false; if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false) return false; if (other.getStatusDescription() == null ^ this.getStatusDescription() == null) return false; if (other.getStatusDescription() != null && other.getStatusDescription().equals(this.getStatusDescription()) == false) return false; if (other.getHttpVersion() == null ^ this.getHttpVersion() == null) return false; if (other.getHttpVersion() != null && other.getHttpVersion().equals(this.getHttpVersion()) == false) return false; if (other.getHeaders() == null ^ this.getHeaders() == null) return false; if (other.getHeaders() != null && other.getHeaders().equals(this.getHeaders()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getStatusDescription() == null) ? 0 : getStatusDescription().hashCode()); hashCode = prime * hashCode + ((getHttpVersion() == null) ? 0 : getHttpVersion().hashCode()); hashCode = prime * hashCode + ((getHeaders() == null) ? 0 : getHeaders().hashCode()); return hashCode; } @Override public Response clone() { try { return (Response) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * class that represents the CloudFront body within a record */ public static class CF implements Serializable, Cloneable { private static final long serialVersionUID = -5940167419180448832L; private Config config; private Request request; private Response response; /** * default constructor */ public CF() {} /** * @return configuration object used by cloud front */ public Config getConfig() { return this.config; } /** * @param config configuration object used by cloud front */ public void setConfig(Config config) { this.config = config; } /** * @param config configuration object used by cloud front * @return CF object */ public CF withConfig(Config config) { setConfig(config); return this; } /** * @return Request object */ public Request getRequest() { return this.request; } /** * @param request Request object used by cloud front */ public void setRequest(Request request) { this.request = request; } /** * @param request Request object used by cloud front * @return CF */ public CF withRequest(Request request) { setRequest(request); return this; } /** * @return Response object used by cloud front */ public Response getResponse() { return this.response; } /** * @param response Response object used by cloud front */ public void setResponse(Response response) { this.response = response; } /** * @param response Response object used by cloud front * @return CF */ public CF withResponse(Response response) { setResponse(response); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getConfig() != null) sb.append("config: ").append(getConfig().toString()).append(","); if (getRequest() != null) sb.append("request: ").append(getRequest().toString()).append(","); if (getResponse() != null) sb.append("response: ").append(getResponse().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CF == false) return false; CF other = (CF) obj; if (other.getConfig() == null ^ this.getConfig() == null) return false; if (other.getConfig() != null && other.getConfig().equals(this.getConfig()) == false) return false; if (other.getRequest() == null ^ this.getRequest() == null) return false; if (other.getRequest() != null && other.getRequest().equals(this.getRequest()) == false) return false; if (other.getResponse() == null ^ this.getResponse() == null) return false; if (other.getResponse() != null && other.getResponse().equals(this.getResponse()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getConfig() == null) ? 0 : getConfig().hashCode()); hashCode = prime * hashCode + ((getRequest() == null) ? 0 : getRequest().hashCode()); hashCode = prime * hashCode + ((getResponse() == null) ? 0 : getResponse().hashCode()); return hashCode; } @Override public CF clone() { try { return (CF) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * Class that represents a record in a CLoudFront event */ public static class Record implements Serializable, Cloneable { private static final long serialVersionUID = -6114551370798889850L; private CF cf; /** * default constructor */ public Record() {} /** * @return CF object that contains message from cloud front */ public CF getCf() { return this.cf; } /** * @param cf CF object that contains message from cloud front */ public void setCf(CF cf) { this.cf = cf; } /** * @param cf CF object that contains message from cloud front * @return Record object */ public Record withCf(CF cf) { setCf(cf); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCf() != null) sb.append("cf: ").append(getCf().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Record == false) return false; Record other = (Record) obj; if (other.getCf() == null ^ this.getCf() == null) return false; if (other.getCf() != null && other.getCf().equals(this.getCf()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCf() == null) ? 0 : getCf().hashCode()); return hashCode; } @Override public Record clone() { try { return (Record) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public CloudFrontEvent() {} /** * @return list of records in cloud front event */ public List<Record> getRecords() { return this.records; } /** * @param records list of records in cloud front event */ public void setRecords(List<Record> records) { this.records = records; } /** * @param records list of records in cloud front event * @return CloudFrontEvent object */ public CloudFrontEvent withRecords(List<Record> records) { setRecords(records); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append("records: ").append(getRecords().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CloudFrontEvent == false) return false; CloudFrontEvent other = (CloudFrontEvent) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public CloudFrontEvent clone() { try { return (CloudFrontEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,762
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/RabbitMQEvent.java
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; /** * Represents a Rabbit MQ event sent to Lambda * <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html">Onboarding Amazon MQ as event source to Lambda</a> */ @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public class RabbitMQEvent { private String eventSource; private String eventSourceArn; private Map<String, List<RabbitMessage>> rmqMessagesByQueue; @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public static class RabbitMessage { private BasicProperties basicProperties; private boolean redelivered; private String data; } @Data @NoArgsConstructor @AllArgsConstructor @Builder(setterPrefix = "with") public static class BasicProperties { private String contentType; private String contentEncoding; private Map<String, Object> headers; private int deliveryMode; private int priority; private String correlationId; private String replyTo; private int expiration; private String messageId; private String timestamp; private String type; private String userId; private String appId; private String clusterId; private int bodySize; } }
1,763
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2WebSocketEvent.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; import java.util.Map; import java.util.Objects; /** * @author Tim Gustafson <tjg@amazon.com> */ public class APIGatewayV2WebSocketEvent implements Serializable, Cloneable { private static final long serialVersionUID = 5695319264103347099L; public static class RequestIdentity implements Serializable, Cloneable { private static final long serialVersionUID = -3276649362684921217L; private String cognitoIdentityPoolId; private String accountId; private String cognitoIdentityId; private String caller; private String apiKey; private String sourceIp; private String cognitoAuthenticationType; private String cognitoAuthenticationProvider; private String userArn; private String userAgent; private String user; private String accessKey; public String getCognitoIdentityPoolId() { return cognitoIdentityPoolId; } public void setCognitoIdentityPoolId(String cognitoIdentityPoolId) { this.cognitoIdentityPoolId = cognitoIdentityPoolId; } public String getAccountId() { return accountId; } public void setAccountId(String accountId) { this.accountId = accountId; } public String getCognitoIdentityId() { return cognitoIdentityId; } public void setCognitoIdentityId(String cognitoIdentityId) { this.cognitoIdentityId = cognitoIdentityId; } public String getCaller() { return caller; } public void setCaller(String caller) { this.caller = caller; } public String getApiKey() { return apiKey; } public void setApiKey(String apiKey) { this.apiKey = apiKey; } public String getSourceIp() { return sourceIp; } public void setSourceIp(String sourceIp) { this.sourceIp = sourceIp; } public String getCognitoAuthenticationType() { return cognitoAuthenticationType; } public void setCognitoAuthenticationType(String cognitoAuthenticationType) { this.cognitoAuthenticationType = cognitoAuthenticationType; } public String getCognitoAuthenticationProvider() { return cognitoAuthenticationProvider; } public void setCognitoAuthenticationProvider(String cognitoAuthenticationProvider) { this.cognitoAuthenticationProvider = cognitoAuthenticationProvider; } public String getUserArn() { return userArn; } public void setUserArn(String userArn) { this.userArn = userArn; } public String getUserAgent() { return userAgent; } public void setUserAgent(String userAgent) { this.userAgent = userAgent; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getAccessKey() { return accessKey; } public void setAccessKey(String accessKey) { this.accessKey = accessKey; } @Override public int hashCode() { int hash = 7; hash = 29 * hash + (this.cognitoIdentityPoolId != null ? this.cognitoIdentityPoolId.hashCode() : 0); hash = 29 * hash + (this.accountId != null ? this.accountId.hashCode() : 0); hash = 29 * hash + (this.cognitoIdentityId != null ? this.cognitoIdentityId.hashCode() : 0); hash = 29 * hash + (this.caller != null ? this.caller.hashCode() : 0); hash = 29 * hash + (this.apiKey != null ? this.apiKey.hashCode() : 0); hash = 29 * hash + (this.sourceIp != null ? this.sourceIp.hashCode() : 0); hash = 29 * hash + (this.cognitoAuthenticationType != null ? this.cognitoAuthenticationType.hashCode() : 0); hash = 29 * hash + (this.cognitoAuthenticationProvider != null ? this.cognitoAuthenticationProvider.hashCode() : 0); hash = 29 * hash + (this.userArn != null ? this.userArn.hashCode() : 0); hash = 29 * hash + (this.userAgent != null ? this.userAgent.hashCode() : 0); hash = 29 * hash + (this.user != null ? this.user.hashCode() : 0); hash = 29 * hash + (this.accessKey != null ? this.accessKey.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final RequestIdentity other = (RequestIdentity) obj; if ((this.cognitoIdentityPoolId == null) ? (other.cognitoIdentityPoolId != null) : !this.cognitoIdentityPoolId.equals(other.cognitoIdentityPoolId)) { return false; } if ((this.accountId == null) ? (other.accountId != null) : !this.accountId.equals(other.accountId)) { return false; } if ((this.cognitoIdentityId == null) ? (other.cognitoIdentityId != null) : !this.cognitoIdentityId.equals(other.cognitoIdentityId)) { return false; } if ((this.caller == null) ? (other.caller != null) : !this.caller.equals(other.caller)) { return false; } if ((this.apiKey == null) ? (other.apiKey != null) : !this.apiKey.equals(other.apiKey)) { return false; } if ((this.sourceIp == null) ? (other.sourceIp != null) : !this.sourceIp.equals(other.sourceIp)) { return false; } if ((this.cognitoAuthenticationType == null) ? (other.cognitoAuthenticationType != null) : !this.cognitoAuthenticationType.equals(other.cognitoAuthenticationType)) { return false; } if ((this.cognitoAuthenticationProvider == null) ? (other.cognitoAuthenticationProvider != null) : !this.cognitoAuthenticationProvider.equals(other.cognitoAuthenticationProvider)) { return false; } if ((this.userArn == null) ? (other.userArn != null) : !this.userArn.equals(other.userArn)) { return false; } if ((this.userAgent == null) ? (other.userAgent != null) : !this.userAgent.equals(other.userAgent)) { return false; } if ((this.user == null) ? (other.user != null) : !this.user.equals(other.user)) { return false; } if ((this.accessKey == null) ? (other.accessKey != null) : !this.accessKey.equals(other.accessKey)) { return false; } return true; } @Override public String toString() { return "{cognitoIdentityPoolId=" + cognitoIdentityPoolId + ", accountId=" + accountId + ", cognitoIdentityId=" + cognitoIdentityId + ", caller=" + caller + ", apiKey=" + apiKey + ", sourceIp=" + sourceIp + ", cognitoAuthenticationType=" + cognitoAuthenticationType + ", cognitoAuthenticationProvider=" + cognitoAuthenticationProvider + ", userArn=" + userArn + ", userAgent=" + userAgent + ", user=" + user + ", accessKey=" + accessKey + "}"; } } public static class RequestContext implements Serializable, Cloneable { private static final long serialVersionUID = -6641935365992304860L; private String accountId; private String resourceId; private String stage; private String requestId; private RequestIdentity identity; private String ResourcePath; private Map<String, Object> authorizer; private String httpMethod; private String apiId; private long connectedAt; private String connectionId; private String domainName; private String error; private String eventType; private String extendedRequestId; private String integrationLatency; private String messageDirection; private String messageId; private String requestTime; private long requestTimeEpoch; private String routeKey; private String status; public String getAccountId() { return accountId; } public void setAccountId(String accountId) { this.accountId = accountId; } public String getResourceId() { return resourceId; } public void setResourceId(String resourceId) { this.resourceId = resourceId; } public String getStage() { return stage; } public void setStage(String stage) { this.stage = stage; } public String getRequestId() { return requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public RequestIdentity getIdentity() { return identity; } public void setIdentity(RequestIdentity identity) { this.identity = identity; } public String getResourcePath() { return ResourcePath; } public void setResourcePath(String ResourcePath) { this.ResourcePath = ResourcePath; } public Map<String, Object> getAuthorizer() { return authorizer; } public void setAuthorizer(Map<String, Object> authorizer) { this.authorizer = authorizer; } public String getHttpMethod() { return httpMethod; } public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } public String getApiId() { return apiId; } public void setApiId(String apiId) { this.apiId = apiId; } public long getConnectedAt() { return connectedAt; } public void setConnectedAt(long connectedAt) { this.connectedAt = connectedAt; } public String getConnectionId() { return connectionId; } public void setConnectionId(String connectionId) { this.connectionId = connectionId; } public String getDomainName() { return domainName; } public void setDomainName(String domainName) { this.domainName = domainName; } public String getError() { return error; } public void setError(String error) { this.error = error; } public String getEventType() { return eventType; } public void setEventType(String eventType) { this.eventType = eventType; } public String getExtendedRequestId() { return extendedRequestId; } public void setExtendedRequestId(String extendedRequestId) { this.extendedRequestId = extendedRequestId; } public String getIntegrationLatency() { return integrationLatency; } public void setIntegrationLatency(String integrationLatency) { this.integrationLatency = integrationLatency; } public String getMessageDirection() { return messageDirection; } public void setMessageDirection(String messageDirection) { this.messageDirection = messageDirection; } public String getMessageId() { return messageId; } public void setMessageId(String messageId) { this.messageId = messageId; } public String getRequestTime() { return requestTime; } public void setRequestTime(String requestTime) { this.requestTime = requestTime; } public long getRequestTimeEpoch() { return requestTimeEpoch; } public void setRequestTimeEpoch(long requestTimeEpoch) { this.requestTimeEpoch = requestTimeEpoch; } public String getRouteKey() { return routeKey; } public void setRouteKey(String routeKey) { this.routeKey = routeKey; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } @Override public int hashCode() { int hash = 3; hash = 59 * hash + (this.accountId != null ? this.accountId.hashCode() : 0); hash = 59 * hash + (this.resourceId != null ? this.resourceId.hashCode() : 0); hash = 59 * hash + (this.stage != null ? this.stage.hashCode() : 0); hash = 59 * hash + (this.requestId != null ? this.requestId.hashCode() : 0); hash = 59 * hash + (this.identity != null ? this.identity.hashCode() : 0); hash = 59 * hash + (this.ResourcePath != null ? this.ResourcePath.hashCode() : 0); hash = 59 * hash + (this.authorizer != null ? this.authorizer.hashCode() : 0); hash = 59 * hash + (this.httpMethod != null ? this.httpMethod.hashCode() : 0); hash = 59 * hash + (this.apiId != null ? this.apiId.hashCode() : 0); hash = 59 * hash + (int) (this.connectedAt ^ (this.connectedAt >>> 32)); hash = 59 * hash + (this.connectionId != null ? this.connectionId.hashCode() : 0); hash = 59 * hash + (this.domainName != null ? this.domainName.hashCode() : 0); hash = 59 * hash + (this.error != null ? this.error.hashCode() : 0); hash = 59 * hash + (this.eventType != null ? this.eventType.hashCode() : 0); hash = 59 * hash + (this.extendedRequestId != null ? this.extendedRequestId.hashCode() : 0); hash = 59 * hash + (this.integrationLatency != null ? this.integrationLatency.hashCode() : 0); hash = 59 * hash + (this.messageDirection != null ? this.messageDirection.hashCode() : 0); hash = 59 * hash + (this.messageId != null ? this.messageId.hashCode() : 0); hash = 59 * hash + (this.requestTime != null ? this.requestTime.hashCode() : 0); hash = 59 * hash + (int) (this.requestTimeEpoch ^ (this.requestTimeEpoch >>> 32)); hash = 59 * hash + (this.routeKey != null ? this.routeKey.hashCode() : 0); hash = 59 * hash + (this.status != null ? this.status.hashCode() : 0); return hash; } @Override public String toString() { return "{accountId=" + accountId + ", resourceId=" + resourceId + ", stage=" + stage + ", requestId=" + requestId + ", identity=" + identity + ", ResourcePath=" + ResourcePath + ", authorizer=" + authorizer + ", httpMethod=" + httpMethod + ", apiId=" + apiId + ", connectedAt=" + connectedAt + ", connectionId=" + connectionId + ", domainName=" + domainName + ", error=" + error + ", eventType=" + eventType + ", extendedRequestId=" + extendedRequestId + ", integrationLatency=" + integrationLatency + ", messageDirection=" + messageDirection + ", messageId=" + messageId + ", requestTime=" + requestTime + ", requestTimeEpoch=" + requestTimeEpoch + ", routeKey=" + routeKey + ", status=" + status + "}"; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final RequestContext other = (RequestContext) obj; if (this.connectedAt != other.connectedAt) { return false; } if (this.requestTimeEpoch != other.requestTimeEpoch) { return false; } if ((this.accountId == null) ? (other.accountId != null) : !this.accountId.equals(other.accountId)) { return false; } if ((this.resourceId == null) ? (other.resourceId != null) : !this.resourceId.equals(other.resourceId)) { return false; } if ((this.stage == null) ? (other.stage != null) : !this.stage.equals(other.stage)) { return false; } if ((this.requestId == null) ? (other.requestId != null) : !this.requestId.equals(other.requestId)) { return false; } if ((this.ResourcePath == null) ? (other.ResourcePath != null) : !this.ResourcePath.equals(other.ResourcePath)) { return false; } if ((this.authorizer == null) ? (other.authorizer != null) : !this.authorizer.equals(other.authorizer)) { return false; } if ((this.httpMethod == null) ? (other.httpMethod != null) : !this.httpMethod.equals(other.httpMethod)) { return false; } if ((this.apiId == null) ? (other.apiId != null) : !this.apiId.equals(other.apiId)) { return false; } if ((this.connectionId == null) ? (other.connectionId != null) : !this.connectionId.equals(other.connectionId)) { return false; } if ((this.domainName == null) ? (other.domainName != null) : !this.domainName.equals(other.domainName)) { return false; } if ((this.error == null) ? (other.error != null) : !this.error.equals(other.error)) { return false; } if ((this.eventType == null) ? (other.eventType != null) : !this.eventType.equals(other.eventType)) { return false; } if ((this.extendedRequestId == null) ? (other.extendedRequestId != null) : !this.extendedRequestId.equals(other.extendedRequestId)) { return false; } if ((this.integrationLatency == null) ? (other.integrationLatency != null) : !this.integrationLatency.equals(other.integrationLatency)) { return false; } if ((this.messageDirection == null) ? (other.messageDirection != null) : !this.messageDirection.equals(other.messageDirection)) { return false; } if ((this.messageId == null) ? (other.messageId != null) : !this.messageId.equals(other.messageId)) { return false; } if ((this.requestTime == null) ? (other.requestTime != null) : !this.requestTime.equals(other.requestTime)) { return false; } if ((this.routeKey == null) ? (other.routeKey != null) : !this.routeKey.equals(other.routeKey)) { return false; } if ((this.status == null) ? (other.status != null) : !this.status.equals(other.status)) { return false; } if (this.identity != other.identity && (this.identity == null || !this.identity.equals(other.identity))) { return false; } return true; } } private String resource; private String path; private String httpMethod; private Map<String, String> headers; private Map<String, List<String>> multiValueHeaders; private Map<String, String> queryStringParameters; private Map<String, List<String>> multiValueQueryStringParameters; private Map<String, String> pathParameters; private Map<String, String> stageVariables; private RequestContext requestContext; private String body; private boolean isBase64Encoded = false; public String getResource() { return resource; } public void setResource(String resource) { this.resource = resource; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getHttpMethod() { return httpMethod; } public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } public Map<String, String> getHeaders() { return headers; } public void setHeaders(Map<String, String> headers) { this.headers = headers; } public Map<String, List<String>> getMultiValueHeaders() { return multiValueHeaders; } public void setMultiValueHeaders(Map<String, List<String>> multiValueHeaders) { this.multiValueHeaders = multiValueHeaders; } public Map<String, String> getQueryStringParameters() { return queryStringParameters; } public void setQueryStringParameters(Map<String, String> queryStringParameters) { this.queryStringParameters = queryStringParameters; } public Map<String, List<String>> getMultiValueQueryStringParameters() { return multiValueQueryStringParameters; } public void setMultiValueQueryStringParameters(Map<String, List<String>> multiValueQueryStringParameters) { this.multiValueQueryStringParameters = multiValueQueryStringParameters; } public Map<String, String> getPathParameters() { return pathParameters; } public void setPathParameters(Map<String, String> pathParameters) { this.pathParameters = pathParameters; } public Map<String, String> getStageVariables() { return stageVariables; } public void setStageVariables(Map<String, String> stageVariables) { this.stageVariables = stageVariables; } public RequestContext getRequestContext() { return requestContext; } public void setRequestContext(RequestContext requestContext) { this.requestContext = requestContext; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } public boolean isIsBase64Encoded() { return isBase64Encoded; } public void setIsBase64Encoded(boolean isBase64Encoded) { this.isBase64Encoded = isBase64Encoded; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; APIGatewayV2WebSocketEvent that = (APIGatewayV2WebSocketEvent) o; if (isBase64Encoded != that.isBase64Encoded) return false; if (resource != null ? !resource.equals(that.resource) : that.resource != null) return false; if (path != null ? !path.equals(that.path) : that.path != null) return false; if (httpMethod != null ? !httpMethod.equals(that.httpMethod) : that.httpMethod != null) return false; if (headers != null ? !headers.equals(that.headers) : that.headers != null) return false; if (multiValueHeaders != null ? !multiValueHeaders.equals(that.multiValueHeaders) : that.multiValueHeaders != null) return false; if (queryStringParameters != null ? !queryStringParameters.equals(that.queryStringParameters) : that.queryStringParameters != null) return false; if (multiValueQueryStringParameters != null ? !multiValueQueryStringParameters.equals(that.multiValueQueryStringParameters) : that.multiValueQueryStringParameters != null) return false; if (pathParameters != null ? !pathParameters.equals(that.pathParameters) : that.pathParameters != null) return false; if (stageVariables != null ? !stageVariables.equals(that.stageVariables) : that.stageVariables != null) return false; if (requestContext != null ? !requestContext.equals(that.requestContext) : that.requestContext != null) return false; return body != null ? body.equals(that.body) : that.body == null; } @Override public int hashCode() { int result = resource != null ? resource.hashCode() : 0; result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (httpMethod != null ? httpMethod.hashCode() : 0); result = 31 * result + (headers != null ? headers.hashCode() : 0); result = 31 * result + (multiValueHeaders != null ? multiValueHeaders.hashCode() : 0); result = 31 * result + (queryStringParameters != null ? queryStringParameters.hashCode() : 0); result = 31 * result + (multiValueQueryStringParameters != null ? multiValueQueryStringParameters.hashCode() : 0); result = 31 * result + (pathParameters != null ? pathParameters.hashCode() : 0); result = 31 * result + (stageVariables != null ? stageVariables.hashCode() : 0); result = 31 * result + (requestContext != null ? requestContext.hashCode() : 0); result = 31 * result + (body != null ? body.hashCode() : 0); result = 31 * result + (isBase64Encoded ? 1 : 0); return result; } @Override public String toString() { final StringBuilder sb = new StringBuilder("APIGatewayV2WebSocketEvent{"); sb.append("resource='").append(resource).append('\''); sb.append(", path='").append(path).append('\''); sb.append(", httpMethod='").append(httpMethod).append('\''); sb.append(", headers=").append(headers); sb.append(", multiValueHeaders=").append(multiValueHeaders); sb.append(", queryStringParameters=").append(queryStringParameters); sb.append(", multiValueQueryStringParameters=").append(multiValueQueryStringParameters); sb.append(", pathParameters=").append(pathParameters); sb.append(", stageVariables=").append(stageVariables); sb.append(", requestContext=").append(requestContext); sb.append(", body='").append(body).append('\''); sb.append(", isBase64Encoded=").append(isBase64Encoded); sb.append('}'); return sb.toString(); } }
1,764
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPResponse.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ 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; @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public class APIGatewayV2HTTPResponse { private int statusCode; private Map<String, String> headers; private Map<String, List<String>> multiValueHeaders; private List<String> cookies; private String body; private boolean isBase64Encoded; }
1,765
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3BatchResponse.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.List; /** * Event to represent the response which should be returned as part of a S3 Batch custom * action. * * https://docs.aws.amazon.com/AmazonS3/latest/dev/batch-ops-invoke-lambda.html */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class S3BatchResponse { private String invocationSchemaVersion; private ResultCode treatMissingKeysAs; private String invocationId; private List<Result> results; @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Result { private String taskId; private ResultCode resultCode; private String resultString; } public enum ResultCode { /** * The task completed normally. If you requested a job completion report, * the task's result string is included in the report. */ Succeeded, /** * The task suffered a temporary failure and will be redriven before the job * completes. The result string is ignored. If this is the final redrive, * the error message is included in the final report. */ TemporaryFailure, /** * The task suffered a permanent failure. If you requested a job-completion * report, the task is marked as Failed and includes the error message * string. Result strings from failed tasks are ignored. */ PermanentFailure } public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEvent s3BatchEvent) { return S3BatchResponse.builder() .withInvocationId(s3BatchEvent.getInvocationId()) .withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion()); } }
1,766
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEvent.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import java.time.Instant; import java.util.List; import java.util.Map; /** * The V2 API Gateway customer authorizer event object as described - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html * */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class APIGatewayV2CustomAuthorizerEvent { private String version; private String type; private String routeArn; private List<String> identitySource; private String routeKey; private String rawPath; private String rawQueryString; private List<String> cookies; private Map<String, String> headers; private Map<String, String> queryStringParameters; private RequestContext requestContext; private Map<String, String> pathParameters; private Map<String, String> stageVariables; @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class RequestContext { private static DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MMM/yyyy:HH:mm:ss Z"); private String accountId; private String apiId; private String domainName; private String domainPrefix; private Http http; private String requestId; private String routeKey; private String stage; private String time; private long timeEpoch; public Instant getTimeEpoch() { return Instant.ofEpochMilli(timeEpoch); } public DateTime getTime() { return fmt.parseDateTime(time); } } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Http { private String method; private String path; private String protocol; private String sourceIp; private String userAgent; } }
1,767
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolMigrateUserEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Migrate User Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-migrate-user.html">Migrate User Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolMigrateUserEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolMigrateUserEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * The username entered by the user. */ private String userName; /** * The password entered by the user for sign-in. It is not set in the forgot-password flow. */ private String password; /** * One or more key-value pairs containing the validation data in the user's sign-in request. */ private Map<String, String> validationData; /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the migrate user trigger. */ private Map<String, String> clientMetadata; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> validationData, Map<String, String> clientMetadata, String userName, String password) { super(userAttributes); this.validationData = validationData; this.clientMetadata = clientMetadata; this.userName = userName; this.password = password; } } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Response { /** * It must contain one or more name-value pairs representing user attributes to be stored in the user profile in your user pool. */ private Map<String, String> userAttributes; /** * During sign-in, this attribute can be set to CONFIRMED, or not set, to auto-confirm your users and allow them to sign-in with their previous passwords. */ private String finalUserStatus; /** * This attribute can be set to "SUPPRESS" to suppress the welcome message usually sent by Amazon Cognito to new users. * If this attribute is not returned, the welcome message will be sent. */ private String messageAction; /** * This attribute can be set to "EMAIL" to send the welcome message by email, or "SMS" to send the welcome message by SMS. * If this attribute is not returned, the welcome message will be sent by SMS. */ private String[] desiredDeliveryMediums; /** * If this parameter is set to "true" and the phone number or email address specified in the UserAttributes parameter already exists as an alias with a different user, the API call will migrate the alias from the previous user to the newly created user. */ private boolean forceAliasCreation; } }
1,768
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CodeCommitEvent.java
package com.amazonaws.services.lambda.runtime.events; import org.joda.time.DateTime; import java.io.Serializable; import java.util.List; /** * References a CodeCommit event */ public class CodeCommitEvent implements Serializable, Cloneable { private static final long serialVersionUID = 2404735479795009282L; private List<Record> records; /** * represents a Reference object in a CodeCommit object */ public static class Reference implements Serializable, Cloneable { private static final long serialVersionUID = 9166524005926768827L; private String commit; private String ref; private Boolean created; /** * default constructor */ public Reference() {} /** * @return commit id */ public String getCommit() { return this.commit; } /** * @param commit set commit id */ public void setCommit(String commit) { this.commit = commit; } /** * @param commit commit id * @return Reference */ public Reference withCommit(String commit) { setCommit(commit); return this; } /** * @return reference id */ public String getRef() { return this.ref; } /** * @param ref reference id */ public void setRef(String ref) { this.ref = ref; } /** * @param ref reference id * @return Reference object */ public Reference withRef(String ref) { setRef(ref); return this; } /** * @return whether reference was created */ public Boolean getCreated() { return this.created; } /** * @param created whether reference was created */ public void setCreated(Boolean created) { this.created = created; } /** * @param created whether reference was created * @return Reference object */ public Reference withCreated(Boolean created) { setCreated(created); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCommit() != null) sb.append("commit: ").append(getCommit()).append(","); if (getRef() != null) sb.append("ref: ").append(getRef()).append(","); if (getCreated() != null) sb.append("created: ").append(getCreated().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Reference == false) return false; Reference other = (Reference) obj; if (other.getCommit() == null ^ this.getCommit() == null) return false; if (other.getCommit() != null && other.getCommit().equals(this.getCommit()) == false) return false; if (other.getRef() == null ^ this.getRef() == null) return false; if (other.getRef() != null && other.getRef().equals(this.getRef()) == false) return false; if (other.getCreated() == null ^ this.getCreated() == null) return false; if (other.getCreated() != null && other.getCreated().equals(this.getCreated()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCommit() == null) ? 0 : getCommit().hashCode()); hashCode = prime * hashCode + ((getRef() == null) ? 0 : getRef().hashCode()); hashCode = prime * hashCode + ((getCreated() == null) ? 0 : getCreated().hashCode()); return hashCode; } @Override public Reference clone() { try { return (Reference) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * Represents a CodeCommit object in a record */ public static class CodeCommit implements Serializable, Cloneable { private static final long serialVersionUID = 2594306162311794147L; private List<Reference> references; /** * default constructor */ public CodeCommit() {} /** * @return list of Reference objects in the CodeCommit event */ public List<Reference> getReferences() { return this.references; } /** * @param references list of Reference objects in the CodeCommit event */ public void setReferences(List<Reference> references) { this.references = references; } /** * @param references list of Reference objects in the CodeCommit event * @return CodeCommit */ public CodeCommit withReferences(List<Reference> references) { setReferences(references); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getReferences() != null) sb.append("references: ").append(getReferences().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CodeCommit == false) return false; CodeCommit other = (CodeCommit) obj; if (other.getReferences() == null ^ this.getReferences() == null) return false; if (other.getReferences() != null && other.getReferences().equals(this.getReferences()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getReferences() == null) ? 0 : getReferences().hashCode()); return hashCode; } @Override public CodeCommit clone() { try { return (CodeCommit) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * represents a CodeCommit record */ public static class Record implements Serializable, Cloneable { private static final long serialVersionUID = 1116409777237432728L; private String eventId; private String eventVersion; private DateTime eventTime; private String eventTriggerName; private Integer eventPartNumber; private CodeCommit codeCommit; private String eventName; private String eventTriggerConfigId; private String eventSourceArn; private String userIdentityArn; private String eventSource; private String awsRegion; private String customData; private Integer eventTotalParts; /** * default constructor */ public Record() {} /** * @return event id */ public String getEventId() { return this.eventId; } /** * @param eventId event id */ public void setEventId(String eventId) { this.eventId = eventId; } /** * @param eventId event id * @return Record */ public Record withEventId(String eventId) { setEventId(eventId); return this; } /** * @return event version */ public String getEventVersion() { return this.eventVersion; } /** * @param eventVersion event version */ public void setEventVersion(String eventVersion) { this.eventVersion = eventVersion; } /** * @param eventVersion event version * @return Record */ public Record withEventVersion(String eventVersion) { setEventVersion(eventVersion); return this; } /** * @return event timestamp */ public DateTime getEventTime() { return this.eventTime; } /** * @param eventTime event timestamp */ public void setEventTime(DateTime eventTime) { this.eventTime = eventTime; } /** * @param eventTime event timestamp * @return Record */ public Record withEventTime(DateTime eventTime) { setEventTime(eventTime); return this; } /** * @return event trigger name */ public String getEventTriggerName() { return this.eventTriggerName; } /** * @param eventTriggerName event trigger name */ public void setEventTriggerName(String eventTriggerName) { this.eventTriggerName = eventTriggerName; } /** * @param eventTriggerName * @return Record */ public Record withEventTriggerName(String eventTriggerName) { setEventTriggerName(eventTriggerName); return this; } /** * @return event part number */ public Integer getEventPartNumber() { return this.eventPartNumber; } /** * @param eventPartNumber event part number */ public void setEventPartNumber(Integer eventPartNumber) { this.eventPartNumber = eventPartNumber; } /** * @param eventPartNumber event part number * @return Record */ public Record withEventPartNumber(Integer eventPartNumber) { setEventPartNumber(eventPartNumber); return this; } /** * @return code commit */ public CodeCommit getCodeCommit() { return this.codeCommit; } /** * @param codeCommit code commit */ public void setCodeCommit(CodeCommit codeCommit) { this.codeCommit = codeCommit; } /** * @param codeCommit code commit * @return Record */ public Record withCodeCommit(CodeCommit codeCommit) { setCodeCommit(codeCommit); return this; } /** * @return event name */ public String getEventName() { return this.eventName; } /** * @param eventName event name */ public void setEventName(String eventName) { this.eventName = eventName; } /** * @param eventName event name * @return Record */ public Record withEventName(String eventName) { setEventName(eventName); return this; } /** * @return event trigger config id */ public String getEventTriggerConfigId() { return this.eventTriggerConfigId; } /** * @param eventTriggerConfigId event trigger config id */ public void setEventTriggerConfigId(String eventTriggerConfigId) { this.eventTriggerConfigId = eventTriggerConfigId; } /** * @param eventTriggerConfigId event trigger config id * @return Record */ public Record withEventTriggerConfigId(String eventTriggerConfigId) { setEventTriggerConfigId(eventTriggerConfigId); return this; } /** * @return event source arn */ public String getEventSourceArn() { return this.eventSourceArn; } /** * @param eventSourceArn event source arn */ public void setEventSourceArn(String eventSourceArn) { this.eventSourceArn = eventSourceArn; } /** * @param eventSourceArn event source arn * @return Record */ public Record withEventSourceArn(String eventSourceArn) { setEventSourceArn(eventSourceArn); return this; } /** * @return user identity arn */ public String getUserIdentityArn() { return this.userIdentityArn; } /** * @param userIdentityArn user identity arn */ public void setUserIdentityArn(String userIdentityArn) { this.userIdentityArn = userIdentityArn; } /** * @param userIdentityArn user identity arn * @return Record */ public Record withUserIdentityArn(String userIdentityArn) { setUserIdentityArn(userIdentityArn); return this; } /** * @return event source */ public String getEventSource() { return this.eventSource; } /** * @param eventSource event source */ public void setEventSource(String eventSource) { this.eventSource = eventSource; } /** * @param eventSource event source * @return Record */ public Record withEventSource(String eventSource) { setEventSource(eventSource); return this; } /** * @return aws region */ public String getAwsRegion() { return this.awsRegion; } /** * @param awsRegion aws region */ public void setAwsRegion(String awsRegion) { this.awsRegion = awsRegion; } /** * @param awsRegion aws region * @return Record */ public Record withAwsRegion(String awsRegion) { setAwsRegion(awsRegion); return this; } /** * @return event total parts */ public Integer getEventTotalParts() { return this.eventTotalParts; } /** * @param eventTotalParts event total parts */ public void setEventTotalParts(Integer eventTotalParts) { this.eventTotalParts = eventTotalParts; } /** * @param eventTotalParts event total parts * @return Record */ public Record withEventTotalParts(Integer eventTotalParts) { setEventTotalParts(eventTotalParts); return this; } /** * * @return custom data */ public String getCustomData(){ return this.customData;} /** * * @param customData event custom data */ public void setCustomData(String customData) { this.customData = customData;} /** * @param customData event * @return Record */ public Record withCustomData(String customData) { setCustomData(customData); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getEventId() != null) sb.append("eventId: ").append(getEventId()).append(","); if (getEventVersion() != null) sb.append("eventVersion: ").append(getEventVersion()).append(","); if (getEventTime() != null) sb.append("eventTime: ").append(getEventTime().toString()).append(","); if (getEventTriggerName() != null) sb.append("eventTriggerName: ").append(getEventTriggerName()).append(","); if (getEventPartNumber() != null) sb.append("eventPartNumber: ").append(getEventPartNumber().toString()).append(","); if (getCodeCommit() != null) sb.append("codeCommit: ").append(getCodeCommit().toString()).append(","); if (getEventName() != null) sb.append("eventName: ").append(getEventName()).append(","); if (getEventTriggerConfigId() != null) sb.append("eventTriggerConfigId: ").append(getEventTriggerConfigId()).append(","); if (getEventSourceArn() != null) sb.append("eventSourceArn: ").append(getEventSourceArn()).append(","); if (getUserIdentityArn() != null) sb.append("userIdentityArn: ").append(getUserIdentityArn()).append(","); if (getEventSource() != null) sb.append("eventSource: ").append(getEventSource()).append(","); if (getAwsRegion() != null) sb.append("awsRegion: ").append(getAwsRegion()).append(","); if (getCustomData() != null) sb.append("customData: ").append(getCustomData()).append(","); if (getEventTotalParts() != null) sb.append("eventTotalParts: ").append(getEventTotalParts()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Record == false) return false; Record other = (Record) obj; if (other.getEventId() == null ^ this.getEventId() == null) return false; if (other.getEventId() != null && other.getEventId().equals(this.getEventId()) == false) return false; if (other.getEventVersion() == null ^ this.getEventVersion() == null) return false; if (other.getEventVersion() != null && other.getEventVersion().equals(this.getEventVersion()) == false) return false; if (other.getEventTime() == null ^ this.getEventTime() == null) return false; if (other.getEventTime() != null && other.getEventTime().equals(this.getEventTime()) == false) return false; if (other.getEventTriggerName() == null ^ this.getEventTriggerName() == null) return false; if (other.getEventTriggerName() != null && other.getEventTriggerName().equals(this.getEventTriggerName()) == false) return false; if (other.getEventPartNumber() == null ^ this.getEventPartNumber() == null) return false; if (other.getEventPartNumber() != null && other.getEventPartNumber().equals(this.getEventPartNumber()) == false) return false; if (other.getCodeCommit() == null ^ this.getCodeCommit() == null) return false; if (other.getCodeCommit() != null && other.getCodeCommit().equals(this.getCodeCommit()) == false) return false; if (other.getEventName() == null ^ this.getEventName() == null) return false; if (other.getEventName() != null && other.getEventName().equals(this.getEventName()) == false) return false; if (other.getEventTriggerConfigId() == null ^ this.getEventTriggerConfigId() == null) return false; if (other.getEventTriggerConfigId() != null && other.getEventTriggerConfigId().equals(this.getEventTriggerConfigId()) == false) return false; if (other.getEventSourceArn() == null ^ this.getEventSourceArn() == null) return false; if (other.getEventSourceArn() != null && other.getEventSourceArn().equals(this.getEventSourceArn()) == false) return false; if (other.getUserIdentityArn() == null ^ this.getUserIdentityArn() == null) return false; if (other.getUserIdentityArn() != null && other.getUserIdentityArn().equals(this.getUserIdentityArn()) == false) return false; if (other.getEventSource() == null ^ this.getEventSource() == null) return false; if (other.getEventSource() != null && other.getEventSource().equals(this.getEventSource()) == false) return false; if (other.getAwsRegion() == null ^ this.getAwsRegion() == null) return false; if (other.getAwsRegion() != null && other.getAwsRegion().equals(this.getAwsRegion()) == false) return false; if (other.getEventTotalParts() == null ^ this.getEventTotalParts() == null) return false; if (other.getEventTotalParts() != null && other.getEventTotalParts().equals(this.getEventTotalParts()) == false) return false; if (other.getCustomData() == null ^ this.getCustomData() == null) return false; if (other.getCustomData() != null && other.getCustomData().equals(this.getCustomData()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getEventId() == null) ? 0 : getEventId().hashCode()); hashCode = prime * hashCode + ((getEventVersion() == null) ? 0 : getEventVersion().hashCode()); hashCode = prime * hashCode + ((getEventTime() == null) ? 0 : getEventTime().hashCode()); hashCode = prime * hashCode + ((getEventTriggerName() == null) ? 0 : getEventTriggerName().hashCode()); hashCode = prime * hashCode + ((getEventPartNumber() == null) ? 0 : getEventPartNumber().hashCode()); hashCode = prime * hashCode + ((getCodeCommit() == null) ? 0 : getCodeCommit().hashCode()); hashCode = prime * hashCode + ((getEventName() == null) ? 0 : getEventName().hashCode()); hashCode = prime * hashCode + ((getEventTriggerConfigId() == null) ? 0 : getEventTriggerConfigId().hashCode()); hashCode = prime * hashCode + ((getEventSourceArn() == null) ? 0 : getEventSourceArn().hashCode()); hashCode = prime * hashCode + ((getUserIdentityArn() == null) ? 0 : getUserIdentityArn().hashCode()); hashCode = prime * hashCode + ((getEventSource() == null) ? 0 : getEventSource().hashCode()); hashCode = prime * hashCode + ((getAwsRegion() == null) ? 0 : getAwsRegion().hashCode()); hashCode = prime * hashCode + ((getEventTotalParts() == null) ? 0 : getEventTotalParts().hashCode()); hashCode = prime * hashCode + ((getCustomData() == null) ? 0 : getCustomData().hashCode()); return hashCode; } @Override public Record clone() { try { return (Record) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public CodeCommitEvent() {} /** * @return records */ public List<Record> getRecords() { return this.records; } /** * @param records records */ public void setRecords(List<Record> records) { this.records = records; } /** * @param records records * @return CodeCommitEvent */ public CodeCommitEvent withRecords(List<Record> records) { setRecords(records); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append("records: ").append(getRecords().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CodeCommitEvent == false) return false; CodeCommitEvent other = (CodeCommitEvent) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public CodeCommitEvent clone() { try { return (CodeCommitEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,769
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisAnalyticsFirehoseInputPreprocessingEvent.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.List; /** * Event model for pre-processing Kinesis Firehose records through Kinesis * Analytics Lambda pre-processing function. */ public class KinesisAnalyticsFirehoseInputPreprocessingEvent implements Serializable { private static final long serialVersionUID = 3372554211277515302L; public String invocationId; public String applicationArn; public String streamArn; public List<Record> records; public KinesisAnalyticsFirehoseInputPreprocessingEvent() { } public KinesisAnalyticsFirehoseInputPreprocessingEvent(String invocationId, String applicationArn, String streamArn, List<Record> records) { super(); this.invocationId = invocationId; this.applicationArn = applicationArn; this.streamArn = streamArn; this.records = records; } public String getInvocationId() { return invocationId; } public void setInvocationId(String invocationId) { this.invocationId = invocationId; } public String getApplicationArn() { return applicationArn; } public void setApplicationArn(String applicationArn) { this.applicationArn = applicationArn; } public String getStreamArn() { return streamArn; } public void setStreamArn(String streamArn) { this.streamArn = streamArn; } public List<Record> getRecords() { return records; } public void setRecords(List<Record> records) { this.records = records; } public static class Record implements Serializable { private static final long serialVersionUID = 9130920004800315787L; public String recordId; public KinesisFirehoseRecordMetadata kinesisFirehoseRecordMetadata; public ByteBuffer data; public Record() { } public Record(String recordId, KinesisFirehoseRecordMetadata kinesisFirehoseRecordMetadata, ByteBuffer data) { super(); this.recordId = recordId; this.kinesisFirehoseRecordMetadata = kinesisFirehoseRecordMetadata; this.data = data; } public String getRecordId() { return recordId; } public void setRecordId(String recordId) { this.recordId = recordId; } public ByteBuffer getData() { return data; } public void setData(ByteBuffer data) { this.data = data; } public KinesisFirehoseRecordMetadata getKinesisFirehoseRecordMetadata() { return kinesisFirehoseRecordMetadata; } public void setKinesisFirehoseRecordMetadata(KinesisFirehoseRecordMetadata kinesisFirehoseRecordMetadata) { this.kinesisFirehoseRecordMetadata = kinesisFirehoseRecordMetadata; } public static class KinesisFirehoseRecordMetadata implements Serializable { private static final long serialVersionUID = 692430771749481045L; public Long approximateArrivalTimestamp; public KinesisFirehoseRecordMetadata() { } public KinesisFirehoseRecordMetadata(Long approximateArrivalTimestamp) { super(); this.approximateArrivalTimestamp = approximateArrivalTimestamp; } public Long getApproximateArrivalTimestamp() { return approximateArrivalTimestamp; } public void setApproximateArrivalTimestamp(Long approximateArrivalTimestamp) { this.approximateArrivalTimestamp = approximateArrivalTimestamp; } } } }
1,770
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponseV1.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The IAM Policy Response required for API Gateway REST APIs * * https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html * */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class IamPolicyResponseV1 implements Serializable, Cloneable { public static final String EXECUTE_API_INVOKE = "execute-api:Invoke"; public static final String VERSION_2012_10_17 = "2012-10-17"; public static final String ALLOW = "Allow"; public static final String DENY = "Deny"; private String principalId; private PolicyDocument policyDocument; private Map<String, Object> context; private String usageIdentifierKey; public Map<String, Object> getPolicyDocument() { Map<String, Object> serializablePolicy = new HashMap<>(); serializablePolicy.put("Version", policyDocument.getVersion()); int numberOfStatements = policyDocument.getStatement().size(); Map<String, Object>[] serializableStatementArray = new Map[numberOfStatements]; for (int i = 0; i < numberOfStatements; i++) { Statement statement = policyDocument.getStatement().get(i); Map<String, Object> serializableStatement = new HashMap<>(); serializableStatement.put("Effect", statement.getEffect()); serializableStatement.put("Action", statement.getAction()); serializableStatement.put("Resource", statement.getResource().toArray(new String[0])); serializableStatement.put("Condition", statement.getCondition()); serializableStatementArray[i] = serializableStatement; } serializablePolicy.put("Statement", serializableStatementArray); return serializablePolicy; } public static Statement allowStatement(String resource) { return Statement.builder() .withEffect(ALLOW) .withResource(Collections.singletonList(resource)) .withAction(EXECUTE_API_INVOKE) .build(); } public static Statement denyStatement(String resource) { return Statement.builder() .withEffect(DENY) .withResource(Collections.singletonList(resource)) .withAction(EXECUTE_API_INVOKE) .build(); } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class PolicyDocument implements Serializable, Cloneable { private String version; private List<Statement> statement; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Statement implements Serializable, Cloneable { private String action; private String effect; private List<String> resource; private Map<String, Map<String, Object>> condition; } }
1,771
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/AppSyncLambdaAuthorizerEvent.java
/* * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.util.Map; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * Class that represents the input to an AppSync Lambda authorizer invocation. */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class AppSyncLambdaAuthorizerEvent { private RequestContext requestContext; private String authorizationToken; @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class RequestContext { private String apiId; private String accountId; private String requestId; private String queryDocument; private String operationName; private Map<String, Object> variables; } }
1,772
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SimpleIAMPolicyResponse.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Map; /** * The simplified IAM Policy response object as described in https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html * */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class SimpleIAMPolicyResponse { private boolean isAuthorized; private Map<String, String> context; }
1,773
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SQSEvent.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; /** * Represents an Amazon SQS event. */ public class SQSEvent implements Serializable, Cloneable { private static final long serialVersionUID = -5663700178408796225L; private List<SQSMessage> records; public static class MessageAttribute implements Serializable, Cloneable { private static final long serialVersionUID = -1602746537669100978L; private String stringValue; private ByteBuffer binaryValue; private List<String> stringListValues; private List<ByteBuffer> binaryListValues; private String dataType; /** * Default constructor */ public MessageAttribute() {} /** * Gets the value of message attribute of type String or type Number * @return stringValue */ public String getStringValue() { return stringValue; } /** * Sets the value of message attribute of type String or type Number * @param stringValue A string representing the value of attribute of type String or type Number */ public void setStringValue(String stringValue) { this.stringValue = stringValue; } /** * Gets the value of message attribute of type Binary * @return binaryValue */ public ByteBuffer getBinaryValue() { return binaryValue; } /** * Sets the value of message attribute of type Binary * @param binaryValue A string representing the value of attribute of type Binary */ public void setBinaryValue(ByteBuffer binaryValue) { this.binaryValue = binaryValue; } /** * Gets the list of String values of message attribute * @return stringListValues */ public List<String> getStringListValues() { return stringListValues; } /** * Sets the list of String values of message attribute * @param stringListValues A list of String representing the value of attribute */ public void setStringListValues(List<String> stringListValues) { this.stringListValues = stringListValues; } /** * Gets the list of Binary values of message attribute * @return binaryListValues */ public List<ByteBuffer> getBinaryListValues() { return binaryListValues; } /** * Sets the list of Binary values of message attribute * @param binaryListValues A list of Binary representing the value of attribute */ public void setBinaryListValues(List<ByteBuffer> binaryListValues) { this.binaryListValues = binaryListValues; } /** * Gets the dataType of message attribute * @return dataType */ public String getDataType() { return dataType; } /** * Sets the dataType of message attribute * @param dataType A string representing the data type of attribute */ public void setDataType(String dataType) { this.dataType = dataType; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStringValue() != null) sb.append("stringValue: ").append(getStringValue()).append(","); if (getBinaryValue() != null) sb.append("binaryValue: ").append(getBinaryValue().toString()).append(","); if (getStringListValues() != null) sb.append("stringListValues: ").append(getStringListValues()).append(","); if (getBinaryListValues() != null) sb.append("binaryListValues: ").append(getBinaryListValues()).append(","); if (getDataType() != null) sb.append("dataType: ").append(getDataType()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof MessageAttribute == false) return false; MessageAttribute other = (MessageAttribute) obj; if (other.getStringValue() == null ^ this.getStringValue() == null) return false; if (other.getStringValue() != null && other.getStringValue().equals(this.getStringValue()) == false) return false; if (other.getBinaryValue() == null ^ this.getBinaryValue() == null) return false; if (other.getBinaryValue() != null && other.getBinaryValue().equals(this.getBinaryValue()) == false) return false; if (other.getStringListValues() == null ^ this.getStringListValues() == null) return false; if (other.getStringListValues() != null && other.getStringListValues().equals(this.getStringListValues()) == false) return false; if (other.getBinaryListValues() == null ^ this.getBinaryListValues() == null) return false; if (other.getBinaryListValues() != null && other.getBinaryListValues().equals(this.getBinaryListValues()) == false) return false; if (other.getDataType() == null ^ this.getDataType() == null) return false; if (other.getDataType() != null && other.getDataType().equals(this.getDataType()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStringValue() == null) ? 0 : getStringValue().hashCode()); hashCode = prime * hashCode + ((getBinaryValue() == null) ? 0 : getBinaryValue().hashCode()); hashCode = prime * hashCode + ((getStringListValues() == null) ? 0 : getStringListValues().hashCode()); hashCode = prime * hashCode + ((getBinaryListValues() == null) ? 0 : getBinaryListValues().hashCode()); hashCode = prime * hashCode + ((getDataType() == null) ? 0 : getDataType().hashCode()); return hashCode; } @Override public MessageAttribute clone() { try { return (MessageAttribute) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } public static class SQSMessage implements Serializable, Cloneable { private static final long serialVersionUID = -2300083946005987098L; private String messageId; private String receiptHandle; private String body; private String md5OfBody; private String md5OfMessageAttributes; private String eventSourceArn; private String eventSource; private String awsRegion; private Map<String, String> attributes; private Map<String, MessageAttribute> messageAttributes; /** * Default constructor */ public SQSMessage() {} /** * Gets the message id * @return messageId */ public String getMessageId() { return messageId; } /** * Sets the message id * @param messageId **/ public void setMessageId(String messageId) { this.messageId = messageId; } /** * Gets the receipt handle * @return receiptHandle */ public String getReceiptHandle() { return receiptHandle; } /** * Sets the receipt handle * @param receiptHandle **/ public void setReceiptHandle(String receiptHandle) { this.receiptHandle = receiptHandle; } /** * Gets the body * @return body */ public String getBody() { return body; } /** * Sets the body * @param body **/ public void setBody(String body) { this.body = body; } /** * Gets the md5 of body * @return md5OfBody */ public String getMd5OfBody() { return md5OfBody; } /** * Sets the md5 of body * @param md5OfBody **/ public void setMd5OfBody(String md5OfBody) { this.md5OfBody = md5OfBody; } /** * Gets the md5 of message attributes * @return md5OfMessageAttributes */ public String getMd5OfMessageAttributes() { return md5OfMessageAttributes; } /** * Sets the md5 of message attributes * @param md5OfMessageAttributes **/ public void setMd5OfMessageAttributes(String md5OfMessageAttributes) { this.md5OfMessageAttributes = md5OfMessageAttributes; } /** * Gets the Event Source ARN * @return eventSourceArn */ public String getEventSourceArn() { return eventSourceArn; } /** * Sets the Event Source ARN * @param eventSourceArn **/ public void setEventSourceArn(String eventSourceArn) { this.eventSourceArn = eventSourceArn; } /** * Gets the Event Source * @return eventSource */ public String getEventSource() { return eventSource; } /** * Sets the Event Source * @param eventSource **/ public void setEventSource(String eventSource) { this.eventSource = eventSource; } /** * Gets the AWS Region * @return awsRegion */ public String getAwsRegion() { return awsRegion; } /** * Sets the AWS Region * @param awsRegion **/ public void setAwsRegion(String awsRegion) { this.awsRegion = awsRegion; } /** * Gets the attributes associated with the queue * @return attributes */ public Map<String, String> getAttributes() { return attributes; } /** * Sets the queue attributes associated with the queue * @param attributes **/ public void setAttributes(Map<String, String> attributes) { this.attributes = attributes; } /** * Gets the attributes associated with the message * @return message attributes */ public Map<String, MessageAttribute> getMessageAttributes() { return messageAttributes; } /** * Sets the attributes associated with the message * @param messageAttributes A map object with string and message attribute key/value pairs */ public void setMessageAttributes(Map<String, MessageAttribute> messageAttributes) { this.messageAttributes = messageAttributes; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getMessageId() != null) sb.append("messageId: ").append(getMessageId()).append(","); if (getReceiptHandle() != null) sb.append("receiptHandle: ").append(getReceiptHandle()).append(","); if (getEventSourceArn() != null) sb.append("eventSourceARN: ").append(getEventSourceArn()).append(","); if (getEventSource() != null) sb.append("eventSource: ").append(getEventSource()).append(","); if (getAwsRegion() != null) sb.append("awsRegion: ").append(getAwsRegion()).append(","); if (getBody() != null) sb.append("body: ").append(getBody()).append(","); if (getMd5OfBody() != null) sb.append("md5OfBody: ").append(getMd5OfBody()).append(","); if (getMd5OfMessageAttributes() != null) sb.append("md5OfMessageAttributes: ").append(getMd5OfMessageAttributes()).append(","); if (getAttributes() != null) sb.append("attributes: ").append(getAttributes().toString()).append(","); if (getMessageAttributes() != null) sb.append("messageAttributes: ").append(getMessageAttributes().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof SQSMessage == false) return false; SQSMessage other = (SQSMessage) obj; if (other.getMessageId() == null ^ this.getMessageId() == null) return false; if (other.getMessageId() != null && other.getMessageId().equals(this.getMessageId()) == false) return false; if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == null) return false; if (other.getReceiptHandle() != null && other.getReceiptHandle().equals(this.getReceiptHandle()) == false) return false; if (other.getEventSourceArn() == null ^ this.getEventSourceArn() == null) return false; if (other.getEventSourceArn() != null && other.getEventSourceArn().equals(this.getEventSourceArn()) == false) return false; if (other.getEventSource() == null ^ this.getEventSource() == null) return false; if (other.getEventSource() != null && other.getEventSource().equals(this.getEventSource()) == false) return false; if (other.getAwsRegion() == null ^ this.getAwsRegion() == null) return false; if (other.getAwsRegion() != null && other.getAwsRegion().equals(this.getAwsRegion()) == false) return false; if (other.getBody() == null ^ this.getBody() == null) return false; if (other.getBody() != null && other.getBody().equals(this.getBody()) == false) return false; if (other.getMd5OfBody() == null ^ this.getMd5OfBody() == null) return false; if (other.getMd5OfBody() != null && other.getMd5OfBody().equals(this.getMd5OfBody()) == false) return false; if (other.getMd5OfMessageAttributes() == null ^ this.getMd5OfMessageAttributes() == null) return false; if (other.getMd5OfMessageAttributes() != null && other.getMd5OfMessageAttributes().equals(this.getMd5OfMessageAttributes()) == false) return false; if (other.getAttributes() == null ^ this.getAttributes() == null) return false; if (other.getAttributes() != null && other.getAttributes().equals(this.getAttributes()) == false) return false; if (other.getMessageAttributes() == null ^ this.getMessageAttributes() == null) return false; if (other.getMessageAttributes() != null && other.getMessageAttributes().equals(this.getMessageAttributes()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getMessageAttributes() == null) ? 0 : getMessageAttributes().hashCode()); hashCode = prime * hashCode + ((getMessageId() == null) ? 0 : getMessageId().hashCode()); hashCode = prime * hashCode + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode()); hashCode = prime * hashCode + ((getEventSourceArn() == null) ? 0 : getEventSourceArn().hashCode()); hashCode = prime * hashCode + ((getEventSource() == null) ? 0 : getEventSource().hashCode()); hashCode = prime * hashCode + ((getAwsRegion() == null) ? 0 : getAwsRegion().hashCode()); hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode()); hashCode = prime * hashCode + ((getMd5OfBody() == null) ? 0 : getMd5OfBody().hashCode()); hashCode = prime * hashCode + ((getMd5OfMessageAttributes() == null) ? 0 : getMd5OfMessageAttributes().hashCode()); hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode()); return hashCode; } @Override public SQSMessage clone() { try { return (SQSMessage) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * Default constructor */ public SQSEvent() {} /** * Gets the list of SQS messages * @return List of messages */ public List<SQSMessage> getRecords() { return records; } /** * Sets a list of SQS messages * @param records A list of SQS message objects */ public void setRecords(List<SQSMessage> records) { this.records = records; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append("Records: ").append(getRecords()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof SQSEvent)) return false; SQSEvent other = (SQSEvent) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public SQSEvent clone() { try { return (SQSEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,774
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreTokenGenerationEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Pre Token Generation Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html">Pre Token Generation Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolPreTokenGenerationEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolPreTokenGenerationEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre token generation trigger. */ private Map<String, String> clientMetadata; /** * The input object containing the current group configuration. */ private GroupConfiguration groupConfiguration; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, GroupConfiguration groupConfiguration) { super(userAttributes); this.clientMetadata = clientMetadata; this.groupConfiguration = groupConfiguration; } } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class GroupConfiguration { /** * A list of the group names that are associated with the user that the identity token is issued for. */ private String[] groupsToOverride; /** * A list of the current IAM roles associated with these groups. */ private String[] iamRolesToOverride; /** * Indicates the preferred IAM role. */ private String preferredRole; } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class Response { private ClaimsOverrideDetails claimsOverrideDetails; } @Data @AllArgsConstructor @Builder(setterPrefix = "with") @NoArgsConstructor public static class ClaimsOverrideDetails { /** * A map of one or more key-value pairs of claims to add or override. * For group related claims, use groupOverrideDetails instead. */ private Map<String, String> claimsToAddOrOverride; /** * A list that contains claims to be suppressed from the identity token. */ private String[] claimsToSuppress; /** * The output object containing the current group configuration. */ private GroupConfiguration groupOverrideDetails; } }
1,775
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostConfirmationEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.ToString; import java.util.Map; /** * Represent the class for the Cognito User Pool Post Confirmation Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html">Post Confirmation Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @EqualsAndHashCode(callSuper = true) @Data @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolPostConfirmationEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; @Builder(setterPrefix = "with") public CognitoUserPoolPostConfirmationEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post confirmation trigger. */ private Map<String, String> clientMetadata; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata) { super(userAttributes); this.clientMetadata = clientMetadata; } } }
1,776
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3Event.java
/* * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** * Represents and AmazonS3 event. * */ public class S3Event extends S3EventNotification implements Serializable, Cloneable { private static final long serialVersionUID = -8094860465750962044L; /** * default constructor * (Not available in v1) */ public S3Event() { super(new ArrayList<S3EventNotificationRecord>()); } /** * Create a new instance of S3Event * @param records A list of S3 event notification records */ public S3Event(List<S3EventNotificationRecord> records) { super(records); } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append(getRecords().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof S3Event == false) return false; S3Event other = (S3Event) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public S3Event clone() { try { return (S3Event) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,777
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisAnalyticsOutputDeliveryEvent.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.util.List; /** * Event model for Kinesis Analytics Lambda output delivery. */ public class KinesisAnalyticsOutputDeliveryEvent implements Serializable { private static final long serialVersionUID = -276093256265202318L; public String invocationId; public String applicationArn; public List<Record> records; public KinesisAnalyticsOutputDeliveryEvent() { } public KinesisAnalyticsOutputDeliveryEvent(String invocationId, String applicationArn, List<Record> records) { super(); this.invocationId = invocationId; this.applicationArn = applicationArn; this.records = records; } public String getInvocationId() { return invocationId; } public void setInvocationId(String invocationId) { this.invocationId = invocationId; } public String getApplicationArn() { return applicationArn; } public void setApplicationArn(String applicationArn) { this.applicationArn = applicationArn; } public List<Record> getRecords() { return records; } public void setRecords(List<Record> records) { this.records = records; } public static class Record implements Serializable { private static final long serialVersionUID = -3545295536239762069L; public String recordId; public LambdaDeliveryRecordMetadata lambdaDeliveryRecordMetadata; public ByteBuffer data; public Record() { } public Record(String recordId, LambdaDeliveryRecordMetadata lambdaDeliveryRecordMetadata, ByteBuffer data) { super(); this.recordId = recordId; this.lambdaDeliveryRecordMetadata = lambdaDeliveryRecordMetadata; this.data = data; } public String getRecordId() { return recordId; } public void setRecordId(String recordId) { this.recordId = recordId; } public ByteBuffer getData() { return data; } public void setData(ByteBuffer data) { this.data = data; } public LambdaDeliveryRecordMetadata getLambdaDeliveryRecordMetadata() { return lambdaDeliveryRecordMetadata; } public void setLambdaDeliveryRecordMetadata(LambdaDeliveryRecordMetadata lambdaDeliveryRecordMetadata) { this.lambdaDeliveryRecordMetadata = lambdaDeliveryRecordMetadata; } public static class LambdaDeliveryRecordMetadata implements Serializable { private static final long serialVersionUID = -3809303175070680370L; public long retryHint; public LambdaDeliveryRecordMetadata() { } public LambdaDeliveryRecordMetadata(long retryHint) { super(); this.retryHint = retryHint; } public long getRetryHint() { return retryHint; } public void setRetryHint(long retryHint) { this.retryHint = retryHint; } } } }
1,778
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPreAuthenticationEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.ToString; import java.util.Map; /** * Represent the class for the Cognito User Pool Pre Authentication Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html">Pre Authentication Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolPreAuthenticationEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; @Builder(setterPrefix = "with") public CognitoUserPoolPreAuthenticationEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more name-value pairs containing the validation data in the request to register a user. * The validation data is set and then passed from the client in the request to register a user. */ private Map<String, String> validationData; /** * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client. */ private boolean userNotFound; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> validationData, boolean userNotFound) { super(userAttributes); this.validationData = validationData; this.userNotFound = userNotFound; } } }
1,779
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IamPolicyResponse.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The IAM Policy Response required for API Gateway HTTP APIs * * https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html * */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class IamPolicyResponse implements Serializable, Cloneable { public static final String EXECUTE_API_INVOKE = "execute-api:Invoke"; public static final String VERSION_2012_10_17 = "2012-10-17"; public static final String ALLOW = "Allow"; public static final String DENY = "Deny"; private String principalId; private PolicyDocument policyDocument; private Map<String, Object> context; public Map<String, Object> getPolicyDocument() { Map<String, Object> serializablePolicy = new HashMap<>(); serializablePolicy.put("Version", policyDocument.getVersion()); int numberOfStatements = policyDocument.getStatement().size(); Map<String, Object>[] serializableStatementArray = new Map[numberOfStatements]; for (int i = 0; i < numberOfStatements; i++) { Statement statement = policyDocument.getStatement().get(i); Map<String, Object> serializableStatement = new HashMap<>(); serializableStatement.put("Effect", statement.getEffect()); serializableStatement.put("Action", statement.getAction()); serializableStatement.put("Resource", statement.getResource().toArray(new String[0])); serializableStatement.put("Condition", statement.getCondition()); serializableStatementArray[i] = serializableStatement; } serializablePolicy.put("Statement", serializableStatementArray); return serializablePolicy; } public static Statement allowStatement(String resource) { return Statement.builder() .withEffect(ALLOW) .withResource(Collections.singletonList(resource)) .withAction(EXECUTE_API_INVOKE) .build(); } public static Statement denyStatement(String resource) { return Statement.builder() .withEffect(DENY) .withResource(Collections.singletonList(resource)) .withAction(EXECUTE_API_INVOKE) .build(); } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class PolicyDocument implements Serializable, Cloneable { private String version; private List<Statement> statement; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Statement implements Serializable, Cloneable { private String action; private String effect; private List<String> resource; private Map<String, Map<String, Object>> condition; } }
1,780
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3ObjectLambdaEvent.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Map; /** * Event to allow transformations to occur before an S3 object is returned to the calling service. * * <strong>Documentation</strong> * * <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/olap-writing-lambda.html">Writing and debugging Lambda functions for S3 Object Lambda Access Points</a> * * <strong>Example:</strong> * * <pre> * <code>import com.amazonaws.services.lambda.runtime.Context; * import com.amazonaws.services.lambda.runtime.events.S3ObjectLambdaEvent; * import org.apache.http.client.fluent.Request; * import software.amazon.awssdk.services.s3.S3Client; * import software.amazon.awssdk.services.s3.model.WriteGetObjectResponseRequest; * * import java.io.IOException; * * import static software.amazon.awssdk.core.sync.RequestBody.fromString; * * public class S3ObjectRequestHandler { * * private static final S3Client s3Client = S3Client.create(); * * public void handleRequest(S3ObjectLambdaEvent event, Context context) throws IOException { * String s3Body = Request.Get(event.inputS3Url()).execute().returnContent().asString(); * * String responseBody = s3Body.toUpperCase(); * * WriteGetObjectResponseRequest request = WriteGetObjectResponseRequest.builder() * .requestRoute(event.outputRoute()) * .requestToken(event.outputToken()) * .build(); * s3Client.writeGetObjectResponse(request, fromString(responseBody)); * } * } * </code> * </pre> */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class S3ObjectLambdaEvent { private String xAmzRequestId; private GetObjectContext getObjectContext; private Configuration configuration; private UserRequest userRequest; private UserIdentity userIdentity; private String protocolVersion; /** * A pre-signed URL that can be used to fetch the original object from Amazon S3. * * The URL is signed using the original caller's identity, and their permissions * will apply when the URL is used. If there are signed headers in the URL, the * Lambda function must include these in the call to Amazon S3, except for the Host. * * @return A pre-signed URL that can be used to fetch the original object from Amazon S3. */ public String inputS3Url() { return getGetObjectContext().getInputS3Url(); } /** * A routing token that is added to the S3 Object Lambda URL when the Lambda function * calls the S3 API WriteGetObjectResponse. * * @return the outputRoute */ public String outputRoute() { return getGetObjectContext().getOutputRoute(); } /** * An opaque token used by S3 Object Lambda to match the WriteGetObjectResponse call * with the original caller. * * @return the outputToken */ public String outputToken() { return getGetObjectContext().getOutputToken(); } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class GetObjectContext { private String inputS3Url; private String outputRoute; private String outputToken; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Configuration { private String accessPointArn; private String supportingAccessPointArn; private String payload; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class UserRequest { private String url; private Map<String, String> headers; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class UserIdentity { private String type; private String principalId; private String arn; private String accountId; private String accessKeyId; } }
1,781
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/IoTButtonEvent.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; /** * represents a click of an IoT Button */ public class IoTButtonEvent implements Serializable, Cloneable { private static final long serialVersionUID = 8699582353606993478L; private String serialNumber; private String clickType; private String batteryVoltage; /** * default constructor */ public IoTButtonEvent() {} /** * @return serial number */ public String getSerialNumber() { return serialNumber; } /** * @param serialNumber serial number */ public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } /** * @param serialNumber serial number * @return IotButtonEvent */ public IoTButtonEvent withSerialNumber(String serialNumber) { setSerialNumber(serialNumber); return this; } /** * @return click type */ public String getClickType() { return clickType; } /** * @param clickType click type */ public void setClickType(String clickType) { this.clickType = clickType; } /** * @param clickType click type * @return IoTButtonEvent */ public IoTButtonEvent withClickType(String clickType) { setClickType(clickType); return this; } /** * @return battery voltage */ public String getBatteryVoltage() { return batteryVoltage; } /** * @param batteryVoltage battery voltage */ public void setBatteryVoltage(String batteryVoltage) { this.batteryVoltage = batteryVoltage; } /** * @param batteryVoltage battery voltage * @return IoTButtonEvent */ public IoTButtonEvent withBatteryVoltage(String batteryVoltage) { setBatteryVoltage(batteryVoltage); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSerialNumber() != null) sb.append("serialNumber: ").append(getSerialNumber()).append(","); if (getClickType() != null) sb.append("clickType: ").append(getClickType()).append(","); if (getBatteryVoltage() != null) sb.append("batteryVoltage: ").append(getBatteryVoltage()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof IoTButtonEvent == false) return false; IoTButtonEvent other = (IoTButtonEvent) obj; if (other.getSerialNumber() == null ^ this.getSerialNumber() == null) return false; if (other.getSerialNumber() != null && other.getSerialNumber().equals(this.getSerialNumber()) == false) return false; if (other.getClickType() == null ^ this.getClickType() == null) return false; if (other.getClickType() != null && other.getClickType().equals(this.getClickType()) == false) return false; if (other.getBatteryVoltage() == null ^ this.getBatteryVoltage() == null) return false; if (other.getBatteryVoltage() != null && other.getBatteryVoltage().equals(this.getBatteryVoltage()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getSerialNumber() == null) ? 0 : getSerialNumber().hashCode()); hashCode = prime * hashCode + ((getClickType() == null) ? 0 : getClickType().hashCode()); hashCode = prime * hashCode + ((getBatteryVoltage() == null) ? 0 : getBatteryVoltage().hashCode()); return hashCode; } @Override public IoTButtonEvent clone() { try { return (IoTButtonEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,782
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConnectEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Map; /** * Class to represent an Amazon Connect contact flow event. * * @see <a href="https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html>Connect Lambda Functions</a> * * @author msailes <msailes@amazon.co.uk> */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class ConnectEvent implements Serializable, Cloneable { private Details details; private String name; @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Details implements Serializable, Cloneable { private ContactData contactData; private Map<String, Object> parameters; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class ContactData implements Serializable, Cloneable { private Map<String, String> attributes; private String channel; private String contactId; private CustomerEndpoint customerEndpoint; private String initialContactId; private String initiationMethod; private String instanceArn; private String previousContactId; private String queue; private SystemEndpoint systemEndpoint; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class CustomerEndpoint implements Serializable, Cloneable { private String address; private String type; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class SystemEndpoint implements Serializable, Cloneable { private String address; private String type; } }
1,783
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolPostAuthenticationEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.ToString; import java.util.Map; /** * Represent the class for the Cognito User Pool Post Authentication Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-authentication.html">Post Authentication Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolPostAuthenticationEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; @Builder(setterPrefix = "with") public CognitoUserPoolPostAuthenticationEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the post authentication trigger. */ private Map<String, String> clientMetadata; /** * This flag indicates if the user has signed in on a new device. */ private boolean newDeviceUsed; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, boolean newDeviceUsed) { super(userAttributes); this.clientMetadata = clientMetadata; this.newDeviceUsed = newDeviceUsed; } } }
1,784
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2WebSocketResponse.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.Map; /** * @author Tim Gustafson <tjg@amazon.com> */ public class APIGatewayV2WebSocketResponse implements Serializable, Cloneable { private static final long serialVersionUID = -5155789062248356200L; private boolean isBase64Encoded = false; private int statusCode; private Map<String, String> headers; private Map<String, String[]> multiValueHeaders; private String body; public boolean isIsBase64Encoded() { return isBase64Encoded; } public void setIsBase64Encoded(boolean isBase64Encoded) { this.isBase64Encoded = isBase64Encoded; } public int getStatusCode() { return statusCode; } public void setStatusCode(int statusCode) { this.statusCode = statusCode; } public Map<String, String> getHeaders() { return headers; } public void setHeaders(Map<String, String> headers) { this.headers = headers; } public Map<String, String[]> getMultiValueHeaders() { return multiValueHeaders; } public void setMultiValueHeaders(Map<String, String[]> multiValueHeaders) { this.multiValueHeaders = multiValueHeaders; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } @Override public int hashCode() { int hash = 3; hash = 71 * hash + (this.isBase64Encoded ? 1 : 0); hash = 71 * hash + this.statusCode; hash = 71 * hash + (this.headers != null ? this.headers.hashCode() : 0); hash = 71 * hash + (this.multiValueHeaders != null ? this.multiValueHeaders.hashCode() : 0); hash = 71 * hash + (this.body != null ? this.body.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final APIGatewayV2WebSocketResponse other = (APIGatewayV2WebSocketResponse) obj; if (this.isBase64Encoded != other.isBase64Encoded) { return false; } if (this.statusCode != other.statusCode) { return false; } if ((this.body == null) ? (other.body != null) : !this.body.equals(other.body)) { return false; } if (this.headers != other.headers && (this.headers == null || !this.headers.equals(other.headers))) { return false; } if (this.multiValueHeaders != other.multiValueHeaders && (this.multiValueHeaders == null || !this.multiValueHeaders.equals(other.multiValueHeaders))) { return false; } return true; } @Override public String toString() { return "{isBase64Encoded=" + isBase64Encoded + ", statusCode=" + statusCode + ", headers=" + headers + ", multiValueHeaders=" + multiValueHeaders + ", body=" + body + "}"; } }
1,785
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyResponseEvent.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Class that represents an APIGatewayProxyResponseEvent object */ public class APIGatewayProxyResponseEvent implements Serializable, Cloneable { private static final long serialVersionUID = 2263167344670024172L; private Integer statusCode; private Map<String, String> headers; private Map<String, List<String>> multiValueHeaders; private String body; private Boolean isBase64Encoded; /** * default constructor */ public APIGatewayProxyResponseEvent() {} /** * @return The HTTP status code for the request */ public Integer getStatusCode() { return statusCode; } /** * @param statusCode The HTTP status code for the request */ public void setStatusCode(Integer statusCode) { this.statusCode = statusCode; } /** * @param statusCode The HTTP status code for the request * @return APIGatewayProxyResponseEvent object */ public APIGatewayProxyResponseEvent withStatusCode(Integer statusCode) { this.setStatusCode(statusCode); return this; } /** * @return The Http headers return in the response */ public Map<String, String> getHeaders() { return headers; } /** * @param headers The Http headers return in the response */ public void setHeaders(Map<String, String> headers) { this.headers = headers; } /** * @param headers The Http headers return in the response * @return APIGatewayProxyResponseEvent */ public APIGatewayProxyResponseEvent withHeaders(Map<String, String> headers) { this.setHeaders(headers); return this; } /** * @return the Http multi value headers to return in the response */ public Map<String, List<String>> getMultiValueHeaders() { return multiValueHeaders; } /** * @param multiValueHeaders the Http multi value headers to return in the response */ public void setMultiValueHeaders(Map<String, List<String>> multiValueHeaders) { this.multiValueHeaders = multiValueHeaders; } /** * * @param multiValueHeaders the Http multi value headers to return in the response * @return APIGatewayProxyResponseEvent */ public APIGatewayProxyResponseEvent withMultiValueHeaders(Map<String, List<String>> multiValueHeaders) { this.setMultiValueHeaders(multiValueHeaders); return this; } /** * @return The response body */ public String getBody() { return body; } /** * @param body The response body */ public void setBody(String body) { this.body = body; } /** * @param body The response body * @return APIGatewayProxyResponseEvent object */ public APIGatewayProxyResponseEvent withBody(String body) { this.setBody(body); return this; } /** * @return whether the body String is base64 encoded. */ public Boolean getIsBase64Encoded() { return this.isBase64Encoded; } /** * @param isBase64Encoded Whether the body String is base64 encoded */ public void setIsBase64Encoded(Boolean isBase64Encoded) { this.isBase64Encoded = isBase64Encoded; } /** * @param isBase64Encoded Whether the body String is base64 encoded * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyResponseEvent withIsBase64Encoded(Boolean isBase64Encoded) { this.setIsBase64Encoded(isBase64Encoded); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStatusCode() != null) sb.append("statusCode: ").append(getStatusCode()).append(","); if (getHeaders() != null) sb.append("headers: ").append(getHeaders().toString()).append(","); if (getMultiValueHeaders() != null) sb.append("multiValueHeaders: ").append(getMultiValueHeaders().toString()).append(","); if (getBody() != null) sb.append("body: ").append(getBody()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof APIGatewayProxyResponseEvent == false) return false; APIGatewayProxyResponseEvent other = (APIGatewayProxyResponseEvent) obj; if (other.getStatusCode() == null ^ this.getStatusCode() == null) return false; if (other.getStatusCode() != null && other.getStatusCode().equals(this.getStatusCode()) == false) return false; if (other.getHeaders() == null ^ this.getHeaders() == null) return false; if (other.getHeaders() != null && other.getHeaders().equals(this.getHeaders()) == false) return false; if (other.getMultiValueHeaders() == null ^ this.getMultiValueHeaders() == null) return false; if (other.getMultiValueHeaders() != null && other.getMultiValueHeaders().equals(this.getMultiValueHeaders()) == false) return false; if (other.getBody() == null ^ this.getBody() == null) return false; if (other.getBody() != null && other.getBody().equals(this.getBody()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStatusCode() == null) ? 0 : getStatusCode().hashCode()); hashCode = prime * hashCode + ((getHeaders() == null) ? 0 : getHeaders().hashCode()); hashCode = prime * hashCode + ((getMultiValueHeaders() == null) ? 0 : getMultiValueHeaders().hashCode()); hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode()); return hashCode; } @Override public APIGatewayProxyResponseEvent clone() { try { return (APIGatewayProxyResponseEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,786
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SecretsManagerRotationEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * Class to represent the events which are sent during a Secrets Manager rotation process. * * @see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets-lambda-function-overview.html">Rotating secrets lambda function overview</a> * * @author msailes <msailes@amazon.co.uk> */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class SecretsManagerRotationEvent { private String step; private String secretId; private String clientRequestToken; }
1,787
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisFirehoseEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.List; import java.util.Map; /** * Created by adsuresh on 7/13/17. */ public class KinesisFirehoseEvent implements Serializable, Cloneable { private static final long serialVersionUID = -2890373471008001695L; private String invocationId; private String deliveryStreamArn; private String region; private List<Record> records; public static class Record implements Serializable, Cloneable { private static final long serialVersionUID = -7231161900431910379L; /** * <p> * The data blob, which is base64-encoded when the blob is serialized. The maximum size of the data blob, before * base64-encoding, is 1,000 KB. * </p> */ private ByteBuffer data; private String recordId; private Long approximateArrivalEpoch; private Long approximateArrivalTimestamp; private Map<String, String> kinesisRecordMetadata; /** * default constructor */ public Record() {} /** * <p> * The data blob, which is base64-encoded when the blob is serialized. The maximum size of the data blob, before * base64-encoding, is 1,000 KB. * </p> * <p> * The AWS SDK for Java performs a Base64 encoding on this field before sending this request to the AWS service. * Users of the SDK should not perform Base64 encoding on this field. * </p> * <p> * Warning: ByteBuffers returned by the SDK are mutable. Changes to the content or position of the byte buffer will * be seen by all objects that have a reference to this object. It is recommended to call ByteBuffer.duplicate() or * ByteBuffer.asReadOnlyBuffer() before using or reading from the buffer. This behavior will be changed in a future * major version of the SDK. * </p> * * @param data * The data blob, which is base64-encoded when the blob is serialized. The maximum size of the data blob, * before base64-encoding, is 1,000 KB. */ public void setData(ByteBuffer data) { this.data = data; } /** * <p> * The data blob, which is base64-encoded when the blob is serialized. The maximum size of the data blob, before * base64-encoding, is 1,000 KB. * </p> * <p> * {@code ByteBuffer}s are stateful. Calling their {@code get} methods changes their {@code position}. We recommend * using {@link java.nio.ByteBuffer#asReadOnlyBuffer()} to create a read-only view of the buffer with an independent * {@code position}, and calling {@code get} methods on this rather than directly on the returned {@code ByteBuffer}. * Doing so will ensure that anyone else using the {@code ByteBuffer} will not be affected by changes to the * {@code position}. * </p> * * @return The data blob, which is base64-encoded when the blob is serialized. The maximum size of the data blob, * before base64-encoding, is 1,000 KB. */ public ByteBuffer getData() { return this.data; } /** * @return record id */ public String getRecordId() { return this.recordId; } /** * @param recordId record id */ public void setRecordId(String recordId) { this.recordId = recordId; } /** * @param recordId record id * @return Record */ public Record withRecordId(String recordId) { setRecordId(recordId); return this; } /** * @return approximate arrival epoch */ public Long getApproximateArrivalEpoch() { return this.approximateArrivalEpoch; } /** * @param approximateArrivalEpoch Long epoch */ public void setApproximateArrivalEpoch(Long approximateArrivalEpoch) { this.approximateArrivalEpoch = approximateArrivalEpoch; } /** * @param approximateArrivalEpoch Long epoch * @return Record */ public Record withApproximateArrivalEpoch(Long approximateArrivalEpoch) { setApproximateArrivalEpoch(approximateArrivalEpoch); return this; } /** * @return approximate arrival timestamp */ public Long getApproximateArrivalTimestamp() { return this.approximateArrivalTimestamp; } /** * @param approximateArrivalTimestamp approximate arrival timestamp */ public void setApproximateArrivalTimestamp(Long approximateArrivalTimestamp) { this.approximateArrivalTimestamp = approximateArrivalTimestamp; } /** * @param approximateArrivalTimestamp approximate arrival timestamp * @return Record */ public Record withApproximateArrivalTimestamp(Long approximateArrivalTimestamp) { setApproximateArrivalTimestamp(approximateArrivalTimestamp); return this; } /** * @return kinesis record meta data */ public Map<String, String> getKinesisRecordMetadata() { return this.kinesisRecordMetadata; } /** * @param kinesisRecordMetadata kinesis record metadata */ public void setKinesisRecordMetadata(Map<String, String> kinesisRecordMetadata) { this.kinesisRecordMetadata = kinesisRecordMetadata; } /** * @param kinesisRecordMetadata kinesis record metadata * @return Record */ public Record withKinesisRecordMetadata(Map<String, String> kinesisRecordMetadata) { setKinesisRecordMetadata(kinesisRecordMetadata); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getData() != null) sb.append("data: ").append(getData().toString()).append(","); if (getRecordId() != null) sb.append("recordId: ").append(getRecordId()).append(","); if (getApproximateArrivalEpoch() != null) sb.append("approximateArrivalEpoch: ").append(getApproximateArrivalEpoch().toString()).append(","); if (getApproximateArrivalTimestamp() != null) sb.append("approximateArrivalTimestamp: ").append(getApproximateArrivalTimestamp().toString()).append(","); if (getKinesisRecordMetadata() != null) sb.append("kinesisRecordMetadata: ").append(getKinesisRecordMetadata().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Record == false) return false; Record other = (Record) obj; if (other.getData() == null ^ this.getData() == null) return false; if (other.getData() != null && other.getData().equals(this.getData()) == false) return false; if (other.getRecordId() == null ^ this.getRecordId() == null) return false; if (other.getRecordId() != null && other.getRecordId().equals(this.getRecordId()) == false) return false; if (other.getApproximateArrivalEpoch() == null ^ this.getApproximateArrivalEpoch() == null) return false; if (other.getApproximateArrivalEpoch() != null && other.getApproximateArrivalEpoch().equals(this.getApproximateArrivalEpoch()) == false) return false; if (other.getApproximateArrivalTimestamp() == null ^ this.getApproximateArrivalTimestamp() == null) return false; if (other.getApproximateArrivalTimestamp() != null && other.getApproximateArrivalTimestamp().equals(this.getApproximateArrivalTimestamp()) == false) return false; if (other.getKinesisRecordMetadata() == null ^ this.getKinesisRecordMetadata() == null) return false; if (other.getKinesisRecordMetadata() != null && other.getKinesisRecordMetadata().equals(this.getKinesisRecordMetadata()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode()); hashCode = prime * hashCode + ((getRecordId() == null) ? 0 : getRecordId().hashCode()); hashCode = prime * hashCode + ((getApproximateArrivalEpoch() == null) ? 0 : getApproximateArrivalEpoch().hashCode()); hashCode = prime * hashCode + ((getApproximateArrivalTimestamp() == null) ? 0 : getApproximateArrivalTimestamp().hashCode()); hashCode = prime * hashCode + ((getKinesisRecordMetadata() == null) ? 0 : getKinesisRecordMetadata().hashCode()); return hashCode; } @Override public Record clone() { try { return (Record) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public KinesisFirehoseEvent() {} /** * @return invocation id */ public String getInvocationId() { return this.invocationId; } /** * @param invocationId invocation id */ public void setInvocationId(String invocationId) { this.invocationId = invocationId; } /** * @param invocationId invocation id * @return KinesisFirehoseEvent */ public KinesisFirehoseEvent withInvocationId(String invocationId) { setInvocationId(invocationId); return this; } /** * @return delivery stream arn */ public String getDeliveryStreamArn() { return this.deliveryStreamArn; } /** * @param deliveryStreamArn delivery stream arn */ public void setDeliveryStreamArn(String deliveryStreamArn) { this.deliveryStreamArn = deliveryStreamArn; } /**] * @param deliveryStreamArn delivery stream arn * @return KinesisFirehoseEvent */ public KinesisFirehoseEvent withDeliveryStreamArn(String deliveryStreamArn) { setDeliveryStreamArn(deliveryStreamArn); return this; } /** * @return region */ public String getRegion() { return this.region; } /** * @param region aws region */ public void setRegion(String region) { this.region = region; } /** * @param region aws region * @return KinesisFirehoseEvent */ public KinesisFirehoseEvent withRegion(String region) { setRegion(region); return this; } /** * Gets the list of Kinesis event records * */ public List<Record> getRecords() { return records; } /** * Sets the list of Kinesis event records * @param records a list of Kinesis event records */ public void setRecords(List<Record> records) { this.records = records; } /** * @param records a list of Kinesis event records * @return KinesisFirehoseEvent */ public KinesisFirehoseEvent withRecords(List<Record> records) { setRecords(records); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInvocationId() != null) sb.append("invocationId: ").append(getInvocationId()).append(","); if (getDeliveryStreamArn() != null) sb.append("deliveryStreamArn: ").append(getDeliveryStreamArn()).append(","); if (getRegion() != null) sb.append("region: ").append(getRegion()).append(","); if (getRecords() != null) sb.append("records: ").append(getRecords().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KinesisFirehoseEvent == false) return false; KinesisFirehoseEvent other = (KinesisFirehoseEvent) obj; if (other.getInvocationId() == null ^ this.getInvocationId() == null) return false; if (other.getInvocationId() != null && other.getInvocationId().equals(this.getInvocationId()) == false) return false; if (other.getDeliveryStreamArn() == null ^ this.getDeliveryStreamArn() == null) return false; if (other.getDeliveryStreamArn() != null && other.getDeliveryStreamArn().equals(this.getDeliveryStreamArn()) == false) return false; if (other.getRegion() == null ^ this.getRegion() == null) return false; if (other.getRegion() != null && other.getRegion().equals(this.getRegion()) == false) return false; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInvocationId() == null) ? 0 : getInvocationId().hashCode()); hashCode = prime * hashCode + ((getDeliveryStreamArn() == null) ? 0 : getDeliveryStreamArn().hashCode()); hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode()); hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public KinesisFirehoseEvent clone() { try { return (KinesisFirehoseEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,788
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Map; /** * Represent the base class for all Cognito User Pool Events * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html#cognito-user-pools-lambda-trigger-event-parameter-shared">Customizing User Pool Workflows with Lambda Triggers</a> * * @author jvdl <jvdl@amazon.com> */ @AllArgsConstructor @Data @NoArgsConstructor public abstract class CognitoUserPoolEvent { /** * The version number of your Lambda function. */ private String version; /** * The name of the event that triggered the Lambda function. */ private String triggerSource; /** * The AWS Region. */ private String region; /** * The user pool ID for the user pool. */ private String userPoolId; /** * The username of the current user. */ private String userName; /** * The caller context. */ private CallerContext callerContext; @AllArgsConstructor @Data @NoArgsConstructor public static abstract class Request { /** * One or more pairs of user attribute names and values. */ private Map<String, String> userAttributes; } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class CallerContext { /** * The AWS SDK version number. */ private String awsSdkVersion; /** * The ID of the client associated with the user pool. */ private String clientId; } }
1,789
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoUserPoolVerifyAuthChallengeResponseEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.*; import java.util.Map; /** * Represent the class for the Cognito User Pool Verify Auth Challenge Response Lambda Trigger * * See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html">Verify Auth Challenge Response Lambda Trigger</a> * * @author jvdl <jvdl@amazon.com> */ @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public class CognitoUserPoolVerifyAuthChallengeResponseEvent extends CognitoUserPoolEvent { /** * The request from the Amazon Cognito service. */ private Request request; /** * The response from your Lambda trigger. */ private Response response; @Builder(setterPrefix = "with") public CognitoUserPoolVerifyAuthChallengeResponseEvent( String version, String triggerSource, String region, String userPoolId, String userName, CallerContext callerContext, Request request, Response response) { super(version, triggerSource, region, userPoolId, userName, callerContext); this.request = request; this.response = response; } @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) public static class Request extends CognitoUserPoolEvent.Request { /** * One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the verify auth challenge trigger. */ private Map<String, String> clientMetadata; /** * This parameter comes from the Create Auth Challenge trigger, and is compared against a user's challengeAnswer to determine whether the user passed the challenge. */ private Map<String, String> privateChallengeParameters; /** * The answer from the user's response to the challenge. */ private String challengeAnswer; /** * This boolean is populated when PreventUserExistenceErrors is set to ENABLED for your User Pool client */ private boolean userNotFound; @Builder(setterPrefix = "with") public Request(Map<String, String> userAttributes, Map<String, String> clientMetadata, String challengeAnswer, Map<String, String> privateChallengeParameters, boolean userNotFound) { super(userAttributes); this.clientMetadata = clientMetadata; this.userNotFound = userNotFound; this.challengeAnswer = challengeAnswer; this.privateChallengeParameters = privateChallengeParameters; } } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Response { /** * Set to true if the user has successfully completed the challenge, or false otherwise. */ private boolean answerCorrect; } }
1,790
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CognitoEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.Map; /** * * Represents an Amazon Cognito event sent to Lambda Functions * */ public class CognitoEvent implements Serializable, Cloneable { private static final long serialVersionUID = -3471890133562627751L; private String region; private Map<String, DatasetRecord> datasetRecords; private String identityPoolId; private String identityId; private String datasetName; private String eventType; private Integer version; /** * DatasetRecord contains the information about each record in a data set. * */ public static class DatasetRecord implements Serializable, Cloneable { private static final long serialVersionUID = -8853471047466644850L; private String oldValue; private String newValue; private String op; /** * default constructor * (Not available in v1) */ public DatasetRecord() {} /** * Get the record's old value * @return old value */ public String getOldValue() { return oldValue; } /** * Sets the record's old value * @param oldValue A string containing the old value */ public void setOldValue(String oldValue) { this.oldValue = oldValue; } /** * @param oldValue String with old value * @return DatasetRecord object */ public DatasetRecord withOldValue(String oldValue) { setOldValue(oldValue); return this; } /** * Gets the record's new value * @return new value */ public String getNewValue() { return newValue; } /** * Sets the records new value * @param newValue A string containing the new value */ public void setNewValue(String newValue) { this.newValue = newValue; } /** * @param newValue new value for record * @return DatasetRecord object */ public DatasetRecord withNewValue(String newValue) { setNewValue(newValue); return this; } /** * Gets the operation associated with the record * <p> * <ul> * <li> * For a new record or any updates to existing record it is set to "replace". * </li> * <li> * For deleting a record it is set to "remove". * </li> * </ul> * </p> */ public String getOp() { return op; } /** * Sets the operation associated with the record * <p> * <ul> * <li> * For a new record or any updates to existing record it is set to "replace". * </li> * <li> * For deleting a record it is set to "remove". * </li> * </ul> * </p> * @param op A string with a value of "replace" of "remove" */ public void setOp(String op) { this.op = op; } /** * @param op String operation * @return DatasetRecord object */ public DatasetRecord withOp(String op) { setOp(op); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getOldValue() != null) sb.append("oldValue: ").append(getOldValue()).append(","); if (getNewValue() != null) sb.append("newValue: ").append(getNewValue()).append(","); if (getOp() != null) sb.append("op: ").append(getOp()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DatasetRecord == false) return false; DatasetRecord other = (DatasetRecord) obj; if (other.getOldValue() == null ^ this.getOldValue() == null) return false; if (other.getOldValue() != null && other.getOldValue().equals(this.getOldValue()) == false) return false; if (other.getNewValue() == null ^ this.getNewValue() == null) return false; if (other.getNewValue() != null && other.getNewValue().equals(this.getNewValue()) == false) return false; if (other.getOp() == null ^ this.getOp() == null) return false; if (other.getOp() != null && other.getOp().equals(this.getOp()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getOldValue() == null) ? 0 : getOldValue().hashCode()); hashCode = prime * hashCode + ((getNewValue() == null) ? 0 : getNewValue().hashCode()); hashCode = prime * hashCode + ((getOp() == null) ? 0 : getOp().hashCode()); return hashCode; } @Override public DatasetRecord clone() { try { return (DatasetRecord) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor * (Not available in v1) */ public CognitoEvent() {} /** * Gets the region in which data set resides. * @return aws region */ public String getRegion() { return region; } /** * Sets the region in which data set resides. * @param region A string containing a region name */ public void setRegion(String region) { this.region = region; } /** * @param region String of region name * @return CognitoEvent */ public CognitoEvent withRegion(String region) { setRegion(region); return this; } /** * Gets the map of data set records for the event * @return map of dataset records */ public Map<String, DatasetRecord> getDatasetRecords() { return datasetRecords; } /** * Sets the map of data set records for the event * @param datasetRecords A map of string & data set record key/value pairs */ public void setDatasetRecords(Map<String, DatasetRecord> datasetRecords) { this.datasetRecords = datasetRecords; } /** * @param datasetRecords a map of string & data set record key/value pairs * @return CognitoEvent */ public CognitoEvent withDatasetRecords(Map<String, DatasetRecord> datasetRecords) { setDatasetRecords(datasetRecords); return this; } /** * Gets the identity pool ID associated with the data set * @return identity pool id */ public String getIdentityPoolId() { return identityPoolId; } /** * Sets the identity pool ID associated with the data set * @param identityPoolId A string containing the identity pool ID. */ public void setIdentityPoolId(String identityPoolId) { this.identityPoolId = identityPoolId; } /** * @param identityPoolId a string containing the identity pool ID * @return CognitoEvent */ public CognitoEvent withIdentityPoolId(String identityPoolId) { setIdentityPoolId(identityPoolId); return this; } /** * Gets the identity pool ID associated with the data set * @return identity id */ public String getIdentityId() { return identityId; } /** * Sets the identity pool ID associated with the data set * @param identityId A string containing the identity pool ID */ public void setIdentityId(String identityId) { this.identityId = identityId; } /** * @param identityId a string containing identity id * @return CognitoEvent */ public CognitoEvent withIdentityId(String identityId) { setIdentityId(identityId); return this; } /** * Gets the data set name of the event * @return dataset name */ public String getDatasetName() { return datasetName; } /** * Sets the data set name for the event * @param datasetName A string containing the data set name */ public void setDatasetName(String datasetName) { this.datasetName = datasetName; } /** * @param datasetName String with data set name * @return CognitoEvent */ public CognitoEvent withDatasetName(String datasetName) { setDatasetName(datasetName); return this; } /** * Gets the event type * @return event type */ public String getEventType() { return eventType; } /** * Sets the event type * @param eventType A string containing the event type */ public void setEventType(String eventType) { this.eventType = eventType; } /** * @param eventType String with event type * @return CognitoEvent */ public CognitoEvent withEventType(String eventType) { setEventType(eventType); return this; } /** * Gets the event version * @return version as integer */ public Integer getVersion() { return version; } /** * Sets the event version * @param version An integer representing the event version */ public void setVersion(Integer version) { this.version = version; } /** * @param version Integer with version * @return CognitoEvent */ public CognitoEvent withVersion(Integer version) { setVersion(version); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRegion() != null) sb.append("region: ").append(getRegion()).append(","); if (getDatasetRecords() != null) sb.append("datasetRecords: ").append(getDatasetRecords().toString()).append(","); if (getIdentityPoolId() != null) sb.append("identityPoolId: ").append(getIdentityPoolId()).append(","); if (getIdentityId() != null) sb.append("identityId: ").append(getIdentityId()).append(","); if (getDatasetName() != null) sb.append("datasetName: ").append(getDatasetName()).append(","); if (getEventType() != null) sb.append("eventType: ").append(getEventType()).append(","); if (getVersion() != null) sb.append("version: ").append(getVersion().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CognitoEvent == false) return false; CognitoEvent other = (CognitoEvent) obj; if (other.getRegion() == null ^ this.getRegion() == null) return false; if (other.getRegion() != null && other.getRegion().equals(this.getRegion()) == false) return false; if (other.getDatasetRecords() == null ^ this.getDatasetRecords() == null) return false; if (other.getDatasetRecords() != null && other.getDatasetRecords().equals(this.getDatasetRecords()) == false) return false; if (other.getIdentityPoolId() == null ^ this.getIdentityPoolId() == null) return false; if (other.getIdentityPoolId() != null && other.getIdentityPoolId().equals(this.getIdentityPoolId()) == false) return false; if (other.getIdentityId() == null ^ this.getIdentityId() == null) return false; if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false) return false; if (other.getDatasetName() == null ^ this.getDatasetName() == null) return false; if (other.getDatasetName() != null && other.getDatasetName().equals(this.getDatasetName()) == false) return false; if (other.getEventType() == null ^ this.getEventType() == null) return false; if (other.getEventType() != null && other.getEventType().equals(this.getEventType()) == false) return false; if (other.getVersion() == null ^ this.getVersion() == null) return false; if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode()); hashCode = prime * hashCode + ((getDatasetRecords() == null) ? 0 : getDatasetRecords().hashCode()); hashCode = prime * hashCode + ((getIdentityPoolId() == null) ? 0 : getIdentityPoolId().hashCode()); hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode()); hashCode = prime * hashCode + ((getDatasetName() == null) ? 0 : getDatasetName().hashCode()); hashCode = prime * hashCode + ((getEventType() == null) ? 0 : getEventType().hashCode()); hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); return hashCode; } @Override public CognitoEvent clone() { try { return (CognitoEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,791
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2HTTPEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ 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; @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor /** * API Gateway v2 event: https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html */ public class APIGatewayV2HTTPEvent { private String version; private String routeKey; private String rawPath; private String rawQueryString; private List<String> cookies; private Map<String, String> headers; private Map<String, String> queryStringParameters; private Map<String, String> pathParameters; private Map<String, String> stageVariables; private String body; private boolean isBase64Encoded; private RequestContext requestContext; @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class RequestContext { private String routeKey; private String accountId; private String stage; private String apiId; private String domainName; private String domainPrefix; private String time; private long timeEpoch; private Http http; private Authorizer authorizer; private String requestId; @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Authorizer { private JWT jwt; private Map<String, Object> lambda; private IAM iam; @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class JWT { private Map<String, String> claims; private List<String> scopes; } } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class Http { private String method; private String path; private String protocol; private String sourceIp; private String userAgent; } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class IAM { private String accessKey; private String accountId; private String callerId; private CognitoIdentity cognitoIdentity; private String principalOrgId; private String userArn; private String userId; } @AllArgsConstructor @Builder(setterPrefix = "with") @Data @NoArgsConstructor public static class CognitoIdentity { private List<String> amr; private String identityId; private String identityPoolId; } } }
1,792
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayProxyRequestEvent.java
package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; import java.util.Map; /** * Class that represents an APIGatewayProxyRequestEvent */ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable { private static final long serialVersionUID = 4189228800688527467L; private String version; private String resource; private String path; private String httpMethod; private Map<String, String> headers; private Map<String, List<String>> multiValueHeaders; private Map<String, String> queryStringParameters; private Map<String, List<String>> multiValueQueryStringParameters; private Map<String, String> pathParameters; private Map<String, String> stageVariables; private ProxyRequestContext requestContext; private String body; private Boolean isBase64Encoded; /** * class that represents proxy request context */ public static class ProxyRequestContext implements Serializable, Cloneable { private static final long serialVersionUID = 8783459961042799774L; private String accountId; private String stage; private String resourceId; private String requestId; private String operationName; private RequestIdentity identity; private String resourcePath; private String httpMethod; private String apiId; private String path; private Map<String, Object> authorizer; private String extendedRequestId; private String requestTime; private Long requestTimeEpoch; private String domainName; private String domainPrefix; private String protocol; /** * default constructor */ public ProxyRequestContext() {} /** * @return account id that owns Lambda function */ public String getAccountId() { return accountId; } /** * @param accountId account id that owns Lambda function */ public void setAccountId(String accountId) { this.accountId = accountId; } /** * @param accountId account id that owns Lambda function * @return ProxyRequestContext object */ public ProxyRequestContext withAccountId(String accountId) { this.setAccountId(accountId); return this; } public Map<String, Object> getAuthorizer() { return authorizer; } public void setAuthorizer(final Map<String, Object> authorizer) { this.authorizer = authorizer; } /** * @return API Gateway stage name */ public String getStage() { return stage; } /** * @param stage API Gateway stage name */ public void setStage(String stage) { this.stage = stage; } /** * @param stage API Gateway stage name * @return ProxyRequestContext object */ public ProxyRequestContext withStage(String stage) { this.setStage(stage); return this; } /** * @return resource id */ public String getResourceId() { return resourceId; } /** * @param resourceId resource id */ public void setResourceId(String resourceId) { this.resourceId = resourceId; } /** * @param resourceId resource id * @return ProxyRequestContext object */ public ProxyRequestContext withResourceId(String resourceId) { this.setResourceId(resourceId); return this; } /** * @return unique request id */ public String getRequestId() { return requestId; } /** * @param requestId unique request id */ public void setRequestId(String requestId) { this.requestId = requestId; } /** * @param requestId unique request id * @return ProxyRequestContext object */ public ProxyRequestContext withRequestId(String requestId) { this.setRequestId(requestId); return this; } /** * @return The identity information for the request caller */ public RequestIdentity getIdentity() { return identity; } /** * @param identity The identity information for the request caller */ public void setIdentity(RequestIdentity identity) { this.identity = identity; } /** * @param identity The identity information for the request caller * @return ProxyRequestContext object */ public ProxyRequestContext withIdentity(RequestIdentity identity) { this.setIdentity(identity); return this; } /** * @return The resource path defined in API Gateway */ public String getResourcePath() { return resourcePath; } /** * @param resourcePath The resource path defined in API Gateway */ public void setResourcePath(String resourcePath) { this.resourcePath = resourcePath; } /** * @param resourcePath The resource path defined in API Gateway * @return ProxyRequestContext object */ public ProxyRequestContext withResourcePath(String resourcePath) { this.setResourcePath(resourcePath); return this; } /** * @return The HTTP method used */ public String getHttpMethod() { return httpMethod; } /** * @param httpMethod the HTTP method used */ public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } /** * @param httpMethod the HTTP method used * @return ProxyRequestContext object */ public ProxyRequestContext withHttpMethod(String httpMethod) { this.setHttpMethod(httpMethod); return this; } /** * @return The API Gateway rest API Id. */ public String getApiId() { return apiId; } /** * @param apiId The API Gateway rest API Id. */ public void setApiId(String apiId) { this.apiId = apiId; } /** * @param apiId The API Gateway rest API Id * @return ProxyRequestContext object */ public ProxyRequestContext withApiId(String apiId) { this.setApiId(apiId); return this; } /** * @return The API Gateway path (Does not include base url) */ public String getPath() { return this.path; } /** * @param path The API Gateway path (Does not include base url) */ public void setPath(String path) { this.path = path; } /** * @param path The API Gateway path (Does not include base url) * @return ProxyRequestContext object */ public ProxyRequestContext withPath(String path) { this.setPath(path); return this; } /** * @return The name of the operation being performed * */ public String getOperationName() { return operationName; } /** * @param operationName The name of the operation being performed * */ public void setOperationName(String operationName) { this.operationName = operationName; } public ProxyRequestContext withOperationName(String operationName) { this.setOperationName(operationName); return this; } /** * @return The API Gateway Extended Request Id */ public String getExtendedRequestId() { return extendedRequestId; } /** * @param extendedRequestId The API Gateway Extended Request Id */ public void setExtendedRequestId(String extendedRequestId) { this.extendedRequestId = extendedRequestId; } /** * @param extendedRequestId The API Gateway Extended Request Id * @return ProxyRequestContext object */ public ProxyRequestContext withExtendedRequestId(String extendedRequestId) { this.setExtendedRequestId(extendedRequestId); return this; } /** * @return The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). */ public String getRequestTime() { return requestTime; } /** * @param requestTime The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). */ public void setRequestTime(String requestTime) { this.requestTime = requestTime; } /** * @param requestTime The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). * @return ProxyRequestContext object */ public ProxyRequestContext withRequestTime(String requestTime) { this.setRequestTime(requestTime); return this; } /** * @return The Epoch-formatted request time (in millis) */ public Long getRequestTimeEpoch() { return requestTimeEpoch; } /** * @param requestTimeEpoch The Epoch-formatted request time (in millis) */ public void setRequestTimeEpoch(Long requestTimeEpoch) { this.requestTimeEpoch = requestTimeEpoch; } /** * @param requestTimeEpoch The Epoch-formatted request time (in millis) * @return ProxyRequestContext object */ public ProxyRequestContext withRequestTimeEpoch(Long requestTimeEpoch) { this.setRequestTimeEpoch(requestTimeEpoch); return this; } /** * @return The full domain name used to invoke the API. This should be the same as the incoming Host header. */ public String getDomainName() { return domainName; } /** * @param domainName The full domain name used to invoke the API. * This should be the same as the incoming Host header. */ public void setDomainName(String domainName) { this.domainName = domainName; } /** * @param domainName The full domain name used to invoke the API. * This should be the same as the incoming Host header. * @return ProxyRequestContext object */ public ProxyRequestContext withDomainName(String domainName) { this.setDomainName(domainName); return this; } /** * @return The first label of the domainName. This is often used as a caller/customer identifier. */ public String getDomainPrefix() { return domainPrefix; } /** * @param domainPrefix The first label of the domainName. This is often used as a caller/customer identifier. */ public void setDomainPrefix(String domainPrefix) { this.domainPrefix = domainPrefix; } /** * @param domainPrefix The first label of the domainName. This is often used as a caller/customer identifier. * @return */ public ProxyRequestContext withDomainPrefix(String domainPrefix) { this.setDomainPrefix(domainPrefix); return this; } /** * @return The request protocol, for example, HTTP/1.1. */ public String getProtocol() { return protocol; } /** * @param protocol The request protocol, for example, HTTP/1.1. */ public void setProtocol(String protocol) { this.protocol = protocol; } /** * @param protocol The request protocol, for example, HTTP/1.1. * @return ProxyRequestContext object */ public ProxyRequestContext withProtocol(String protocol) { this.setProtocol(protocol); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAccountId() != null) sb.append("accountId: ").append(getAccountId()).append(","); if (getResourceId() != null) sb.append("resourceId: ").append(getResourceId()).append(","); if (getStage() != null) sb.append("stage: ").append(getStage()).append(","); if (getRequestId() != null) sb.append("requestId: ").append(getRequestId()).append(","); if (getIdentity() != null) sb.append("identity: ").append(getIdentity().toString()).append(","); if (getResourcePath() != null) sb.append("resourcePath: ").append(getResourcePath()).append(","); if (getHttpMethod() != null) sb.append("httpMethod: ").append(getHttpMethod()).append(","); if (getApiId() != null) sb.append("apiId: ").append(getApiId()).append(","); if (getPath() != null) sb.append("path: ").append(getPath()).append(","); if (getAuthorizer() != null) sb.append("authorizer: ").append(getAuthorizer().toString()); if (getOperationName() != null) sb.append("operationName: ").append(getOperationName().toString()); if (getExtendedRequestId() != null) sb.append("extendedRequestId: ").append(getExtendedRequestId()).append(","); if (getRequestTime() != null) sb.append("requestTime: ").append(getRequestTime()).append(","); if (getProtocol() != null) sb.append("protocol: ").append(getProtocol()).append(","); if (getRequestTimeEpoch() != null) sb.append("requestTimeEpoch: ").append(getRequestTimeEpoch()).append(","); if (getDomainPrefix() != null) sb.append("domainPrefix: ").append(getDomainPrefix()).append(","); if (getDomainName() != null) sb.append("domainName: ").append(getDomainName()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ProxyRequestContext == false) return false; ProxyRequestContext other = (ProxyRequestContext) obj; if (other.getAccountId() == null ^ this.getAccountId() == null) return false; if (other.getAccountId() != null && other.getAccountId().equals(this.getAccountId()) == false) return false; if (other.getResourceId() == null ^ this.getResourceId() == null) return false; if (other.getResourceId() != null && other.getResourceId().equals(this.getResourceId()) == false) return false; if (other.getStage() == null ^ this.getStage() == null) return false; if (other.getStage() != null && other.getStage().equals(this.getStage()) == false) return false; if (other.getRequestId() == null ^ this.getRequestId() == null) return false; if (other.getRequestId() != null && other.getRequestId().equals(this.getRequestId()) == false) return false; if (other.getIdentity() == null ^ this.getIdentity() == null) return false; if (other.getIdentity() != null && other.getIdentity().equals(this.getIdentity()) == false) return false; if (other.getResourcePath() == null ^ this.getResourcePath() == null) return false; if (other.getResourcePath() != null && other.getResourcePath().equals(this.getResourcePath()) == false) return false; if (other.getHttpMethod() == null ^ this.getHttpMethod() == null) return false; if (other.getHttpMethod() != null && other.getHttpMethod().equals(this.getHttpMethod()) == false) return false; if (other.getApiId() == null ^ this.getApiId() == null) return false; if (other.getApiId() != null && other.getApiId().equals(this.getApiId()) == false) return false; if (other.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getAuthorizer() == null ^ this.getAuthorizer() == null) return false; if (other.getAuthorizer() != null && !other.getAuthorizer().equals(this.getAuthorizer())) return false; if (other.getOperationName() == null ^ this.getOperationName() == null) return false; if (other.getOperationName() != null && !other.getOperationName().equals(this.getOperationName())) return false; if (other.getExtendedRequestId() == null ^ this.getExtendedRequestId() == null) return false; if (other.getExtendedRequestId() != null && other.getExtendedRequestId().equals(this.getExtendedRequestId()) == false) return false; if (other.getRequestTime() == null ^ this.getRequestTime() == null) return false; if (other.getRequestTime() != null && other.getRequestTime().equals(this.getRequestTime()) == false) return false; if (other.getRequestTimeEpoch() == null ^ this.getRequestTimeEpoch() == null) return false; if (other.getRequestTimeEpoch() != null && other.getRequestTimeEpoch().equals(this.getRequestTimeEpoch()) == false) return false; if (other.getDomainName() == null ^ this.getDomainName() == null) return false; if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false; if (other.getDomainPrefix() == null ^ this.getDomainPrefix() == null) return false; if (other.getDomainPrefix() != null && other.getDomainPrefix().equals(this.getDomainPrefix()) == false) return false; if (other.getProtocol() == null ^ this.getProtocol() == null) return false; if (other.getProtocol() != null && other.getProtocol().equals(this.getProtocol()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAccountId() == null) ? 0 : getAccountId().hashCode()); hashCode = prime * hashCode + ((getResourceId() == null) ? 0 : getResourceId().hashCode()); hashCode = prime * hashCode + ((getStage() == null) ? 0 : getStage().hashCode()); hashCode = prime * hashCode + ((getRequestId() == null) ? 0 : getRequestId().hashCode()); hashCode = prime * hashCode + ((getIdentity() == null) ? 0 : getIdentity().hashCode()); hashCode = prime * hashCode + ((getResourcePath() == null) ? 0 : getResourcePath().hashCode()); hashCode = prime * hashCode + ((getHttpMethod() == null) ? 0 : getHttpMethod().hashCode()); hashCode = prime * hashCode + ((getApiId() == null) ? 0 : getApiId().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getAuthorizer() == null) ? 0 : getAuthorizer().hashCode()); hashCode = prime * hashCode + ((getOperationName() == null) ? 0: getOperationName().hashCode()); hashCode = prime * hashCode + ((getExtendedRequestId() == null) ? 0 : getExtendedRequestId().hashCode()); hashCode = prime * hashCode + ((getRequestTime() == null) ? 0 : getRequestTime().hashCode()); hashCode = prime * hashCode + ((getRequestTimeEpoch() == null) ? 0 : getRequestTimeEpoch().hashCode()); hashCode = prime * hashCode + ((getDomainName() == null) ? 0 : getDomainName().hashCode()); hashCode = prime * hashCode + ((getDomainPrefix() == null) ? 0 : getDomainPrefix().hashCode()); hashCode = prime * hashCode + ((getProtocol() == null) ? 0 : getProtocol().hashCode()); return hashCode; } @Override public ProxyRequestContext clone() { try { return (ProxyRequestContext) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } public static class RequestIdentity implements Serializable, Cloneable { private static final long serialVersionUID = -5283829736983640346L; private String cognitoIdentityPoolId; private String accountId; private String cognitoIdentityId; private String caller; private String apiKey; private String principalOrgId; private String sourceIp; private String cognitoAuthenticationType; private String cognitoAuthenticationProvider; private String userArn; private String userAgent; private String user; private String accessKey; /** * default constructor */ public RequestIdentity() {} /** * @return The Cognito identity pool id. */ public String getCognitoIdentityPoolId() { return cognitoIdentityPoolId; } /** * @param cognitoIdentityPoolId The Cognito identity pool id. */ public void setCognitoIdentityPoolId(String cognitoIdentityPoolId) { this.cognitoIdentityPoolId = cognitoIdentityPoolId; } /** * @param cognitoIdentityPoolId The Cognito Identity pool id * @return RequestIdentity object */ public RequestIdentity withCognitoIdentityPoolId(String cognitoIdentityPoolId) { this.setCognitoIdentityPoolId(cognitoIdentityPoolId); return this; } /** * @return The account id that owns the executing Lambda function */ public String getAccountId() { return accountId; } /** * @param accountId The account id that owns the executing Lambda function */ public void setAccountId(String accountId) { this.accountId = accountId; } /** * @param accountId The account id that owns the executing Lambda function * @return RequestIdentity object */ public RequestIdentity withAccountId(String accountId) { this.setAccountId(accountId); return this; } /** * @return The cognito identity id. */ public String getCognitoIdentityId() { return cognitoIdentityId; } /** * @param cognitoIdentityId The cognito identity id. */ public void setCognitoIdentityId(String cognitoIdentityId) { this.cognitoIdentityId = cognitoIdentityId; } /** * @param cognitoIdentityId The cognito identity id * @return RequestIdentity object */ public RequestIdentity withCognitoIdentityId(String cognitoIdentityId) { this.setCognitoIdentityId(cognitoIdentityId); return this; } /** * @return the caller */ public String getCaller() { return caller; } /** * @param caller the caller */ public void setCaller(String caller) { this.caller = caller; } /** * @param caller the caller * @return RequestIdentity object */ public RequestIdentity withCaller(String caller) { this.setCaller(caller); return this; } /** * @return the api key */ public String getApiKey() { return apiKey; } /** * @param apiKey the api key */ public void setApiKey(String apiKey) { this.apiKey = apiKey; } /** * @param apiKey the api key * @return RequestIdentity object */ public RequestIdentity withApiKey(String apiKey) { this.setApiKey(apiKey); return this; } /** * @return the principal org Id */ public String getPrincipalOrgId() { return principalOrgId; } /** * @param principalOrgId the principal org Id */ public void setPrincipalOrgId(String principalOrgId) { this.principalOrgId = principalOrgId; } /** * @param principalOrgId the principal org Id * @return RequestIdentity object */ public RequestIdentity withPrincipalOrgId(String principalOrgId) { this.setPrincipalOrgId(principalOrgId); return this; } /** * @return source ip address */ public String getSourceIp() { return sourceIp; } /** * @param sourceIp source ip address */ public void setSourceIp(String sourceIp) { this.sourceIp = sourceIp; } /** * @param sourceIp source ip address * @return RequestIdentity object */ public RequestIdentity withSourceIp(String sourceIp) { this.setSourceIp(sourceIp); return this; } /** * @return The Cognito authentication type used for authentication */ public String getCognitoAuthenticationType() { return cognitoAuthenticationType; } /** * @param cognitoAuthenticationType The Cognito authentication type used for authentication */ public void setCognitoAuthenticationType(String cognitoAuthenticationType) { this.cognitoAuthenticationType = cognitoAuthenticationType; } /** * @param cognitoAuthenticationType The Cognito authentication type used for authentication * @return */ public RequestIdentity withCognitoAuthenticationType(String cognitoAuthenticationType) { this.setCognitoAuthenticationType(cognitoAuthenticationType); return this; } /** * @return The Cognito authentication provider */ public String getCognitoAuthenticationProvider() { return cognitoAuthenticationProvider; } /** * @param cognitoAuthenticationProvider The Cognito authentication provider */ public void setCognitoAuthenticationProvider(String cognitoAuthenticationProvider) { this.cognitoAuthenticationProvider = cognitoAuthenticationProvider; } /** * @param cognitoAuthenticationProvider The Cognito authentication provider * @return RequestIdentity object */ public RequestIdentity withCognitoAuthenticationProvider(String cognitoAuthenticationProvider) { this.setCognitoAuthenticationProvider(cognitoAuthenticationProvider); return this; } /** * @return the user arn */ public String getUserArn() { return userArn; } /** * @param userArn user arn */ public void setUserArn(String userArn) { this.userArn = userArn; } /** * @param userArn user arn * @return RequestIdentity object */ public RequestIdentity withUserArn(String userArn) { this.setUserArn(userArn); return this; } /** * @return user agent */ public String getUserAgent() { return userAgent; } /** * @param userAgent user agent */ public void setUserAgent(String userAgent) { this.userAgent = userAgent; } /** * @param userAgent user agent * @return RequestIdentityType */ public RequestIdentity withUserAgent(String userAgent) { this.setUserAgent(userAgent); return this; } /** * @return user */ public String getUser() { return user; } /** * @param user user */ public void setUser(String user) { this.user = user; } /** * @param user user * @return RequestIdentity */ public RequestIdentity withUser(String user) { this.setUser(user); return this; } /** * @return access key */ public String getAccessKey() { return this.accessKey; } /** * @param accessKey Cognito access key */ public void setAccessKey(String accessKey) { this.accessKey = accessKey; } /** * @param accessKey Cognito access key * @return RequestIdentity */ public RequestIdentity withAccessKey(String accessKey) { this.setAccessKey(accessKey); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCognitoIdentityPoolId() != null) sb.append("cognitoIdentityPoolId: ").append(getCognitoIdentityPoolId()).append(","); if (getAccountId() != null) sb.append("accountId: ").append(getAccountId()).append(","); if (getCognitoIdentityId() != null) sb.append("cognitoIdentityId: ").append(getCognitoIdentityId()).append(","); if (getCaller() != null) sb.append("caller: ").append(getCaller()).append(","); if (getApiKey() != null) sb.append("apiKey: ").append(getApiKey()).append(","); if (getPrincipalOrgId() != null) sb.append("principalOrgId: ").append(getPrincipalOrgId()).append(","); if (getSourceIp() != null) sb.append("sourceIp: ").append(getSourceIp()).append(","); if (getCognitoAuthenticationType() != null) sb.append("eventTriggerConfigId: ").append(getCognitoAuthenticationType()).append(","); if (getCognitoAuthenticationProvider() != null) sb.append("cognitoAuthenticationProvider: ").append(getCognitoAuthenticationProvider()).append(","); if (getUserArn() != null) sb.append("userArn: ").append(getUserArn()).append(","); if (getUserAgent() != null) sb.append("userAgent: ").append(getUserAgent()).append(","); if (getUser() != null) sb.append("user: ").append(getUser()).append(","); if (getAccessKey() != null) sb.append("accessKey: ").append(getAccessKey()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof RequestIdentity == false) return false; RequestIdentity other = (RequestIdentity) obj; if (other.getCognitoIdentityPoolId() == null ^ this.getCognitoIdentityPoolId() == null) return false; if (other.getCognitoIdentityPoolId() != null && other.getCognitoIdentityPoolId().equals(this.getCognitoIdentityPoolId()) == false) return false; if (other.getAccountId() == null ^ this.getAccountId() == null) return false; if (other.getAccountId() != null && other.getAccountId().equals(this.getAccountId()) == false) return false; if (other.getCognitoIdentityId() == null ^ this.getCognitoIdentityId() == null) return false; if (other.getCognitoIdentityId() != null && other.getCognitoIdentityId().equals(this.getCognitoIdentityId()) == false) return false; if (other.getCaller() == null ^ this.getCaller() == null) return false; if (other.getCaller() != null && other.getCaller().equals(this.getCaller()) == false) return false; if (other.getApiKey() == null ^ this.getApiKey() == null) return false; if (other.getApiKey() != null && other.getApiKey().equals(this.getApiKey()) == false) return false; if (other.getPrincipalOrgId() == null ^ this.getPrincipalOrgId() == null) return false; if (other.getPrincipalOrgId() != null && other.getPrincipalOrgId().equals(this.getPrincipalOrgId()) == false) return false; if (other.getSourceIp() == null ^ this.getSourceIp() == null) return false; if (other.getSourceIp() != null && other.getSourceIp().equals(this.getSourceIp()) == false) return false; if (other.getCognitoAuthenticationType() == null ^ this.getCognitoAuthenticationType() == null) return false; if (other.getCognitoAuthenticationType() != null && other.getCognitoAuthenticationType().equals(this.getCognitoAuthenticationType()) == false) return false; if (other.getCognitoAuthenticationProvider() == null ^ this.getCognitoAuthenticationProvider() == null) return false; if (other.getCognitoAuthenticationProvider() != null && other.getCognitoAuthenticationProvider().equals(this.getCognitoAuthenticationProvider()) == false) return false; if (other.getUserArn() == null ^ this.getUserArn() == null) return false; if (other.getUserArn() != null && other.getUserArn().equals(this.getUserArn()) == false) return false; if (other.getUserAgent() == null ^ this.getUserAgent() == null) return false; if (other.getUserAgent() != null && other.getUserAgent().equals(this.getUserAgent()) == false) return false; if (other.getUser() == null ^ this.getUser() == null) return false; if (other.getUser() != null && other.getUser().equals(this.getUser()) == false) return false; if (other.getAccessKey() == null ^ this.getAccessKey() == null) return false; if (other.getAccessKey() != null && other.getAccessKey().equals(this.getAccessKey()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCognitoIdentityPoolId() == null) ? 0 : getCognitoIdentityPoolId().hashCode()); hashCode = prime * hashCode + ((getAccountId() == null) ? 0 : getAccountId().hashCode()); hashCode = prime * hashCode + ((getCognitoIdentityId() == null) ? 0 : getCognitoIdentityId().hashCode()); hashCode = prime * hashCode + ((getCognitoIdentityId() == null) ? 0 : getCognitoIdentityId().hashCode()); hashCode = prime * hashCode + ((getCaller() == null) ? 0 : getCaller().hashCode()); hashCode = prime * hashCode + ((getApiKey() == null) ? 0 : getApiKey().hashCode()); hashCode = prime * hashCode + ((getPrincipalOrgId() == null) ? 0 : getPrincipalOrgId().hashCode()); hashCode = prime * hashCode + ((getSourceIp() == null) ? 0 : getSourceIp().hashCode()); hashCode = prime * hashCode + ((getCognitoAuthenticationType() == null) ? 0 : getCognitoAuthenticationType().hashCode()); hashCode = prime * hashCode + ((getCognitoAuthenticationProvider() == null) ? 0 : getCognitoAuthenticationProvider().hashCode()); hashCode = prime * hashCode + ((getUserArn() == null) ? 0 : getUserArn().hashCode()); hashCode = prime * hashCode + ((getUserAgent() == null) ? 0 : getUserAgent().hashCode()); hashCode = prime * hashCode + ((getUser() == null) ? 0 : getUser().hashCode()); hashCode = prime * hashCode + ((getAccessKey() == null) ? 0 : getAccessKey().hashCode()); return hashCode; } @Override public RequestIdentity clone() { try { return (RequestIdentity) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor */ public APIGatewayProxyRequestEvent() {} /** * @return The payload format version */ public String getVersion() { return version; } /** * @param version The payload format version */ public void setVersion(String version) { this.version = version; } /** * @param version The payload format version * @return */ public APIGatewayProxyRequestEvent withVersion(String version) { this.setVersion(version); return this; } /** * @return The resource path defined in API Gateway */ public String getResource() { return resource; } /** * @param resource The resource path defined in API Gateway */ public void setResource(String resource) { this.resource = resource; } /** * @param resource The resource path defined in API Gateway * @return */ public APIGatewayProxyRequestEvent withResource(String resource) { this.setResource(resource); return this; } /** * @return The url path for the caller */ public String getPath() { return path; } /** * @param path The url path for the caller */ public void setPath(String path) { this.path = path; } /** * @param path The url path for the caller * @return APIGatewayProxyRequestEvent object */ public APIGatewayProxyRequestEvent withPath(String path) { this.setPath(path); return this; } /** * @return The HTTP method used */ public String getHttpMethod() { return httpMethod; } /** * @param httpMethod The HTTP method used */ public void setHttpMethod(String httpMethod) { this.httpMethod = httpMethod; } /** * @param httpMethod The HTTP method used * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withHttpMethod(String httpMethod) { this.setHttpMethod(httpMethod); return this; } /** * @return The headers sent with the request */ public Map<String, String> getHeaders() { return headers; } /** * @param headers The headers sent with the request */ public void setHeaders(Map<String, String> headers) { this.headers = headers; } /** * @param headers The headers sent with the request * @return APIGatewayProxyRequestEvent object */ public APIGatewayProxyRequestEvent withHeaders(Map<String, String> headers) { this.setHeaders(headers); return this; } /** * @return The multi value headers sent with the request */ public Map<String, List<String>> getMultiValueHeaders() { return multiValueHeaders; } /** * @param multiValueHeaders The multi value headers sent with the request */ public void setMultiValueHeaders(Map<String, List<String>> multiValueHeaders) { this.multiValueHeaders = multiValueHeaders; } /** * @param multiValueHeaders The multi value headers sent with the request * @return APIGatewayProxyRequestEvent object */ public APIGatewayProxyRequestEvent withMultiValueHeaders(Map<String, List<String>> multiValueHeaders) { this.setMultiValueHeaders(multiValueHeaders); return this; } /** * @return The query string parameters that were part of the request */ public Map<String, String> getQueryStringParameters() { return queryStringParameters; } /** * @param queryStringParameters The query string parameters that were part of the request */ public void setQueryStringParameters(Map<String, String> queryStringParameters) { this.queryStringParameters = queryStringParameters; } /** * @param queryStringParameters The query string parameters that were part of the request * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withQueryStringParameters(Map<String, String> queryStringParameters) { this.setQueryStringParameters(queryStringParameters); return this; } /** * @deprecated Because of typo in method's name, use {@link #withQueryStringParameters} instead. */ @Deprecated public APIGatewayProxyRequestEvent withQueryStringParamters(Map<String, String> queryStringParameters) { return withQueryStringParameters(queryStringParameters); } /** * @return The multi value query string parameters that were part of the request */ public Map<String, List<String>> getMultiValueQueryStringParameters() { return multiValueQueryStringParameters; } /** * @param multiValueQueryStringParameters The multi value query string parameters that were part of the request */ public void setMultiValueQueryStringParameters(Map<String, List<String>> multiValueQueryStringParameters) { this.multiValueQueryStringParameters = multiValueQueryStringParameters; } /** * @param multiValueQueryStringParameters The multi value query string parameters that were part of the request * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withMultiValueQueryStringParameters(Map<String, List<String>> multiValueQueryStringParameters) { this.setMultiValueQueryStringParameters(multiValueQueryStringParameters); return this; } /** * @return The path parameters that were part of the request */ public Map<String, String> getPathParameters() { return pathParameters; } /** * @param pathParameters The path parameters that were part of the request */ public void setPathParameters(Map<String, String> pathParameters) { this.pathParameters = pathParameters; } /** * @param pathParameters The path parameters that were part of the request * @return APIGatewayProxyRequestEvent object */ public APIGatewayProxyRequestEvent withPathParameters(Map<String, String> pathParameters) { this.setPathParameters(pathParameters); return this; } /** * @deprecated Because of typo in method's name, use {@link #withPathParameters} instead. */ @Deprecated public APIGatewayProxyRequestEvent withPathParamters(Map<String, String> pathParameters) { return withPathParameters(pathParameters); } /** * @return The stage variables defined for the stage in API Gateway */ public Map<String, String> getStageVariables() { return stageVariables; } /** * @param stageVariables The stage variables defined for the stage in API Gateway */ public void setStageVariables(Map<String, String> stageVariables) { this.stageVariables = stageVariables; } /** * @param stageVariables The stage variables defined for the stage in API Gateway * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withStageVariables(Map<String, String> stageVariables) { this.setStageVariables(stageVariables); return this; } /** * @return The request context for the request */ public ProxyRequestContext getRequestContext() { return requestContext; } /** * @param requestContext The request context for the request */ public void setRequestContext(ProxyRequestContext requestContext) { this.requestContext = requestContext; } /** * @param requestContext The request context for the request * @return APIGatewayProxyRequestEvent object */ public APIGatewayProxyRequestEvent withRequestContext(ProxyRequestContext requestContext) { this.setRequestContext(requestContext); return this; } /** * @return The HTTP request body. */ public String getBody() { return body; } /** * @param body The HTTP request body. */ public void setBody(String body) { this.body = body; } /** * @param body The HTTP request body * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withBody(String body) { this.setBody(body); return this; } /** * @return whether the body String is base64 encoded. */ public Boolean getIsBase64Encoded() { return this.isBase64Encoded; } /** * @param isBase64Encoded Whether the body String is base64 encoded */ public void setIsBase64Encoded(Boolean isBase64Encoded) { this.isBase64Encoded = isBase64Encoded; } /** * @param isBase64Encoded Whether the body String is base64 encoded * @return APIGatewayProxyRequestEvent */ public APIGatewayProxyRequestEvent withIsBase64Encoded(Boolean isBase64Encoded) { this.setIsBase64Encoded(isBase64Encoded); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getVersion() != null) sb.append("version: ").append(getVersion()).append(","); if (getResource() != null) sb.append("resource: ").append(getResource()).append(","); if (getPath() != null) sb.append("path: ").append(getPath()).append(","); if (getHttpMethod() != null) sb.append("httpMethod: ").append(getHttpMethod()).append(","); if (getHeaders() != null) sb.append("headers: ").append(getHeaders().toString()).append(","); if (getMultiValueHeaders() != null) sb.append("multiValueHeaders: ").append(getMultiValueHeaders().toString()).append(","); if (getQueryStringParameters() != null) sb.append("queryStringParameters: ").append(getQueryStringParameters().toString()).append(","); if (getMultiValueQueryStringParameters() != null) sb.append("multiValueQueryStringParameters: ").append(getMultiValueQueryStringParameters().toString()).append(","); if (getPathParameters() != null) sb.append("pathParameters: ").append(getPathParameters().toString()).append(","); if (getStageVariables() != null) sb.append("stageVariables: ").append(getStageVariables().toString()).append(","); if (getRequestContext() != null) sb.append("requestContext: ").append(getRequestContext().toString()).append(","); if (getBody() != null) sb.append("body: ").append(getBody()).append(","); if (getIsBase64Encoded() != null) sb.append("isBase64Encoded: ").append(getIsBase64Encoded()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof APIGatewayProxyRequestEvent == false) return false; APIGatewayProxyRequestEvent other = (APIGatewayProxyRequestEvent) obj; if (other.getVersion() == null ^ this.getVersion() == null) return false; if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; if (other.getResource() == null ^ this.getResource() == null) return false; if (other.getResource() != null && other.getResource().equals(this.getResource()) == false) return false; if (other.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getHttpMethod() == null ^ this.getHttpMethod() == null) return false; if (other.getHttpMethod() != null && other.getHttpMethod().equals(this.getHttpMethod()) == false) return false; if (other.getHeaders() == null ^ this.getHeaders() == null) return false; if (other.getHeaders() != null && other.getHeaders().equals(this.getHeaders()) == false) return false; if (other.getMultiValueHeaders() == null ^ this.getMultiValueHeaders() == null) return false; if (other.getMultiValueHeaders() != null && other.getMultiValueHeaders().equals(this.getMultiValueHeaders()) == false) return false; if (other.getQueryStringParameters() == null ^ this.getQueryStringParameters() == null) return false; if (other.getQueryStringParameters() != null && other.getQueryStringParameters().equals(this.getQueryStringParameters()) == false) return false; if (other.getMultiValueQueryStringParameters() == null ^ this.getMultiValueQueryStringParameters() == null) return false; if (other.getMultiValueQueryStringParameters() != null && other.getMultiValueQueryStringParameters().equals(this.getMultiValueQueryStringParameters()) == false) return false; if (other.getPathParameters() == null ^ this.getPathParameters() == null) return false; if (other.getPathParameters() != null && other.getPathParameters().equals(this.getPathParameters()) == false) return false; if (other.getStageVariables() == null ^ this.getStageVariables() == null) return false; if (other.getStageVariables() != null && other.getStageVariables().equals(this.getStageVariables()) == false) return false; if (other.getRequestContext() == null ^ this.getRequestContext() == null) return false; if (other.getRequestContext() != null && other.getRequestContext().equals(this.getRequestContext()) == false) return false; if (other.getBody() == null ^ this.getBody() == null) return false; if (other.getBody() != null && other.getBody().equals(this.getBody()) == false) return false; if (other.getIsBase64Encoded() == null ^ this.getIsBase64Encoded() == null) return false; if (other.getIsBase64Encoded() != null && other.getIsBase64Encoded().equals(this.getIsBase64Encoded()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); hashCode = prime * hashCode + ((getResource() == null) ? 0 : getResource().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getHttpMethod() == null) ? 0 : getHttpMethod().hashCode()); hashCode = prime * hashCode + ((getHeaders() == null) ? 0 : getHeaders().hashCode()); hashCode = prime * hashCode + ((getMultiValueHeaders() == null) ? 0 : getMultiValueHeaders().hashCode()); hashCode = prime * hashCode + ((getQueryStringParameters() == null) ? 0 : getQueryStringParameters().hashCode()); hashCode = prime * hashCode + ((getMultiValueQueryStringParameters() == null) ? 0 : getMultiValueQueryStringParameters().hashCode()); hashCode = prime * hashCode + ((getPathParameters() == null) ? 0 : getPathParameters().hashCode()); hashCode = prime * hashCode + ((getStageVariables() == null) ? 0 : getStageVariables().hashCode()); hashCode = prime * hashCode + ((getRequestContext() == null) ? 0 : getRequestContext().hashCode()); hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode()); hashCode = prime * hashCode + ((getIsBase64Encoded() == null) ? 0 : getIsBase64Encoded().hashCode()); return hashCode; } @Override public APIGatewayProxyRequestEvent clone() { try { return (APIGatewayProxyRequestEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,793
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ConfigEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; /** * Represents an event for an AWS Config rule's function. */ public class ConfigEvent implements Serializable, Cloneable { private static final long serialVersionUID = -3484211708255634243L; private String version; private String invokingEvent; private String ruleParameters; private String resultToken; private String configRuleArn; private String configRuleId; private String configRuleName; private String accountId; private String executionRoleArn; private boolean eventLeftScope; /** * default constructor */ public ConfigEvent() {} /** * Gets the AWS Config event version. * */ public String getVersion() { return version; } /** * Sets the AWS Config event version. * @param version String containing the event version. */ public void setVersion(String version) { this.version = version; } /** * @param version config event version * @return Config Event */ public ConfigEvent withVersion(String version) { setVersion(version); return this; } /** * Gets the JSON-encoded notification published by AWS Config. * */ public String getInvokingEvent() { return invokingEvent; } /** * Sets the JSON-encoded notification published by AWS Config. * @param invokingEvent String containing the notification published by AWS Config. */ public void setInvokingEvent(String invokingEvent) { this.invokingEvent = invokingEvent; } /** * @param invokingEvent invoking event * @return Config Event */ public ConfigEvent withInvokingEvent(String invokingEvent) { setInvokingEvent(invokingEvent); return this; } /** * Gets the JSON-encoded map containing the AWS Config rule parameters. * */ public String getRuleParameters() { return ruleParameters; } /** * Sets the JSON-encoded map containing the AWS Config rule parameters. * @param ruleParameters String containing the AWS Config rule parameters. */ public void setRuleParameters(String ruleParameters) { this.ruleParameters = ruleParameters; } /** * @param ruleParameters String with rule parameters * @return ConfigEvent */ public ConfigEvent withRuleParameters(String ruleParameters) { setRuleParameters(ruleParameters); return this; } /** * Gets the token associated with the invocation of the AWS Config rule's Lambda function. * */ public String getResultToken() { return resultToken; } /** * Sets the token associated with the invocation of the AWS Config rule's Lambda function. * @param resultToken String containing the token associated to the invocation. */ public void setResultToken(String resultToken) { this.resultToken = resultToken; } /** * @param resultToken result token * @return ConfigEvent */ public ConfigEvent withResultToken(String resultToken) { setResultToken(resultToken); return this; } /** * Gets the ARN of the AWS Config rule that triggered the event. * */ public String getConfigRuleArn() { return configRuleArn; } /** * Sets the ARN of the AWS Config rule that triggered the event. * @param configRuleArn String containing the AWS Config rule ARN. */ public void setConfigRuleArn(String configRuleArn) { this.configRuleArn = configRuleArn; } /** * @param configRuleArn config rule for arn * @return ConfigEvent */ public ConfigEvent withConfigRuleArn(String configRuleArn) { setConfigRuleArn(configRuleArn); return this; } /** * Gets the ID of the AWS Config rule that triggered the event. * */ public String getConfigRuleId() { return configRuleId; } /** * Sets the ID of the AWS Config rule that triggered the event. * @param configRuleId String containing the AWS Config rule ID. */ public void setConfigRuleId(String configRuleId) { this.configRuleId = configRuleId; } /** * @param configRuleId config rule id * @return ConfigEvent */ public ConfigEvent withConfigRuleId(String configRuleId) { setConfigRuleId(configRuleId); return this; } /** * Gets the name of the AWS Config rule that triggered the event. * */ public String getConfigRuleName() { return configRuleName; } /** * Sets the name of the AWS Config rule that triggered the event. * @param configRuleName String containing the AWS Config rule name. */ public void setConfigRuleName(String configRuleName) { this.configRuleName = configRuleName; } /** * @param configRuleName config rule name * @return ConfigEvent */ public ConfigEvent withConfigRuleName(String configRuleName) { setConfigRuleName(configRuleName); return this; } /** * Gets the account ID of the AWS Config rule that triggered the event. * */ public String getAccountId() { return accountId; } /** * Sets the account ID of the AWS Config rule that triggered the event. * @param accountId String containing the account ID of the AWS Config rule. */ public void setAccountId(String accountId) { this.accountId = accountId; } /** * @param accountId Account id * @return Config Event */ public ConfigEvent withAccountId(String accountId) { setAccountId(accountId); return this; } /** * Gets the ARN of the IAM role that is assigned to AWS Config. * */ public String getExecutionRoleArn() { return executionRoleArn; } /** * Sets the ARN of the IAM role that is assigned to AWS Config. * @param executionRoleArn String containing the IAM role assigned to AWS Config. */ public void setExecutionRoleArn(String executionRoleArn) { this.executionRoleArn = executionRoleArn; } /** * @param executionRoleArn execution role arn * @return ConfigEvent */ public ConfigEvent withExecutionRoleArn(String executionRoleArn) { setExecutionRoleArn(executionRoleArn); return this; } /** * Whether the AWS resource to be evaluated has been removed from the AWS Config rule's scope. * */ public boolean getEventLeftScope() { return eventLeftScope; } /** * Sets whether the AWS resource to be evaluated has been removed from the AWS Config rule's scope. * @param eventLeftScope Boolean flag indicating that the resource is no longer in scope. */ public void setEventLeftScope(boolean eventLeftScope) { this.eventLeftScope = eventLeftScope; } /** * @param eventLeftScope event left scope * @return ConfigEvent */ public ConfigEvent withEventLeftScope(Boolean eventLeftScope) { setEventLeftScope(eventLeftScope); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAccountId() != null) sb.append("accountId: ").append(getAccountId()).append(","); if (getConfigRuleArn() != null) sb.append("configRuleArn: ").append(getConfigRuleArn()).append(","); if (getConfigRuleId() != null) sb.append("configRulelId: ").append(getConfigRuleId()).append(","); if (getConfigRuleName() != null) sb.append("configRuleName: ").append(getConfigRuleName()).append(","); sb.append("eventLeftScope: ").append(getEventLeftScope()).append(","); if (getExecutionRoleArn() != null) sb.append("executionRoleArn: ").append(getExecutionRoleArn()).append(","); if (getInvokingEvent() != null) sb.append("invokingEvent: ").append(getInvokingEvent()).append(","); if (getResultToken() != null) sb.append("resultToken: ").append(getResultToken()).append(","); if (getRuleParameters() != null) sb.append("ruleParameters: ").append(getRuleParameters()).append(","); if (getVersion() != null) sb.append("version: ").append(getVersion()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); result = prime * result + ((configRuleArn == null) ? 0 : configRuleArn.hashCode()); result = prime * result + ((configRuleId == null) ? 0 : configRuleId.hashCode()); result = prime * result + ((configRuleName == null) ? 0 : configRuleName.hashCode()); result = prime * result + (eventLeftScope ? 1231 : 1237); result = prime * result + ((executionRoleArn == null) ? 0 : executionRoleArn.hashCode()); result = prime * result + ((invokingEvent == null) ? 0 : invokingEvent.hashCode()); result = prime * result + ((resultToken == null) ? 0 : resultToken.hashCode()); result = prime * result + ((ruleParameters == null) ? 0 : ruleParameters.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConfigEvent other = (ConfigEvent) obj; if (accountId == null) { if (other.accountId != null) return false; } else if (!accountId.equals(other.accountId)) return false; if (configRuleArn == null) { if (other.configRuleArn != null) return false; } else if (!configRuleArn.equals(other.configRuleArn)) return false; if (configRuleId == null) { if (other.configRuleId != null) return false; } else if (!configRuleId.equals(other.configRuleId)) return false; if (configRuleName == null) { if (other.configRuleName != null) return false; } else if (!configRuleName.equals(other.configRuleName)) return false; if (eventLeftScope != other.eventLeftScope) return false; if (executionRoleArn == null) { if (other.executionRoleArn != null) return false; } else if (!executionRoleArn.equals(other.executionRoleArn)) return false; if (invokingEvent == null) { if (other.invokingEvent != null) return false; } else if (!invokingEvent.equals(other.invokingEvent)) return false; if (resultToken == null) { if (other.resultToken != null) return false; } else if (!resultToken.equals(other.resultToken)) return false; if (ruleParameters == null) { if (other.ruleParameters != null) return false; } else if (!ruleParameters.equals(other.ruleParameters)) return false; if (version == null) { if (other.version != null) return false; } else if (!version.equals(other.version)) return false; return true; } @Override public ConfigEvent clone() { try { return (ConfigEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,794
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisEvent.java
/* * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; /** * Represents an Amazon Kinesis event. */ public class KinesisEvent implements Serializable, Cloneable { private static final long serialVersionUID = 8145257839787754632L; private List<KinesisEventRecord> records; /** * The unit of data of an Amazon Kinesis stream */ public static class Record extends com.amazonaws.services.lambda.runtime.events.models.kinesis.Record { private static final long serialVersionUID = 7856672931457425976L; private String kinesisSchemaVersion; /** * default constructor * (Not available in v1) */ public Record() {} /** * Gets the schema version for the record * @return kinesis schema version */ public String getKinesisSchemaVersion() { return kinesisSchemaVersion; } /** * Sets the schema version for the record * @param kinesisSchemaVersion A string containing the schema version */ public void setKinesisSchemaVersion(String kinesisSchemaVersion) { this.kinesisSchemaVersion = kinesisSchemaVersion; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getSequenceNumber() != null) sb.append("SequenceNumber: ").append(getSequenceNumber()).append(","); if (getApproximateArrivalTimestamp() != null) sb.append("ApproximateArrivalTimestamp: ").append(getApproximateArrivalTimestamp()).append(","); if (getData() != null) sb.append("Data: ").append(getData()).append(","); if (getPartitionKey() != null) sb.append("PartitionKey: ").append(getPartitionKey()).append(","); if (getEncryptionType() != null) sb.append("EncryptionType: ").append(getEncryptionType()).append(","); if (getKinesisSchemaVersion() != null) sb.append("KinesisSchemaVersion: ").append(getKinesisSchemaVersion()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Record == false) return false; Record other = (Record) obj; if (other.getSequenceNumber() == null ^ this.getSequenceNumber() == null) return false; if (other.getSequenceNumber() != null && other.getSequenceNumber().equals(this.getSequenceNumber()) == false) return false; if (other.getApproximateArrivalTimestamp() == null ^ this.getApproximateArrivalTimestamp() == null) return false; if (other.getApproximateArrivalTimestamp() != null && other.getApproximateArrivalTimestamp().equals(this.getApproximateArrivalTimestamp()) == false) return false; if (other.getData() == null ^ this.getData() == null) return false; if (other.getData() != null && other.getData().equals(this.getData()) == false) return false; if (other.getPartitionKey() == null ^ this.getPartitionKey() == null) return false; if (other.getPartitionKey() != null && other.getPartitionKey().equals(this.getPartitionKey()) == false) return false; if (other.getEncryptionType() == null ^ this.getEncryptionType() == null) return false; if (other.getEncryptionType() != null && other.getEncryptionType().equals(this.getEncryptionType()) == false) return false; if (other.getKinesisSchemaVersion() == null ^ this.getKinesisSchemaVersion() == null) return false; if (other.getKinesisSchemaVersion() != null && other.getKinesisSchemaVersion().equals(this.getKinesisSchemaVersion()) == false) return false; return true; } /* (non-Javadoc) * @see com.amazonaws.services.lambda.runtime.events.models.kinesis.Record#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((getKinesisSchemaVersion() == null) ? 0 : getKinesisSchemaVersion().hashCode()); return result; } @Override public Record clone() { return (Record) super.clone(); } } /** * Kinesis event records provide contextual data about a Kinesis record * */ public static class KinesisEventRecord implements Serializable, Cloneable { private static final long serialVersionUID = -3855723544907905206L; private String eventSource; private Record kinesis; private String eventID; private String invokeIdentityArn; private String eventName; private String eventVersion; private String eventSourceARN; private String awsRegion; /** * default constructor * (not available in v1) */ public KinesisEventRecord() {} /** * Gets the source of the event * @return event source */ public String getEventSource() { return eventSource; } /** * Sets the source of the event * @param eventSource A string representing the event source */ public void setEventSource(String eventSource) { this.eventSource = eventSource; } /** * Gets the underlying Kinesis record associated with the event. * @return Kinesis Record object */ public Record getKinesis() { return kinesis; } /** * Sets the underlying Kinesis record associated with the event. * @param kinesis A Kineis record object. */ public void setKinesis(Record kinesis) { this.kinesis = kinesis; } /** * Gets the event id. * @return event id */ public String getEventID() { return eventID; } /** * Sets the event id * @param eventID A string representing the event id. */ public void setEventID(String eventID) { this.eventID = eventID; } /** * Gets then ARN for the identity used to invoke the Lambda Function. * @return invoke arn */ public String getInvokeIdentityArn() { return invokeIdentityArn; } /** * Sets an ARN for the identity used to invoke the Lambda Function. * @param invokeIdentityArn A string representing the invoke identity ARN */ public void setInvokeIdentityArn(String invokeIdentityArn) { this.invokeIdentityArn = invokeIdentityArn; } /** * Gets the name of the event * @return event name */ public String getEventName() { return eventName; } /** * Sets the name of the event * @param eventName A string containing the event name */ public void setEventName(String eventName) { this.eventName = eventName; } /** * Gets the event version * @return event version */ public String getEventVersion() { return eventVersion; } /** * Sets the event version * @param eventVersion A string containing the event version */ public void setEventVersion(String eventVersion) { this.eventVersion = eventVersion; } /** * Gets the ARN of the event source * @return event source arn */ public String getEventSourceARN() { return eventSourceARN; } /** * Sets the ARN of the event source * @param eventSourceARN A string containing the event source ARN */ public void setEventSourceARN(String eventSourceARN) { this.eventSourceARN = eventSourceARN; } /** * Gets the AWS region where the event originated * @return aws region */ public String getAwsRegion() { return awsRegion; } /** * Sets the AWS region where the event originated * @param awsRegion A string containing the AWS region */ public void setAwsRegion(String awsRegion) { this.awsRegion = awsRegion; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getEventSource() != null) sb.append("eventSource: ").append(getEventSource()).append(","); if (getKinesis() != null) sb.append("kinesis: ").append(getKinesis().toString()).append(","); if (getEventID() != null) sb.append("eventId: ").append(getEventID()).append(","); if (getInvokeIdentityArn() != null) sb.append("invokeIdentityArn: ").append(getInvokeIdentityArn()).append(","); if (getEventName() != null) sb.append("eventName: ").append(getEventName()).append(","); if (getEventVersion() != null) sb.append("eventVersion: ").append(getEventVersion()).append(","); if (getEventSourceARN() != null) sb.append("eventSourceARN: ").append(getEventSourceARN()).append(","); if (getAwsRegion() != null) sb.append("awsRegion: ").append(getAwsRegion()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KinesisEventRecord == false) return false; KinesisEventRecord other = (KinesisEventRecord) obj; if (other.getEventSource() == null ^ this.getEventSource() == null) return false; if (other.getEventSource() != null && other.getEventSource().equals(this.getEventSource()) == false) return false; if (other.getKinesis() == null ^ this.getKinesis() == null) return false; if (other.getKinesis() != null && other.getKinesis().equals(this.getKinesis()) == false) return false; if (other.getEventID() == null ^ this.getEventID() == null) return false; if (other.getEventID() != null && other.getEventID().equals(this.getEventID()) == false) return false; if (other.getInvokeIdentityArn() == null ^ this.getInvokeIdentityArn() == null) return false; if (other.getInvokeIdentityArn() != null && other.getInvokeIdentityArn().equals(this.getInvokeIdentityArn()) == false) return false; if (other.getEventName() == null ^ this.getEventName() == null) return false; if (other.getEventName() != null && other.getEventName().equals(this.getEventName()) == false) return false; if (other.getEventVersion() == null ^ this.getEventVersion() == null) return false; if (other.getEventVersion() != null && other.getEventVersion().equals(this.getEventVersion()) == false) return false; if (other.getEventSourceARN() == null ^ this.getEventSourceARN() == null) return false; if (other.getEventSourceARN() != null && other.getEventSourceARN().equals(this.getEventSourceARN()) == false) return false; if (other.getAwsRegion() == null ^ this.getAwsRegion() == null) return false; if (other.getAwsRegion() != null && other.getAwsRegion().equals(this.getAwsRegion()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getEventSource() == null) ? 0 : getEventSource().hashCode()); hashCode = prime * hashCode + ((getKinesis() == null) ? 0 : getKinesis().hashCode()); hashCode = prime * hashCode + ((getEventID() == null) ? 0 : getEventID().hashCode()); hashCode = prime * hashCode + ((getInvokeIdentityArn() == null) ? 0 : getInvokeIdentityArn().hashCode()); hashCode = prime * hashCode + ((getEventName() == null) ? 0 : getEventName().hashCode()); hashCode = prime * hashCode + ((getEventVersion() == null) ? 0 : getEventVersion().hashCode()); hashCode = prime * hashCode + ((getEventSourceARN() == null) ? 0 : getEventSourceARN().hashCode()); hashCode = prime * hashCode + ((getAwsRegion() == null) ? 0 : getAwsRegion().hashCode()); return hashCode; } @Override public KinesisEventRecord clone() { try { return (KinesisEventRecord) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } } /** * default constructor * (Not available in v1) */ public KinesisEvent() {} /** * Gets the list of Kinesis event records * @return list of records */ public List<KinesisEventRecord> getRecords() { return records; } /** * Sets the list of Kinesis event records * @param records a list of Kinesis event records */ public void setRecords(List<KinesisEventRecord> records) { this.records = records; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRecords() != null) sb.append(getRecords().toString()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KinesisEvent == false) return false; KinesisEvent other = (KinesisEvent) obj; if (other.getRecords() == null ^ this.getRecords() == null) return false; if (other.getRecords() != null && other.getRecords().equals(this.getRecords()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRecords() == null) ? 0 : getRecords().hashCode()); return hashCode; } @Override public KinesisEvent clone() { try { return (KinesisEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,795
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/KinesisAnalyticsOutputDeliveryResponse.java
/* * Copyright 2012-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import java.io.Serializable; import java.util.List; /** * Response model for Kinesis Analytics Lambda Output delivery. */ public class KinesisAnalyticsOutputDeliveryResponse implements Serializable { public enum Result { /** * Indicates that record has been delivered successfully. */ Ok, /** * Indicates that the delivery of the record failed. */ DeliveryFailed } private static final long serialVersionUID = 4530412727972559896L; public List<Record> records; public KinesisAnalyticsOutputDeliveryResponse() { super(); } public KinesisAnalyticsOutputDeliveryResponse(List<Record> records) { super(); this.records = records; } public List<Record> getRecords() { return records; } public void setRecords(List<Record> records) { this.records = records; } public static class Record implements Serializable { private static final long serialVersionUID = -4034554254120467176L; public String recordId; public Result result; public Record() { super(); } public Record(String recordId, Result result) { super(); this.recordId = recordId; this.result = result; } public String getRecordId() { return recordId; } public void setRecordId(String recordId) { this.recordId = recordId; } public Result getResult() { return result; } public void setResult(Result result) { this.result = result; } } }
1,796
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledEvent.java
/* * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import org.joda.time.DateTime; import java.io.Serializable; import java.util.List; import java.util.Map; /** * represents a scheduled event */ public class ScheduledEvent implements Serializable, Cloneable { private static final long serialVersionUID = -5810383198587331146L; private String version; private String account; private String region; private Map<String, Object> detail; private String detailType; private String source; private String id; private DateTime time; private List<String> resources; /** * default constructor */ public ScheduledEvent() {} /** * @return the version number */ public String getVersion() { return version; } /** * @param version the version number */ public void setVersion(String version) { this.version = version; } /** * @param version version number * @return ScheduledEvent */ public ScheduledEvent withVersion(String version) { setVersion(version); return this; } /** * @return the account id */ public String getAccount() { return account; } /** * @param account the account id */ public void setAccount(String account) { this.account = account; } /** * @param account account id * @return ScheduledEvent */ public ScheduledEvent withAccount(String account) { setAccount(account); return this; } /** * @return the aws region */ public String getRegion() { return region; } /** * @param region the aws region */ public void setRegion(String region) { this.region = region; } /** * @param region aws region * @return ScheduledEvent */ public ScheduledEvent withRegion(String region) { setRegion(region); return this; } /** * @return The details of the events (usually left blank) */ public Map<String, Object> getDetail() { return detail; } /** * @param detail The details of the events (usually left blank) */ public void setDetail(Map<String, Object> detail) { this.detail = detail; } /** * @param detail details of the events (usually left blank) * @return ScheduledEvent */ public ScheduledEvent withDetail(Map<String, Object> detail) { setDetail(detail); return this; } /** * @return The details type - see cloud watch events for more info */ public String getDetailType() { return detailType; } /** * @param detailType The details type - see cloud watch events for more info */ public void setDetailType(String detailType) { this.detailType = detailType; } /** * @param detailType The details type - see cloud watch events for more info * @return ScheduledEvent */ public ScheduledEvent withDetailType(String detailType) { setDetailType(detailType); return this; } /** * @return the source of the event */ public String getSource() { return source; } /** * @param source the source of the event */ public void setSource(String source) { this.source = source; } /** * @param source source of the event * @return ScheduledEvent */ public ScheduledEvent withSource(String source) { setSource(source); return this; } /** * @return the timestamp for when the event is scheduled */ public DateTime getTime() { return this.time; } /** * @param time the timestamp for when the event is scheduled */ public void setTime(DateTime time) { this.time = time; } /** * @param time the timestamp for when the event is scheduled * @return ScheduledEvent */ public ScheduledEvent withTime(DateTime time) { setTime(time); return this; } /** * @return the id of the event */ public String getId() { return id; } /** * @param id the id of the event */ public void setId(String id) { this.id = id; } /** * @param id id of event * @return ScheduledEvent */ public ScheduledEvent withId(String id) { setId(id); return this; } /** * @return the resources used by event */ public List<String> getResources() { return this.resources; } /** * @param resources the resources used by event */ public void setResources(List<String> resources) { this.resources = resources; } /** * @param resources list of resource names * @return Scheduled event object */ public ScheduledEvent withResources(List<String> resources) { setResources(resources); return this; } /** * Returns a string representation of this object; useful for testing and debugging. * * @return A string representation of this object. * * @see Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getVersion() != null) sb.append("version: ").append(getVersion()).append(","); if (getAccount() != null) sb.append("account: ").append(getAccount()).append(","); if (getRegion() != null) sb.append("region: ").append(getRegion()).append(","); if (getDetail() != null) sb.append("detail: ").append(getDetail().toString()).append(","); if (getDetailType() != null) sb.append("detailType: ").append(getDetailType()).append(","); if (getSource() != null) sb.append("source: ").append(getSource()).append(","); if (getId() != null) sb.append("id: ").append(getId()).append(","); if (getTime() != null) sb.append("time: ").append(getTime().toString()).append(","); if (getResources() != null) sb.append("resources: ").append(getResources()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ScheduledEvent == false) return false; ScheduledEvent other = (ScheduledEvent) obj; if (other.getVersion() == null ^ this.getVersion() == null) return false; if (other.getVersion() != null && other.getVersion().equals(this.getVersion()) == false) return false; if (other.getAccount() == null ^ this.getAccount() == null) return false; if (other.getAccount() != null && other.getAccount().equals(this.getAccount()) == false) return false; if (other.getRegion() == null ^ this.getRegion() == null) return false; if (other.getRegion() != null && other.getRegion().equals(this.getRegion()) == false) return false; if (other.getDetail() == null ^ this.getDetail() == null) return false; if (other.getDetail() != null && other.getDetail().equals(this.getDetail()) == false) return false; if (other.getDetailType() == null ^ this.getDetailType() == null) return false; if (other.getDetailType() != null && other.getDetailType().equals(this.getDetailType()) == false) return false; if (other.getSource() == null ^ this.getSource() == null) return false; if (other.getSource() != null && other.getSource().equals(this.getSource()) == false) return false; if (other.getId() == null ^ this.getId() == null) return false; if (other.getId() != null && other.getId().equals(this.getId()) == false) return false; if (other.getTime() == null ^ this.getTime() == null) return false; if (other.getTime() != null && other.getTime().equals(this.getTime()) == false) return false; if (other.getResources() == null ^ this.getResources() == null) return false; if (other.getResources() != null && other.getResources().equals(this.getResources()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getVersion() == null) ? 0 : getVersion().hashCode()); hashCode = prime * hashCode + ((getAccount() == null) ? 0 : getAccount().hashCode()); hashCode = prime * hashCode + ((getRegion() == null) ? 0 : getRegion().hashCode()); hashCode = prime * hashCode + ((getDetail() == null) ? 0 : getDetail().hashCode()); hashCode = prime * hashCode + ((getDetailType() == null) ? 0 : getDetailType().hashCode()); hashCode = prime * hashCode + ((getSource() == null) ? 0 : getSource().hashCode()); hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode()); hashCode = prime * hashCode + ((getTime() == null) ? 0 : getTime().hashCode()); hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); return hashCode; } @Override public ScheduledEvent clone() { try { return (ScheduledEvent) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone()", e); } } }
1,797
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/CloudFormationCustomResourceEvent.java
/* * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Map; /** * Class to represent the custom resource request event from CloudFormation. * * CloudFormation invokes your Lambda function asynchronously with this event and includes a callback URL. The function * is responsible for returning a response to the callback URL that indicates success or failure. * * @see <a href="https://docs.aws.amazon.com/lambda/latest/dg/services-cloudformation.html">Using AWS Lambda with AWS CloudFormation</a> * * @author msailes <msailes@amazon.co.uk> */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class CloudFormationCustomResourceEvent implements Serializable, Cloneable { private String requestType; private String serviceToken; private String responseUrl; private String stackId; private String requestId; private String logicalResourceId; private String physicalResourceId; private String resourceType; private Map<String, Object> resourceProperties; private Map<String, Object> oldResourceProperties; }
1,798
0
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime
Create_ds/aws-lambda-java-libs/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayCustomAuthorizerEvent.java
package com.amazonaws.services.lambda.runtime.events; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.util.Map; /** * The API Gateway customer authorizer event object as described - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html * */ @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public class APIGatewayCustomAuthorizerEvent { private String version; private String type; private String methodArn; private String identitySource; private String authorizationToken; private String resource; private String path; private String httpMethod; private Map<String, String> headers; private Map<String, String> queryStringParameters; private Map<String, String> pathParameters; private Map<String, String> stageVariables; private RequestContext requestContext; @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class RequestContext { private String path; private String accountId; private String resourceId; private String stage; private String requestId; private Identity identity; private String resourcePath; private String httpMethod; private String apiId; } @Data @Builder(setterPrefix = "with") @NoArgsConstructor @AllArgsConstructor public static class Identity { private String apiKey; private String sourceIp; } }
1,799