Search in sources :

Example 1 with SchemaRegistryError

use of io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError in project hopsworks by logicalclocks.

the class KafkaResource method deleteSubjectsVersion.

@ApiOperation(value = "Delete a specific version of a subject (and its compatibility).")
@DELETE
@Path("/subjects/{subject}/versions/{version}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN })
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteSubjectsVersion(@PathParam("subject") String subject, @PathParam("version") String version, @Context SecurityContext sc) throws KafkaException {
    try {
        Integer deleted = subjectsController.deleteSubjectsVersion(project, subject, version);
        GenericEntity<Integer> entity = new GenericEntity<Integer>(deleted) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with SchemaRegistryError

use of io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError in project hopsworks by logicalclocks.

the class KafkaResource method getSubjectVersions.

@ApiOperation(value = "Get list of versions of a registered subject.")
@GET
@Path("/subjects/{subject}/versions")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getSubjectVersions(@PathParam("subject") String subject, @Context SecurityContext sc) {
    try {
        List<Integer> versions = subjectsController.getSubjectVersions(project, subject);
        String array = Arrays.toString(versions.toArray());
        GenericEntity<String> entity = new GenericEntity<String>(array) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 3 with SchemaRegistryError

use of io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError in project hopsworks by logicalclocks.

the class KafkaResource method deleteSubject.

@ApiOperation(value = "Delete a subject with all its versions and its compatibility if exists.")
@DELETE
@Path("/subjects/{subject}")
@Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON })
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteSubject(@PathParam("subject") String subject, @Context SecurityContext sc) throws KafkaException {
    try {
        List<Integer> versions = subjectsController.deleteSubject(project, subject);
        String array = Arrays.toString(versions.toArray());
        GenericEntity<String> entity = new GenericEntity<String>(array) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 4 with SchemaRegistryError

use of io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError in project hopsworks by logicalclocks.

the class KafkaResource method getSchema.

@ApiOperation(value = "Get avro schema of a subject and version.")
@GET
@Path("/subjects/{subject}/versions/{version}/schema")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getSchema(@PathParam("subject") String subject, @PathParam("version") String version, @Context SecurityContext sc) {
    try {
        SubjectDTO dto = subjectsController.getSubjectDetails(project, subject, version);
        GenericEntity<String> entity = new GenericEntity<String>(dto.getSchema()) {
        };
        return Response.ok().entity(entity).build();
    } catch (SchemaException e) {
        SchemaRegistryError error = new SchemaRegistryError(e.getErrorCode().getCode(), e.getErrorCode().getMessage());
        return Response.status(e.getErrorCode().getRespStatus()).entity(error).build();
    }
}
Also used : SchemaException(io.hops.hopsworks.exceptions.SchemaException) SubjectDTO(io.hops.hopsworks.common.dao.kafka.schemas.SubjectDTO) GenericEntity(javax.ws.rs.core.GenericEntity) SchemaRegistryError(io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)4 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)4 SchemaRegistryError (io.hops.hopsworks.common.dao.kafka.schemas.SchemaRegistryError)4 SchemaException (io.hops.hopsworks.exceptions.SchemaException)4 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)4 ApiOperation (io.swagger.annotations.ApiOperation)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 GenericEntity (javax.ws.rs.core.GenericEntity)4 Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)2 GET (javax.ws.rs.GET)2 SubjectDTO (io.hops.hopsworks.common.dao.kafka.schemas.SubjectDTO)1