private async Task <IActionResult> SendExportRequest( ExportJobType exportType, PartialDateTime since, string resourceType = null, string groupId = null, string containerName = null, string formatName = null, string anonymizationConfigLocation = null, string anonymizationConfigFileETag = null) { CreateExportResponse response = await _mediator.ExportAsync( _fhirRequestContextAccessor.FhirRequestContext.Uri, exportType, resourceType, since, groupId, containerName, formatName, anonymizationConfigLocation, anonymizationConfigFileETag, HttpContext.RequestAborted); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public void GivenAnExportResult_WhenSettingAContentTypeHeader_ThenExportResultHasAContentTypeHeader() { string contentTypeValue = "application/json"; var exportResult = ExportResult.Accepted().SetContentTypeHeader(contentTypeValue); Assert.Equal(contentTypeValue, exportResult.Headers[HeaderNames.ContentType]); }
private async Task <IActionResult> SendExportRequest(PartialDateTime since, string type = null) { CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, type, since, HttpContext.RequestAborted); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public void GivenAnExportResult_WhenSettingAContentLocationHeader_TheExportResultHasAContentLocationHeader() { string opName = OperationsConstants.Export; string id = Guid.NewGuid().ToString(); var exportOperationUrl = new Uri($"http://localhost/{OperationsConstants.Operations}/{opName}/{id}"); var urlResolver = Substitute.For <IUrlResolver>(); urlResolver.ResolveOperationResultUrl(Arg.Any <string>(), Arg.Any <string>()).Returns(exportOperationUrl); var exportResult = ExportResult.Accepted().SetContentLocationHeader(urlResolver, opName, id); Assert.Equal(exportOperationUrl.AbsoluteUri, exportResult.Headers[HeaderNames.ContentLocation]); }
public async Task <IActionResult> Export() { if (!_exportConfig.Enabled) { throw new RequestNotValidException(string.Format(Resources.UnsupportedOperation, OperationsConstants.Export)); } CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, HttpContext.RequestAborted); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public async Task <IActionResult> Export([FromQuery(Name = KnownQueryParameterNames.Since)] PartialDateTime since) { if (!_exportConfig.Enabled) { throw new RequestNotValidException(string.Format(Resources.OperationNotEnabled, OperationsConstants.Export)); } CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, since, HttpContext.RequestAborted); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public async Task <IActionResult> Export( [FromQuery(Name = KnownQueryParameterNames.DestinationType)] string destinationType, [FromQuery(Name = KnownQueryParameterNames.DestinationConnectionSettings)] string destinationConnectionString) { if (!_exportConfig.Enabled) { throw new RequestNotValidException(string.Format(Resources.UnsupportedOperation, OperationsConstants.Export)); } CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, destinationType, destinationConnectionString); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public async Task <IActionResult> GetExportStatusById(string id) { var getExportResult = await _mediator.GetExportStatusAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, id); // If the job is complete, we need to return 200 along the completed data to the client. // Else we need to return 202. ExportResult exportActionResult; if (getExportResult.StatusCode == HttpStatusCode.OK) { exportActionResult = ExportResult.Ok(getExportResult.JobResult); exportActionResult.SetContentTypeHeader(OperationsConstants.ExportContentTypeHeaderValue); } else { exportActionResult = ExportResult.Accepted(); } return(exportActionResult); }