use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetMemberRestService method executeAction.
@Operation(summary = "Executes an action", description = "Executes an action specified via the request body on a reference set member." + "<p>Supported actions are:" + "• 'sync' - Executes sync action on a query type member" + "• 'create|update|delete' - allowed (mainly resolved and used in bulk requests), but in case of single member action use the dedicated endpoints instead" + "</p>")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Action execution successful"), @ApiResponse(responseCode = "204", description = "No content"), @ApiResponse(responseCode = "404", description = "Branch or member not found") })
@PostMapping(value = "/{id}/actions", consumes = { AbstractRestService.JSON_MEDIA_TYPE }, produces = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseBody
public Object executeAction(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "The reference set member identifier") @PathVariable(value = "id") final String memberId, @Parameter(description = "Reference set member action") @RequestBody final SnomedResourceRequest<RestRequest> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final RequestResolver<TransactionContext> resolver = new RefSetMemberRequestResolver();
final RestRequest change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
change.setSource("memberId", memberId);
return SnomedRequests.prepareCommit().setDefaultModuleId(defaultModuleId).setAuthor(author).setBody(change.resolve(resolver)).setCommitComment(commitComment).build(path).execute(getBus()).getSync();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedRf2ExportRestService method export.
@Operation(summary = "Export SNOMED CT content to RF2", description = "Exports SNOMED CT content from the given branch to RF2.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") })
@GetMapping
@ResponseBody
public ResponseEntity<?> export(@Parameter(description = "The branch path", required = true) @PathVariable(value = "path") final String branch, @ParameterObject final SnomedRf2ExportConfiguration params, @Parameter(description = "Accepted language tags, in order of preference", example = "en-US;q=0.8,en-GB;q=0.6") @RequestHeader(value = HttpHeaders.ACCEPT_LANGUAGE, defaultValue = "en-US;q=0.8,en-GB;q=0.6", required = false) final String acceptLanguage) {
final Attachment exportedFile = SnomedRequests.rf2().prepareExport().setReleaseType(params.getType() == null ? null : Rf2ReleaseType.getByNameIgnoreCase(params.getType())).setExtensionOnly(params.isExtensionOnly()).setLocales(acceptLanguage).setIncludePreReleaseContent(params.isIncludeUnpublished()).setModules(params.getModuleIds()).setRefSets(params.getRefSetIds()).setCountryNamespaceElement(params.getNamespaceId()).setMaintainerType(Strings.isNullOrEmpty(params.getMaintainerType()) ? null : Rf2MaintainerType.getByNameIgnoreCase(params.getMaintainerType())).setNrcCountryCode(params.getNrcCountryCode()).setTransientEffectiveTime(params.getTransientEffectiveTime()).setStartEffectiveTime(params.getStartEffectiveTime()).setEndEffectiveTime(params.getEndEffectiveTime()).setRefSetExportLayout(params.getRefSetLayout() == null ? null : Rf2RefSetExportLayout.getByNameIgnoreCase(params.getRefSetLayout())).setComponentTypes(params.getComponentTypes()).build(branch).execute(getBus()).getSync();
final File file = ((InternalAttachmentRegistry) attachments).getAttachment(exportedFile.getAttachmentId());
final Resource exportZipResource = new FileSystemResource(file);
final HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
httpHeaders.setContentDispositionFormData("attachment", exportedFile.getFileName());
// TODO figure out a smart way to cache export results, probably it could be tied to commitTimestamps/versions/etc.
file.deleteOnExit();
return new ResponseEntity<>(exportZipResource, httpHeaders, HttpStatus.OK);
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedRf2ImportRestService method create.
@Operation(summary = "Import SNOMED CT content", description = "Configures processes to import RF2 based archives. The configured process will wait until the archive actually uploaded via the <em>/archive</em> endpoint. " + "The actual import process will start after the file upload completed. Note: unpublished components (with no value entered in the 'effectiveTime' column) are " + "only allowed in DELTA import mode.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "404", description = "Not found") })
@PostMapping(consumes = { AbstractRestService.MULTIPART_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(name = "path") final String path, @Parameter(description = "RF2 Release Type to import from the archive", schema = @Schema(allowableValues = "full,snapshot,delta", defaultValue = "delta")) @RequestParam(name = "type", defaultValue = "delta") final String type, @Parameter(description = "To create versions for the CodeSystem relative to the given path", schema = @Schema(defaultValue = "true")) @RequestParam(name = "createVersions", defaultValue = "true") final Boolean createVersions, @Parameter(description = "Ignore missing referenced components in listed references instead of reporting them as an error.") @RequestParam(name = "ignoreMissingReferencesIn", required = false) final List<String> ignoreMissingReferencesIn, @Parameter(description = "Import all component until this specified effective time value", schema = @Schema(format = "date", pattern = "\\d{6}")) @RequestParam(name = "importUntil", required = false) final String importUntil, @Parameter(description = "Enable to run the import content integrity validations without pushing any changes", schema = @Schema(defaultValue = "false")) @RequestParam(name = "dryRun", defaultValue = "false") final Boolean dryRun, @Parameter(description = "Import file", required = true) @RequestPart("file") final MultipartFile file) throws IOException {
final String importJobId = SnomedRf2Requests.importJobKey(path);
final UUID rf2ArchiveId = UUID.randomUUID();
attachments.upload(rf2ArchiveId, file.getInputStream());
String jobId = SnomedRequests.rf2().prepareImport().setRf2Archive(new Attachment(rf2ArchiveId, file.getName())).setReleaseType(Rf2ReleaseType.getByNameIgnoreCase(type)).setCreateVersions(createVersions).setIgnoreMissingReferencesIn(ignoreMissingReferencesIn).setDryRun(dryRun).setImportUntil(importUntil).build(path).runAsJobWithRestart(importJobId, String.format("Importing SNOMED CT RF2 file '%s'", file.getOriginalFilename())).execute(getBus()).getSync(1, TimeUnit.MINUTES);
return ResponseEntity.created(getResourceLocationURI(path, jobId)).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedConceptRestService method create.
@Operation(summary = "Create Concept", description = "Creates a new Concept directly on a path.")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Concept created on task"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Concept parameters") @RequestBody final SnomedResourceRequest<SnomedConceptRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedConceptRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String createdConceptId = change.toRequestBuilder().commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES).getResultAs(String.class);
return ResponseEntity.created(getResourceLocationURI(path, createdConceptId)).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class SnomedReferenceSetRestService method create.
@Operation(summary = "Create a reference set", description = "Creates a new reference set directly on a path. Creates the corresponding identifier concept as well based on the given JSON body." + "<p>Reference Set type and referenced component type properties are immutable and cannot be modified, " + "thus there is no update endpoint for reference sets. " + "To update the corresponding identifier concept properties, use the concept update endpoint.</p>")
@ApiResponses({ @ApiResponse(responseCode = "201", description = "Created"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Reference set parameters") @RequestBody final SnomedResourceRequest<SnomedRefSetRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
final SnomedRefSetRestInput change = body.getChange();
final String commitComment = body.getCommitComment();
final String defaultModuleId = body.getDefaultModuleId();
final String createdRefSetId = change.toRequestBuilder().commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES).getResultAs(String.class);
return ResponseEntity.created(getResourceLocationURI(path, createdRefSetId)).build();
}
Aggregations