Search in sources :

Example 86 with In

use of io.swagger.v3.oas.models.security.SecurityScheme.In 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 87 with In

use of io.swagger.v3.oas.models.security.SecurityScheme.In 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)

Example 88 with In

use of io.swagger.v3.oas.models.security.SecurityScheme.In in project snow-owl by b2ihealthcare.

the class RepositoryRestService method lockGlobal.

@Operation(summary = "Lock all repositories", description = "Places a global lock, which prevents other users from making changes to any of the repositories " + "while a backup is created. The call may block up to the specified timeout to acquire the lock; " + "if timeoutMillis is set to 0, it returns immediately.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Lock successful"), @ApiResponse(responseCode = "409", description = "Conflicting lock already taken"), @ApiResponse(responseCode = "400", description = "Illegal timeout value, or locking-related issue") })
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/lock")
public void lockGlobal(@Parameter(description = "lock timeout in milliseconds") @RequestParam(value = "timeoutMillis", defaultValue = "5000", required = false) final int timeoutMillis) {
    checkValidTimeout(timeoutMillis);
    final DatastoreLockContext context = new DatastoreLockContext(User.SYSTEM.getUsername(), DatastoreLockContextDescriptions.CREATE_BACKUP);
    final DatastoreLockTarget target = DatastoreLockTarget.ALL;
    doLock(timeoutMillis, context, target);
}
Also used : DatastoreLockTarget(com.b2international.snowowl.core.internal.locks.DatastoreLockTarget) DatastoreLockContext(com.b2international.snowowl.core.internal.locks.DatastoreLockContext) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 89 with In

use of io.swagger.v3.oas.models.security.SecurityScheme.In in project snow-owl by b2ihealthcare.

the class RepositoryRestService method lockRepository.

@Operation(summary = "Lock single repository", description = "Places a repository-level lock, which prevents other users from making changes to the specified repository. " + "The call may block up to the specified timeout to acquire the lock; if timeoutMillis is set to 0, " + "it returns immediately.")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Lock successful"), @ApiResponse(responseCode = "409", description = "Conflicting lock already taken"), @ApiResponse(responseCode = "404", description = "Repository not found"), @ApiResponse(responseCode = "400", description = "Illegal timeout value, or locking-related issue") })
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/{id}/lock")
public void lockRepository(@PathVariable(value = "id") @Parameter(description = "The repository id") final String id, @Parameter(description = "lock timeout in milliseconds") @RequestParam(value = "timeoutMillis", defaultValue = "5000", required = false) final int timeoutMillis) {
    checkValidRepositoryUuid(id);
    checkValidTimeout(timeoutMillis);
    final DatastoreLockContext context = new DatastoreLockContext(User.SYSTEM.getUsername(), DatastoreLockContextDescriptions.CREATE_REPOSITORY_BACKUP, DatastoreLockContextDescriptions.CREATE_BACKUP);
    final DatastoreLockTarget target = new DatastoreLockTarget(id, null);
    doLock(timeoutMillis, context, target);
}
Also used : DatastoreLockTarget(com.b2international.snowowl.core.internal.locks.DatastoreLockTarget) DatastoreLockContext(com.b2international.snowowl.core.internal.locks.DatastoreLockContext) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 90 with In

use of io.swagger.v3.oas.models.security.SecurityScheme.In in project snow-owl by b2ihealthcare.

the class FhirCodeSystemValidateCodeOperationController method validateCode.

/**
 * HTTP Get request to validate that a coded value is in the code system specified by the ID param in the path.
 * The code system is identified by its Code System ID within the path - 'instance' level call
 * If the operation is not called at the instance level, one of the parameters "url" or "codeSystem" must be provided.
 * The operation returns a result (true / false), an error message, and the recommended display for the code.
 * When invoking this operation, a client SHALL provide one (and only one) of the parameters (code+system, coding, or codeableConcept).
 * Other parameters (including version and display) are optional.
 *
 * @param codeSystemId the code system to validate against
 * @param code to code to validate
 * @param version the version of the code system to validate against
 * @param date the date for which the validation should be checked
 * @param isAbstract If this parameter has a value of true, the client is stating that the validation is being performed in a context
 * 			where a concept designated as 'abstract' is appropriate/allowed.
 *
 * @return validation results as {@link OperationOutcome}
 */
@Operation(summary = "Validate a code in a code system", description = "Validate that a coded value is in a code system.")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad request"), @ApiResponse(responseCode = "404", description = "Code system not found") })
@GetMapping("/{codeSystemId:**}/$validate-code")
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The id of the code system to validate against") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The code to be validated") @RequestParam(value = "code") final String code, @Parameter(description = "The version of the code system") @RequestParam(value = "version") final Optional<String> version, @Parameter(description = "The display string of the code") @RequestParam(value = "display") final Optional<String> display, @Parameter(description = "The date stamp of the code system to validate against") @RequestParam(value = "date") final Optional<String> date, @Parameter(description = "The abstract status of the code") @RequestParam(value = "abstract") final Optional<Boolean> isAbstract) {
    ValidateCodeRequest.Builder builder = ValidateCodeRequest.builder().code(code).version(version.orElse(null)).display(display.orElse(null)).isAbstract(isAbstract.orElse(null));
    if (date.isPresent()) {
        builder.date(date.get());
    }
    // Convert to FHIR parameters and delegate to the POST call
    Json json = new Parameters.Json(builder.build());
    Fhir fhir = new Parameters.Fhir(json.parameters());
    return validateCode(codeSystemId, fhir);
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) ValidateCodeRequest(com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Test (org.testng.annotations.Test)130 OpenAPI (io.swagger.v3.oas.models.OpenAPI)108 Parameter (io.swagger.v3.oas.models.parameters.Parameter)51 Schema (io.swagger.v3.oas.models.media.Schema)49 StringSchema (io.swagger.v3.oas.models.media.StringSchema)44 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)40 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)39 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)39 Operation (io.swagger.v3.oas.annotations.Operation)36 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)36 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)31 Operation (io.swagger.v3.oas.models.Operation)28 PathItem (io.swagger.v3.oas.models.PathItem)27 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)27 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)25 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)25 Map (java.util.Map)25 HashMap (java.util.HashMap)23 PathParameter (io.swagger.v3.oas.models.parameters.PathParameter)22 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)21