Listify/Lambdas/Lists/src/main/java/InputUtils.java
NMerz de0bd51eaf Basic ListAdd Lambda
Create a basic list adding Lambda.

NOTE: This does not include the following which are still needed:
1) Permanent DB Setup
2) Better RDS access control with security groups
3) Proper input parameters for the List add Lambda
2020-09-26 16:53:44 -04:00

29 lines
1.2 KiB
Java

import java.util.Map;
public class InputUtils {
public static String getCognitoIDFromBody(Map<String, Object> inputMap) {
System.out.println(inputMap.keySet());
System.out.println(inputMap.entrySet());
Map<String, Object> contextMap;
if ((inputMap.get("context") != null) && (inputMap.get("context") instanceof Map<?, ?>)) {
contextMap = ((Map<String, Object>) inputMap.get("context"));
} else {
throw new IllegalArgumentException("The key \"context\" must exist and be a map");
}
System.out.println(inputMap.get("context"));
System.out.println(contextMap.get("sub"));
return contextMap.get("sub").toString();
}
public static Map<String, Object> getBody(Map<String, Object> inputMap) {
return getMap(inputMap, "body");
}
public static Map<String, Object> getMap(Map<String, Object> parentMap, String childKey) {
if ((parentMap.get(childKey) != null) && (parentMap.get(childKey) instanceof Map<?, ?>)) {
return ((Map<String, Object>) parentMap.get(childKey));
}
throw new IllegalArgumentException("The key \"" + childKey + "\" must exist and be a map");
}
}