@GET @Path("/version") @ApiOperation(value = "Get the version information of this Schema Registry instance", response = SchemaRegistryVersion.class, tags = OPERATION_GROUP_OTHER) @Timed public Response getVersion(@Context UriInfo uriInfo) { return WSUtils.respondEntity(schemaRegistryVersion, Response.Status.OK); }
@GET @Path("/version") @ApiOperation(value = "Get the version information of this Schema Registry instance", response = SchemaRegistryVersion.class, tags = OPERATION_GROUP_OTHER) @Timed public Response getVersion(@Context UriInfo uriInfo) { return WSUtils.respondEntity(schemaRegistryVersion, Response.Status.OK); }
private Response _getSerDesInfo(Long serializerId) { Response response; try { SerDesInfo serializerInfo = schemaRegistry.getSerDes(serializerId); response = WSUtils.respondEntity(serializerInfo, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting serializer/deserializer [{}]", serializerId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
private Response _addSerDesInfo(SerDesPair serDesInfo) { Response response; try { Long serializerId = schemaRegistry.addSerDes(serDesInfo); response = WSUtils.respondEntity(serializerId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while adding serializer/deserializer [{}]", serDesInfo, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
private Response _addSerDesInfo(SerDesPair serDesInfo) { Response response; try { Long serializerId = schemaRegistry.addSerDes(serDesInfo); response = WSUtils.respondEntity(serializerId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while adding serializer/deserializer [{}]", serDesInfo, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
private Response _getSerDesInfo(Long serializerId) { Response response; try { SerDesInfo serializerInfo = schemaRegistry.getSerDes(serializerId); response = WSUtils.respondEntity(serializerInfo, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting serializer/deserializer [{}]", serializerId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Produces(MediaType.APPLICATION_JSON) @Path("ml/models/pmml/{name}") @Timed public Response getMLModelContents(@PathParam("name") String modelName) { MLModel modelInfo = modelRegistryService.getModelInfo(modelName); return WSUtils.respondEntity(modelInfo.getPmml(), OK); } }
@GET @Path("/schemas/versions/statemachine") @ApiOperation(value = "Get schema version life cycle states", response = SchemaVersionInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed public Response getSchemaVersionLifeCycleStates() { Response response; try { SchemaVersionLifecycleStateMachineInfo states = schemaRegistry.getSchemaVersionLifecycleStateMachineInfo(); response = WSUtils.respondEntity(states, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting schema version lifecycle states", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/schemas/versions/statemachine") @ApiOperation(value = "Get schema version life cycle states", response = SchemaVersionInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed public Response getSchemaVersionLifeCycleStates() { Response response; try { SchemaVersionLifecycleStateMachineInfo states = schemaRegistry.getSchemaVersionLifecycleStateMachineInfo(); response = WSUtils.respondEntity(states, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while getting schema version lifecycle states", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Produces({"application/octet-stream", "application/json"}) @Path("/files/download/{fileId}") @ApiOperation(value = "Downloads the respective for the given fileId if it exists", response = StreamingOutput.class, tags = OPERATION_GROUP_OTHER) @Timed public Response downloadFile(@ApiParam(value = "Identifier of the file to be downloaded", required = true) @PathParam("fileId") String fileId) { Response response; try { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput(schemaRegistry.downloadFile(fileId)); response = Response.ok(streamOutput).build(); return response; } catch (FileNotFoundException e) { LOG.error("No file found for fileId [{}]", fileId, e); response = WSUtils.respondEntity(fileId, Response.Status.NOT_FOUND); } catch (Exception ex) { LOG.error("Encountered error while downloading file [{}]", fileId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Produces({"application/octet-stream", "application/json"}) @Path("/files/download/{fileId}") @ApiOperation(value = "Downloads the respective for the given fileId if it exists", response = StreamingOutput.class, tags = OPERATION_GROUP_OTHER) @Timed public Response downloadFile(@ApiParam(value = "Identifier of the file to be downloaded", required = true) @PathParam("fileId") String fileId) { Response response; try { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput(schemaRegistry.downloadFile(fileId)); response = Response.ok(streamOutput).build(); return response; } catch (FileNotFoundException e) { LOG.error("No file found for fileId [{}]", fileId, e); response = WSUtils.respondEntity(fileId, Response.Status.NOT_FOUND); } catch (Exception ex) { LOG.error("Encountered error while downloading file [{}]", fileId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Path("/schemas/{name}/mapping/{serDesId}") @ApiOperation(value = "Bind the given Serializer/Deserializer to the schema identified by the schema name", tags = OPERATION_GROUP_SERDE) @Timed @UnitOfWork public Response mapSchemaWithSerDes(@ApiParam(value = "Schema name", required = true) @PathParam("name") String schemaName, @ApiParam(value = "Serializer/deserializer identifier", required = true) @PathParam("serDesId") Long serDesId, @Context UriInfo uriInfo) { return handleLeaderAction(uriInfo, () -> { Response response; try { schemaRegistry.mapSchemaWithSerDes(schemaName, serDesId); response = WSUtils.respondEntity(true, Response.Status.OK); } catch (Exception ex) { response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/files") @ApiOperation(value = "Upload the given file and returns respective identifier.", response = String.class, tags = OPERATION_GROUP_OTHER) @Timed public Response uploadFile(@FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) { Response response; try { LOG.info("Received contentDispositionHeader: [{}]", contentDispositionHeader); String uploadedFileId = schemaRegistry.uploadFile(inputStream); response = WSUtils.respondEntity(uploadedFileId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while uploading file", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Path("/schemas/{name}/mapping/{serDesId}") @ApiOperation(value = "Bind the given Serializer/Deserializer to the schema identified by the schema name", tags = OPERATION_GROUP_SERDE) @Timed @UnitOfWork public Response mapSchemaWithSerDes(@ApiParam(value = "Schema name", required = true) @PathParam("name") String schemaName, @ApiParam(value = "Serializer/deserializer identifier", required = true) @PathParam("serDesId") Long serDesId, @Context UriInfo uriInfo) { return handleLeaderAction(uriInfo, () -> { Response response; try { schemaRegistry.mapSchemaWithSerDes(schemaName, serDesId); response = WSUtils.respondEntity(true, Response.Status.OK); } catch (Exception ex) { response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }); }
@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/files") @ApiOperation(value = "Upload the given file and returns respective identifier.", response = String.class, tags = OPERATION_GROUP_OTHER) @Timed public Response uploadFile(@FormDataParam("file") final InputStream inputStream, @FormDataParam("file") final FormDataContentDisposition contentDispositionHeader) { Response response; try { LOG.info("Received contentDispositionHeader: [{}]", contentDispositionHeader); String uploadedFileId = schemaRegistry.uploadFile(inputStream); response = WSUtils.respondEntity(uploadedFileId, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while uploading file", ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/schemasById/{schemaId}") @ApiOperation(value = "Get schema for a given schema identifier", response = SchemaMetadataInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response getSchemaInfo(@ApiParam(value = "Schema identifier", required = true) @PathParam("schemaId") Long schemaId) { Response response; try { SchemaMetadataInfo schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(schemaId); if (schemaMetadataInfo != null) { response = WSUtils.respondEntity(schemaMetadataInfo, Response.Status.OK); } else { response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaId.toString()); } } catch (Exception ex) { LOG.error("Encountered error while retrieving SchemaInfo with schemaId: [{}]", schemaId, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@GET @Path("/subjects") @ApiOperation(value = "Get all registered subjects", response = String.class, responseContainer = "List", tags = OPERATION_GROUP_CONFLUENT_SR) @Timed @UnitOfWork public Response getSubjects() { Response response; try { List<String> registeredSubjects = schemaRegistry.findSchemaMetadata(Collections.emptyMap()) .stream() .map(x -> x.getSchemaMetadata().getName()) .collect(Collectors.toList()); response = WSUtils.respondEntity(registeredSubjects, Response.Status.OK); } catch (Exception ex) { LOG.error("Encountered error while retrieving all subjects", ex); response = serverError(); } return response; }
@POST @Path("/schemas/{versionId}/merge") @ApiOperation(value = "Merge a schema version to master given its version id", response = SchemaVersionMergeResult.class, tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response mergeSchemaVersion(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { try { SchemaVersionMergeResult schemaVersionMergeResult = schemaRegistry.mergeSchemaVersion(schemaVersionId); return WSUtils.respondEntity(schemaVersionMergeResult, Response.Status.OK); } catch (SchemaNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaVersionId.toString()); } catch (IncompatibleSchemaException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while merging a schema version to {} branch with version : [{}]", SchemaBranch.MASTER_BRANCH, schemaVersionId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }
@GET @Path("/schemas/{name}") @ApiOperation(value = "Get schema information for the given schema name", response = SchemaMetadataInfo.class, tags = OPERATION_GROUP_SCHEMA) @Timed @UnitOfWork public Response getSchemaInfo(@ApiParam(value = "Schema name", required = true) @PathParam("name") String schemaName) { Response response; try { SchemaMetadataInfo schemaMetadataInfo = schemaRegistry.getSchemaMetadataInfo(schemaName); if (schemaMetadataInfo != null) { response = WSUtils.respondEntity(schemaMetadataInfo, Response.Status.OK); } else { response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaName); } } catch (Exception ex) { LOG.error("Encountered error while retrieving SchemaInfo with name: [{}]", schemaName, ex); response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } return response; }
@POST @Path("/schemas/{versionId}/merge") @ApiOperation(value = "Merge a schema version to master given its version id", response = SchemaVersionMergeResult.class, tags = OPERATION_GROUP_SCHEMA) @UnitOfWork public Response mergeSchemaVersion(@ApiParam(value = "Details about schema version",required = true) @PathParam("versionId") Long schemaVersionId) { try { SchemaVersionMergeResult schemaVersionMergeResult = schemaRegistry.mergeSchemaVersion(schemaVersionId); return WSUtils.respondEntity(schemaVersionMergeResult, Response.Status.OK); } catch (SchemaNotFoundException e) { return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaVersionId.toString()); } catch (IncompatibleSchemaException e) { return WSUtils.respond(Response.Status.BAD_REQUEST, CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA, e.getMessage()); } catch (Exception ex) { LOG.error("Encountered error while merging a schema version to {} branch with version : [{}]", SchemaBranch.MASTER_BRANCH, schemaVersionId, ex); return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage()); } }