private static APIGatewayProxyResponse GetAllTimelines(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); var repo = new DynamoDbTimelineRepository(new AmazonDynamoDBClient(RegionEndpoint.EUWest1), tenantId); var models = repo.GetModels(); return(ResponseHelper.WrapResponse(models)); }
private static APIGatewayProxyResponse GetAllTimelineEvents(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); var repo = GetRepo(tenantId); var eventModels = repo.GetAllTimelineEventModels(); return(ResponseHelper.WrapResponse(eventModels)); }
private static APIGatewayProxyResponse GetTimelineEventAttachments(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.Headers.TryGetValue("TimelineEventId", out var timelineEventId); ValidateTimelineEventAttachmentId(timelineEventId); var models = GetRepo(tenantId).GetTimelineEventLinks(timelineEventId); return(ResponseHelper.WrapResponse($"{JsonConvert.SerializeObject(models)}")); }
private static APIGatewayProxyResponse GetTimelineEventAttachments(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.TryGetHeader("TimelineEventId", out var timelineEventId); ValidateTimelineEventAttachmentId(timelineEventId); var models = GetRepo(tenantId).GetTimelineEventAttachments(timelineEventId); return(ResponseHelper.WrapResponse(models)); }
private static APIGatewayProxyResponse GetTimelineEvent(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.TryGetHeader("TimelineEventId", out var timelineEventId); ValidateTimelineEventId(timelineEventId); var repo = GetRepo(tenantId); var eventModel = repo.GetTimelineEventModel(timelineEventId); return(ResponseHelper.WrapResponse(eventModel)); }
private static APIGatewayProxyResponse GetTimelineEvent(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.Headers.TryGetValue("TimelineEventId", out var timelineEventId); ValidateTimelineEventId(timelineEventId); var repo = GetRepo(tenantId); var eventModel = repo.GetTimelineEventModel(timelineEventId); return(ResponseHelper.WrapResponse($"{JsonConvert.SerializeObject(eventModel)}")); }
private static APIGatewayProxyResponse GetTimeline(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.TryGetHeader("TimelineId", out var timelineId); timelineId.ValidateString("Invalid Timeline Id"); var repo = GetRepository(tenantId); var model = repo.GetModel(timelineId); return(ResponseHelper.WrapResponse(model)); }
private static APIGatewayProxyResponse GetLinkedEvents(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.TryGetHeader("TimelineId", out var timelineId); timelineId.ValidateString("Invalid Timeline Id"); var linkRepo = GetRepository(tenantId); var events = linkRepo.GetLinkedEvents(timelineId); return(ResponseHelper.WrapResponse(events)); }
private static APIGatewayProxyResponse GenerateGetAttachmentPresignedUrl(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.Headers.TryGetValue("AttachmentId", out var attachmentId); ValidateTimelineEventAttachmentId(attachmentId); var s3Client = new AmazonS3Client(RegionEndpoint.EUWest1); var presignedUrl = s3Client.GetPreSignedURL(new GetPreSignedUrlRequest { BucketName = "ideagengcu", Verb = HttpVerb.GET, Key = $"{tenantId}/{attachmentId}", Expires = DateTime.Now.AddMinutes(15) }); return(ResponseHelper.WrapResponse(presignedUrl)); }
private static APIGatewayProxyResponse GenerateAttachmentPresignedUrl(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); var attachmentId = request.Headers["AttachmentId"]; ValidateTimelineEventAttachmentId(attachmentId); var s3Client = new AmazonS3Client(RegionEndpoint.EUWest1); var presignedUrl = s3Client.GetPreSignedURL(new GetPreSignedUrlRequest { BucketName = "stewartw-test-bucket", Verb = HttpVerb.PUT, Key = $"{tenantId}/{attachmentId}", Expires = DateTime.Now.AddMinutes(15) }); return(WrapResponse(presignedUrl)); }
private static APIGatewayProxyResponse GetLinkedTimelineEvents(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); request.TryGetHeader("TimelineEventId", out var timelineEventId); ValidateTimelineEventId(timelineEventId); var repo = GetRepo(tenantId); var eventModel = repo.GetTimelineEventModel(timelineEventId); var timelineEventLinkedModels = repo.GetTimelineEventLinks(eventModel.Id); Log("Returning linked timeline events"); foreach (var linkedModel in timelineEventLinkedModels) { Log(linkedModel.ToString()); } return(ResponseHelper.WrapResponse(timelineEventLinkedModels)); }
private static APIGatewayProxyResponse GetAllTimelinesAndTimelineEvents(APIGatewayProxyRequest request) { var tenantId = request.AuthoriseGetRequest(); var timelineRepo = GetTimelineRepository(tenantId); var timelineEventRepo = GetTimelineEventRepository(tenantId); var attachmentRepo = GetAttachmentRepository(tenantId); var timelineModels = timelineRepo.GetModels(); var response = new GetAllTimelinesAndEventsResponse(); foreach (var timelineModel in timelineModels) { response.Timelines.Add(new Responses.Timeline { Id = timelineModel.Id, CreationTimeStamp = timelineModel.CreationTimeStamp, IsDeleted = timelineModel.IsDeleted, Title = timelineModel.Title, TimelineEvents = GetTimelineEvents(timelineRepo.GetLinkedEvents(timelineModel.Id).Select(_ => _.TimelineEventId), timelineEventRepo, attachmentRepo) }); } return(ResponseHelper.WrapResponse(response)); }