public APIGatewayProxyResponseEvent handleGetRequest()

in ExportTenantData/src/main/java/tenant/export/ApiGatewayHandler.java [77:108]


    public APIGatewayProxyResponseEvent handleGetRequest(final APIGatewayProxyRequestEvent input, final Context context) {
        // we vending the token by extracting the tenant ID from the JWT token contained in
        // the request headers
        TokenVendor tokenVendor = new TokenVendor();
        final AwsCredentialsProvider awsCredentialsProvider =
            tokenVendor.vendTokenJwt(input.getHeaders());

        String tenant = tokenVendor.getTenant();
        logger.info("TENANT ID: " + tenant);

        // TenantProduct class encapsulates writing to DynamoDB using the enhanced DynamoDB
        // client, which allows us to use POJOs
        TenantProduct tenantProduct = new TenantProduct(awsCredentialsProvider, tenant);
        tenantProduct = tenantProduct.load(tenantProduct);

        String body;
        try {
            body = mapper.writeValueAsString(tenantProduct);
        } catch (JsonProcessingException e) {
            logger.error("Error parsing JSON body.", e);
            throw new RuntimeException(createBadRequestResponse(context.getAwsRequestId(),
                "Error parsing JSON body."));
        }

        Map<String, String> headers = new HashMap<>();
        headers.put("Content-Type", "application/json");

        return new APIGatewayProxyResponseEvent()
            .withHeaders(headers)
            .withBody(body)
            .withStatusCode(200);
    }