use of io.swagger.v3.oas.models.responses.ApiResponses 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);
}
use of io.swagger.v3.oas.models.responses.ApiResponses 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);
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class BundleRestService method delete.
@Operation(summary = "Delete a bundle", description = "Delete a bundle with the given parameters")
@ApiResponses({ @ApiResponse(responseCode = "204", description = "Deletion successful"), @ApiResponse(responseCode = "409", description = "Bundle cannot be deleted") })
@DeleteMapping(value = "/{bundleId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@Parameter(description = "The bundle identifier") @PathVariable(value = "bundleId") final String bundleId, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
try {
final Bundle bundle = ResourceRequests.bundles().prepareGet(bundleId).buildAsync().execute(getBus()).getSync(1, TimeUnit.MINUTES);
ResourceRequests.bundles().prepareDelete(bundleId).commit().setAuthor(author).setCommitComment(String.format("Deleted Bundle %s", bundle.getTitle())).buildAsync().execute(getBus()).getSync(COMMIT_TIMEOUT, TimeUnit.MINUTES);
} catch (NotFoundException e) {
// already deleted, ignore error
}
}
use of io.swagger.v3.oas.models.responses.ApiResponses 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);
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project snow-owl by b2ihealthcare.
the class FhirCodeSystemValidateCodeOperationController method validateCode.
/**
* POST-based $validate-code end-point.
* All parameters are in the request body, except the codeSystemId
* @param body - FHIR parameters
* @return out - FHIR parameters
*/
@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 = "404", description = "Not found"), @ApiResponse(responseCode = "400", description = "Bad request") })
@PostMapping(value = "/{codeSystemId:**}/$validate-code", consumes = AbstractFhirController.APPLICATION_FHIR_JSON)
public Promise<Parameters.Fhir> validateCode(@Parameter(description = "The id of the code system to validate against") @PathVariable("codeSystemId") String codeSystemId, @Parameter(description = "The validate-code request parameters") @RequestBody Parameters.Fhir body) {
final ValidateCodeRequest request = toRequest(body, ValidateCodeRequest.class);
// Validate for parameters that are not allowed on the instance level
if (request.getUrl() != null) {
throw new BadRequestException("Parameter 'url' cannot be specified when the code system ID is set.", "ValidateCodeRequest.url");
}
if (request.getCoding() != null) {
throw new BadRequestException("Parameter 'coding' cannot be specified when the code system ID is set.", "ValidateCodeRequest.coding");
}
if (request.getCodeableConcept() != null) {
throw new BadRequestException("Parameter 'codeableConcept' cannot be specified when the code system ID is set.", "ValidateCodeRequest.codeableConcept");
}
if (request.getCodeSystem() != null) {
throw new BadRequestException("Validation against external code systems is not supported", "ValidateCodeRequest.codeSystem");
}
// before execution set the codesystem to the path variable
request.setUrl(new Uri(codeSystemId));
return FhirRequests.codeSystems().prepareValidateCode().setRequest(request).buildAsync().execute(getBus()).then(this::toResponse);
}
Aggregations