-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathHello.java
More file actions
49 lines (39 loc) · 1.68 KB
/
Hello.java
File metadata and controls
49 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package lambda;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import saaf.Inspector;
import saaf.Response;
import java.util.HashMap;
/**
* uwt.lambda_test::handleRequest
*
* @author Wes Lloyd
* @author Robert Cordingly
*/
public class Hello implements RequestHandler<HashMap<String, Object>, HashMap<String, Object>> {
/**
* Lambda Function Handler
*
* @param request Hashmap containing request JSON attributes.
* @param context
* @return HashMap that Lambda will automatically convert into JSON.
*/
public HashMap<String, Object> handleRequest(HashMap<String, Object> request, Context context) {
//Collect initial data.
Inspector inspector = new Inspector();
inspector.inspectAll();
//****************START FUNCTION IMPLEMENTATION*************************
//Add custom key/value attribute to SAAF's output. (OPTIONAL)
inspector.addAttribute("message", "Hello " + request.get("name")
+ "! This is a custom attribute added as output from SAAF!");
//Create and populate a separate response object for function output. (OPTIONAL)
Response response = new Response();
response.setValue("Hello " + request.get("name")
+ "! This is from a response object!");
inspector.consumeResponse(response);
//****************END FUNCTION IMPLEMENTATION***************************
//Collect final information such as total runtime and cpu deltas.
inspector.inspectAllDeltas();
return inspector.finish();
}
}