mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Allow multiple method creation
A resource should be able to accept multiple methods
This commit is contained in:
parent
34ed7358c5
commit
bbe0daff43
@ -1,14 +1,7 @@
|
|||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.Context;
|
public class InputUtils {
|
||||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
public static String getCognitoIDFromBody(Map<String, Object> inputMap) {
|
||||||
|
|
||||||
public class ListAdd implements RequestHandler<Map<String,Object>, String>{
|
|
||||||
|
|
||||||
|
|
||||||
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
|
||||||
System.out.println(inputMap.keySet());
|
System.out.println(inputMap.keySet());
|
||||||
System.out.println(inputMap.entrySet());
|
System.out.println(inputMap.entrySet());
|
||||||
Map<String, Object> contextMap;
|
Map<String, Object> contextMap;
|
||||||
@ -19,13 +12,5 @@ public class ListAdd implements RequestHandler<Map<String,Object>, String>{
|
|||||||
}
|
}
|
||||||
System.out.println(inputMap.get("context"));
|
System.out.println(inputMap.get("context"));
|
||||||
System.out.println(contextMap.get("sub"));
|
System.out.println(contextMap.get("sub"));
|
||||||
try {
|
|
||||||
System.out.println(new DBConnector());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
22
Lambdas/Lists/src/main/java/ListsPOST.java
Normal file
22
Lambdas/Lists/src/main/java/ListsPOST.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.amazonaws.services.lambda.runtime.Context;
|
||||||
|
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||||
|
|
||||||
|
public class ListsPOST implements RequestHandler<Map<String,Object>, String>{
|
||||||
|
|
||||||
|
|
||||||
|
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||||
|
String cognitoID = InputUtils.getCognitoIDFromBody(inputMap);
|
||||||
|
try {
|
||||||
|
System.out.println(new DBConnector());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -28,7 +28,7 @@ zipPath=${functionPath}.zip
|
|||||||
|
|
||||||
zip ${zipPath} ${jarPath}
|
zip ${zipPath} ${jarPath}
|
||||||
|
|
||||||
RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${zipPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}.lambda_handler)
|
RAWLAMBDA=$(aws lambda create-function --function-name ${functionName}${method} --zip-file fileb://${zipPath} --runtime ${LANGUAGE} --role ${LAMBDAROLE} --handler ${functionName}${method}.lambda_handler 2>${DEBUGFILE})
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Unable to create Lamba" >&2
|
echo "Unable to create Lamba" >&2
|
||||||
@ -39,12 +39,16 @@ LAMBDAARN=$(echo $RAWLAMBDA | head -n 3 | tail -n 1 | cut -d \" -f 8)
|
|||||||
|
|
||||||
echo ${LAMBDAARN} > ${DEBUGFILE}
|
echo ${LAMBDAARN} > ${DEBUGFILE}
|
||||||
|
|
||||||
RAWRESOURCEID=$(aws apigateway create-resource --rest-api-id ${APIID} --parent-id ${ROOTRESOURCEID} --path-part ${functionName})
|
RAWRESOURCEID=$(aws apigateway create-resource --rest-api-id ${APIID} --parent-id ${ROOTRESOURCEID} --path-part ${functionName} 2>${DEBUGFILE})
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo "Unable to create Resource. This needs to be handled at some future point" >&2
|
echo "Unable to create resource." > ${DEBUGFILE}
|
||||||
|
RAWRESOURCEID=$(aws apigateway get-resources --rest-api-id datoh7woc9 --query "items[?pathPart==\`${functionName}\`].{id:id}" | head -n 3 | tail -n 1)
|
||||||
|
if [[ $RAWRESOURCEID == "[]" ]]; then
|
||||||
|
echo "Unable to create or find API Gateway resource." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
RESOURCEID=$(echo ${RAWRESOURCEID} | head -n 2 | tail -n 1 | cut -d \" -f 4)
|
RESOURCEID=$(echo ${RAWRESOURCEID} | head -n 2 | tail -n 1 | cut -d \" -f 4)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user