use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-doc-sdk-examples by awsdocs.
the class ListMissingStudentsHandler method handleRequest.
@Override
public String handleRequest(Map<String, String> event, Context context) {
LambdaLogger logger = context.getLogger();
String date = event.get("date");
logger.log("DATE: " + date);
RDSGetStudents students = new RDSGetStudents();
String xml = null;
try {
xml = students.getStudentsRDS(date);
} catch (SQLException e) {
e.printStackTrace();
}
logger.log("XML: " + xml);
return xml;
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-doc-sdk-examples by awsdocs.
the class Handler3 method handleRequest.
@Override
public String handleRequest(String event, Context context) {
LambdaLogger logger = context.getLogger();
String email = event;
// log execution details
logger.log("Email value " + email);
SendMessage msg = new SendMessage();
try {
msg.sendMessage(email);
} catch (IOException e) {
e.getStackTrace();
}
return "";
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-doc-sdk-examples by awsdocs.
the class Handler method handleRequest.
public Void handleRequest(Context context) {
LambdaLogger logger = context.getLogger();
ScanEmployees scanEmployees = new ScanEmployees();
Boolean ans = scanEmployees.sendEmployeMessage();
if (ans)
logger.log("Messages sent: " + ans);
return null;
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-doc-sdk-examples by awsdocs.
the class PPEHandler method handleRequest.
@Override
public String handleRequest(Map<String, String> event, Context context) {
LambdaLogger logger = context.getLogger();
String bucketName = event.get("bucketName");
logger.log("Bucket name is: " + bucketName);
S3Service s3Service = new S3Service();
DynamoDBService ddb = new DynamoDBService();
AnalyzePhotos photos = new AnalyzePhotos();
SendEmail email = new SendEmail();
List<String> items = s3Service.listBucketObjects(bucketName);
List<ArrayList<GearItem>> myList = new ArrayList<>();
for (String item : items) {
byte[] keyData = s3Service.getObjectBytes(bucketName, item);
// Analyze the photo and return a list where each element is a WorkItem.
ArrayList<GearItem> gearItem = photos.detectLabels(keyData, item);
// Only add a list with items.
if (gearItem != null)
myList.add(gearItem);
}
ddb.persistItem(myList);
// Create a new list with only unique keys to email.
Set<String> unqiueKeys = createUniqueList(myList);
email.sendMsg(unqiueKeys);
logger.log("Updated the DynamoDB table with PPE data");
return bucketName;
}
use of com.amazonaws.services.lambda.runtime.LambdaLogger in project aws-doc-sdk-examples by awsdocs.
the class Handler method handleRequest.
@Override
public String handleRequest(Map<String, String> event, Context context) {
LambdaLogger logger = context.getLogger();
String delFag = event.get("flag");
logger.log("FLAG IS: " + delFag);
S3Service s3Service = new S3Service();
AnalyzePhotos photos = new AnalyzePhotos();
String bucketName = "<Enter your bucket name>";
List<String> myKeys = s3Service.listBucketObjects(bucketName);
if (delFag.compareTo("true") == 0) {
// Create a List to store the data.
List<ArrayList<WorkItem>> myList = new ArrayList<>();
// loop through each element in the List and tag the assets.
for (String key : myKeys) {
byte[] keyData = s3Service.getObjectBytes(bucketName, key);
// Analyze the photo and return a list where each element is a WorkItem.
ArrayList<WorkItem> item = photos.detectLabels(keyData, key);
myList.add(item);
}
s3Service.tagAssets(myList, bucketName);
logger.log("All Assets in the bucket are tagged!");
} else {
// Delete all object tags.
for (String key : myKeys) {
s3Service.deleteTagFromObject(bucketName, key);
logger.log("All Assets in the bucket are deleted!");
}
}
return delFag;
}
Aggregations