Search in sources :

Example 66 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project snow-owl by b2ihealthcare.

the class SnomedReferenceSetMemberRestService method create.

@Operation(summary = "Create a reference set member", description = "Creates a new reference set member directly on a branch. " + "On top of the basic member properties you can include other properties relevant for specific reference set member types." + "For example: query type reference set members support _query_ and _refsetDescription_ properties. " + "_Query_ defines the ESCG query of the new member, while the _refsetDescription_ will be used as the description of the new target simple type reference set.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Branch not found") })
@PostMapping(consumes = { AbstractRestService.JSON_MEDIA_TYPE })
public ResponseEntity<Void> create(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "Reference set member parameters") @RequestBody final SnomedResourceRequest<SnomedRefSetMemberRestInput> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    final SnomedRefSetMemberRestInput change = body.getChange();
    final String commitComment = body.getCommitComment();
    final String defaultModuleId = body.getDefaultModuleId();
    final String id = change.getId();
    // Check for correct UUID format in id input
    UUID.fromString(id);
    final String createdRefSetMemberId = 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, createdRefSetMemberId)).build();
}
Also used : SnomedRefSetMemberRestInput(com.b2international.snowowl.snomed.core.rest.domain.SnomedRefSetMemberRestInput) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 67 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse in project snow-owl by b2ihealthcare.

the class SnomedReferenceSetMemberRestService method update.

@Operation(summary = "Update Reference Set Member", description = "Updates properties of the specified Reference Set Member." + "The following properties are allowed to change (other properties will be simply ignored):" + "- activity status flag (active)" + "- module Concept (moduleId)" + "- query field of query type reference set members")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "No Content"), @ApiResponse(responseCode = "404", description = "Branch or member not found") })
@PutMapping(value = "/{id}", consumes = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@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 = "Updated Reference Set parameters") @RequestBody final SnomedResourceRequest<SnomedMemberRestUpdate> body, @Parameter(description = "Force update flag") @RequestParam(defaultValue = "false", required = false) final Boolean force, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    final SnomedMemberRestUpdate update = body.getChange();
    final String commitComment = body.getCommitComment();
    final String defaultModuleId = body.getDefaultModuleId();
    SnomedRequests.prepareUpdateMember(memberId).setSource(update.getSource()).force(force).commit().setDefaultModuleId(defaultModuleId).setAuthor(author).setCommitComment(commitComment).build(path).execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
}
Also used : SnomedMemberRestUpdate(com.b2international.snowowl.snomed.core.rest.domain.SnomedMemberRestUpdate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 68 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse 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:" + "&bull; 'sync' - Executes sync action on a query type member" + "&bull; '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();
}
Also used : RestRequest(com.b2international.snowowl.snomed.core.rest.request.RestRequest) TransactionContext(com.b2international.snowowl.core.domain.TransactionContext) RefSetMemberRequestResolver(com.b2international.snowowl.snomed.core.rest.request.RefSetMemberRequestResolver) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 69 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse 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);
}
Also used : InternalAttachmentRegistry(com.b2international.snowowl.core.attachments.InternalAttachmentRegistry) HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) Attachment(com.b2international.snowowl.core.attachments.Attachment) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 70 with ApiResponse

use of io.swagger.v3.oas.models.responses.ApiResponse 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();
}
Also used : Attachment(com.b2international.snowowl.core.attachments.Attachment) UUID(java.util.UUID) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)113 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)84 Test (org.testng.annotations.Test)53 Operation (io.swagger.v3.oas.models.Operation)50 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)48 OpenAPI (io.swagger.v3.oas.models.OpenAPI)47 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)43 PathItem (io.swagger.v3.oas.models.PathItem)39 Schema (io.swagger.v3.oas.models.media.Schema)38 MediaType (io.swagger.v3.oas.models.media.MediaType)31 Path (javax.ws.rs.Path)30 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)29 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)27 StringSchema (io.swagger.v3.oas.models.media.StringSchema)27 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)25 Content (io.swagger.v3.oas.models.media.Content)25 ArrayList (java.util.ArrayList)24 Components (io.swagger.v3.oas.models.Components)19 Parameter (io.swagger.v3.oas.models.parameters.Parameter)18