Search in sources :

Example 1 with LambdaLogger

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;
}
Also used : SQLException(java.sql.SQLException) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 2 with LambdaLogger

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 "";
}
Also used : IOException(java.io.IOException) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 3 with LambdaLogger

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;
}
Also used : LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 4 with LambdaLogger

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;
}
Also used : ArrayList(java.util.ArrayList) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Example 5 with LambdaLogger

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;
}
Also used : ArrayList(java.util.ArrayList) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger)

Aggregations

LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)59 HashMap (java.util.HashMap)10 Date (java.util.Date)9 List (java.util.List)8 Map (java.util.Map)8 Context (com.amazonaws.services.lambda.runtime.Context)6 ApiAuthorizer (com.formkiq.lambda.apigateway.ApiAuthorizer)6 ApiGatewayRequestEvent (com.formkiq.lambda.apigateway.ApiGatewayRequestEvent)6 ApiGatewayRequestEventUtil (com.formkiq.lambda.apigateway.ApiGatewayRequestEventUtil)6 ApiGatewayRequestHandler (com.formkiq.lambda.apigateway.ApiGatewayRequestHandler)6 ApiRequestHandlerResponse (com.formkiq.lambda.apigateway.ApiRequestHandlerResponse)6 IOException (java.io.IOException)6 SC_OK (com.formkiq.lambda.apigateway.ApiResponseStatus.SC_OK)5 AwsServiceCache (com.formkiq.lambda.apigateway.AwsServiceCache)5 BadException (com.formkiq.lambda.apigateway.exception.BadException)5 DynamicObject (com.formkiq.stacks.common.objects.DynamicObject)5 Collectors (java.util.stream.Collectors)5 ClientContext (com.amazonaws.services.lambda.runtime.ClientContext)4 CognitoIdentity (com.amazonaws.services.lambda.runtime.CognitoIdentity)4 ApiMapResponse (com.formkiq.lambda.apigateway.ApiMapResponse)4