Search in sources :

Example 11 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired 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 12 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class KafkaResource method getTopics.

@ApiOperation(value = "Retrieve Kafka topics metadata .")
@GET
@Path("/topics")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTopics(@Context UriInfo uriInfo, @BeanParam Pagination pagination, @BeanParam TopicsBeanParam topicsBeanParam, @Context SecurityContext sc) {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KAFKA);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    resourceRequest.setSort(topicsBeanParam.getSortBySet());
    resourceRequest.setFilter(topicsBeanParam.getFilter());
    TopicDTO dto = topicsBuilder.build(uriInfo, resourceRequest, project);
    return Response.ok().entity(dto).build();
}
Also used : TopicDTO(io.hops.hopsworks.common.dao.kafka.TopicDTO) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) 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 13 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class KafkaResource method updateTopicAcls.

@ApiOperation(value = "Update ACL specified by id.")
@PUT
@Path("/topics/{topic}/acls/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response updateTopicAcls(@Context UriInfo uriInfo, @PathParam("topic") String topicName, @PathParam("id") Integer aclId, AclDTO aclDto, @Context SecurityContext sc) throws KafkaException, ProjectException, UserException {
    Integer updatedAclId = kafkaController.updateTopicAcl(project, topicName, aclId, aclDto);
    aclDto.setId(updatedAclId);
    URI uri = aclBuilder.getAclUri(uriInfo, project, topicName).path(Integer.toString(updatedAclId)).build();
    aclDto.setHref(uri);
    return Response.ok(uri).entity(aclDto).build();
}
Also used : URI(java.net.URI) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) 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) PUT(javax.ws.rs.PUT)

Example 14 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class ModelsResource method getAll.

@ApiOperation(value = "Get a list of all models for this project", response = ModelDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.MODELREGISTRY }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getAll(@BeanParam Pagination pagination, @BeanParam ModelsBeanParam modelsBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ModelRegistryException, GenericException, SchematizedTagException, MetadataException {
    Users user = jwtHelper.getUserPrincipal(sc);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.MODELS);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    resourceRequest.setFilter(modelsBeanParam.getFilter());
    resourceRequest.setSort(modelsBeanParam.getSortBySet());
    resourceRequest.setExpansions(modelsBeanParam.getExpansions().getResources());
    ModelDTO dto = modelsBuilder.build(uriInfo, resourceRequest, user, userProject, modelRegistryProject);
    return Response.ok().entity(dto).build();
}
Also used : ModelDTO(io.hops.hopsworks.api.modelregistry.models.dto.ModelDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) 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 15 with ApiKeyRequired

use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.

the class ModelsResource method getTags.

@ApiOperation(value = "Get all tags attached to a model", response = TagsDTO.class)
@GET
@Path("/{id}/tags")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.MODELREGISTRY }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the model", required = true) @PathParam("id") String id, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, SchematizedTagException, ProvenanceException, ModelRegistryException {
    Users user = jwtHelper.getUserPrincipal(sc);
    ProvStateDTO fileState = modelsController.getModel(modelRegistryProject, id);
    ModelDTO model = modelUtils.convertProvenanceHitToModel(fileState);
    Map<String, String> result = tagController.getAll(userProject, user, modelUtils.getModelFullPath(modelRegistryProject, model.getName(), model.getVersion()));
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
    resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
    TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, userProject, modelRegistryProject, fileState.getMlId(), result);
    return Response.status(Response.Status.OK).entity(dto).build();
}
Also used : ModelDTO(io.hops.hopsworks.api.modelregistry.models.dto.ModelDTO) TagsDTO(io.hops.hopsworks.common.tags.TagsDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ProvStateDTO(io.hops.hopsworks.common.provenance.state.dto.ProvStateDTO) Path(javax.ws.rs.Path) 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

ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)175 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)171 ApiOperation (io.swagger.annotations.ApiOperation)169 Produces (javax.ws.rs.Produces)165 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)159 Path (javax.ws.rs.Path)124 Users (io.hops.hopsworks.persistence.entity.user.Users)116 GET (javax.ws.rs.GET)96 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)94 Consumes (javax.ws.rs.Consumes)45 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)38 POST (javax.ws.rs.POST)32 DELETE (javax.ws.rs.DELETE)26 GenericEntity (javax.ws.rs.core.GenericEntity)25 PUT (javax.ws.rs.PUT)23 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)15 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)11 UriBuilder (javax.ws.rs.core.UriBuilder)11 Project (io.hops.hopsworks.persistence.entity.project.Project)10 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)9