Search in sources :

Example 6 with ApiAuthorizer

use of com.formkiq.lambda.apigateway.ApiAuthorizer in project formkiq-core by formkiq.

the class WebhooksTagsRequestHandler method get.

@Override
public ApiRequestHandlerResponse get(final LambdaLogger logger, final ApiGatewayRequestEvent event, final ApiAuthorizer authorizer, final AwsServiceCache awsServices) throws Exception {
    String siteId = authorizer.getSiteId();
    String id = getPathParameter(event, "webhookId");
    PaginationResults<DynamicObject> list = awsServices.webhookService().findTags(siteId, id, null);
    List<Map<String, Object>> tags = list.getResults().stream().map(m -> {
        Map<String, Object> map = new HashMap<>();
        map.put("insertedDate", m.getString("inserteddate"));
        map.put("webhookId", id);
        map.put("type", m.getString("type"));
        map.put("userId", m.getString("userId"));
        map.put("value", m.getString("tagValue"));
        map.put("key", m.getString("tagKey"));
        return map;
    }).collect(Collectors.toList());
    return new ApiRequestHandlerResponse(SC_OK, new ApiMapResponse(Map.of("tags", tags)));
}
Also used : SC_CREATED(com.formkiq.lambda.apigateway.ApiResponseStatus.SC_CREATED) Arrays(java.util.Arrays) DynamicObject(com.formkiq.stacks.common.objects.DynamicObject) Date(java.util.Date) ApiGatewayRequestHandler(com.formkiq.lambda.apigateway.ApiGatewayRequestHandler) ApiMapResponse(com.formkiq.lambda.apigateway.ApiMapResponse) HashMap(java.util.HashMap) AwsServiceCache(com.formkiq.lambda.apigateway.AwsServiceCache) ApiAuthorizer(com.formkiq.lambda.apigateway.ApiAuthorizer) NotFoundException(com.formkiq.lambda.apigateway.exception.NotFoundException) Collectors(java.util.stream.Collectors) BadException(com.formkiq.lambda.apigateway.exception.BadException) ApiResponse(com.formkiq.lambda.apigateway.ApiResponse) List(java.util.List) ApiGatewayRequestEventUtil(com.formkiq.lambda.apigateway.ApiGatewayRequestEventUtil) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) Map(java.util.Map) ApiGatewayRequestEvent(com.formkiq.lambda.apigateway.ApiGatewayRequestEvent) DocumentTag(com.formkiq.stacks.dynamodb.DocumentTag) ApiRequestHandlerResponse(com.formkiq.lambda.apigateway.ApiRequestHandlerResponse) ApiMessageResponse(com.formkiq.lambda.apigateway.ApiMessageResponse) SC_OK(com.formkiq.lambda.apigateway.ApiResponseStatus.SC_OK) DocumentTagType(com.formkiq.stacks.dynamodb.DocumentTagType) PaginationResults(com.formkiq.stacks.dynamodb.PaginationResults) DynamicObject(com.formkiq.stacks.common.objects.DynamicObject) ApiRequestHandlerResponse(com.formkiq.lambda.apigateway.ApiRequestHandlerResponse) ApiMapResponse(com.formkiq.lambda.apigateway.ApiMapResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)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 SC_OK (com.formkiq.lambda.apigateway.ApiResponseStatus.SC_OK)6 AwsServiceCache (com.formkiq.lambda.apigateway.AwsServiceCache)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Date (java.util.Date)5 ApiMapResponse (com.formkiq.lambda.apigateway.ApiMapResponse)4 BadException (com.formkiq.lambda.apigateway.exception.BadException)4 Map (java.util.Map)4 DynamicObject (com.formkiq.stacks.common.objects.DynamicObject)3 DocumentTag (com.formkiq.stacks.dynamodb.DocumentTag)3 PaginationResults (com.formkiq.stacks.dynamodb.PaginationResults)3 DEFAULT_SITE_ID (com.formkiq.stacks.dynamodb.SiteIdKeyGenerator.DEFAULT_SITE_ID)3 ZoneOffset (java.time.ZoneOffset)3 HashMap (java.util.HashMap)3