Search in sources :

Example 1 with GetAccountSettingsResponse

use of software.amazon.awssdk.services.lambda.model.GetAccountSettingsResponse in project aws-doc-sdk-examples by awsdocs.

the class Handler method handleRequest.

@Override
public String handleRequest(SQSEvent event, Context context) {
    String response = new String();
    // call Lambda API
    logger.info("Getting account settings");
    CompletableFuture<GetAccountSettingsResponse> accountSettings = lambdaClient.getAccountSettings(GetAccountSettingsRequest.builder().build());
    // log execution details
    logger.info("ENVIRONMENT VARIABLES: {}", gson.toJson(System.getenv()));
    logger.info("CONTEXT: {}", gson.toJson(context));
    logger.info("EVENT: {}", gson.toJson(event));
    // process event
    for (SQSMessage msg : event.getRecords()) {
        logger.info(msg.getBody());
    }
    // process Lambda API response
    try {
        GetAccountSettingsResponse settings = accountSettings.get();
        response = gson.toJson(settings.accountUsage());
        logger.info("Account usage: {}", response);
    } catch (Exception e) {
        e.getStackTrace();
    }
    return response;
}
Also used : GetAccountSettingsResponse(software.amazon.awssdk.services.lambda.model.GetAccountSettingsResponse) SQSMessage(com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage) ServiceException(software.amazon.awssdk.services.lambda.model.ServiceException)

Example 2 with GetAccountSettingsResponse

use of software.amazon.awssdk.services.lambda.model.GetAccountSettingsResponse in project aws-doc-sdk-examples by awsdocs.

the class GetAccountSettings method getSettings.

// snippet-start:[lambda.java2.account.main]
public static void getSettings(LambdaClient awsLambda) {
    try {
        GetAccountSettingsResponse response = awsLambda.getAccountSettings();
        System.out.println("Total code size for your account is " + response.accountLimit().totalCodeSize() + " bytes");
    } catch (LambdaException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : GetAccountSettingsResponse(software.amazon.awssdk.services.lambda.model.GetAccountSettingsResponse) LambdaException(software.amazon.awssdk.services.lambda.model.LambdaException)

Aggregations

GetAccountSettingsResponse (software.amazon.awssdk.services.lambda.model.GetAccountSettingsResponse)2 SQSMessage (com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage)1 LambdaException (software.amazon.awssdk.services.lambda.model.LambdaException)1 ServiceException (software.amazon.awssdk.services.lambda.model.ServiceException)1