@ApiOperation(value = "Create a model", tags = {"Models"}, notes = "All request values are optional. For example, you can only include the name attribute in the request body JSON-object, only setting the name of the model, leaving all other fields null.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indicates the model was created.")
})
@RequestMapping(value = "/repository/models", method = RequestMethod.POST, produces = "application/json")
public ModelResponse createModel(@RequestBody ModelRequest modelRequest, HttpServletRequest request, HttpServletResponse response) {
Model model = repositoryService.newModel();
model.setCategory(modelRequest.getCategory());
model.setDeploymentId(modelRequest.getDeploymentId());
model.setKey(modelRequest.getKey());
model.setMetaInfo(modelRequest.getMetaInfo());
model.setName(modelRequest.getName());
model.setVersion(modelRequest.getVersion());
model.setTenantId(modelRequest.getTenantId());
repositoryService.saveModel(model);
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createModelResponse(model);
}
}