use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class DatasetTagsResource method deleteTags.
@ApiOperation(value = "Delete all attached tags to a dataset")
@DELETE
@Path("/all/{path: .+}")
@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.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteTags(@Context SecurityContext sc, @PathParam("path") String path, @QueryParam("datasetType") DatasetType datasetType) throws DatasetException, MetadataException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
tagsController.deleteAll(user, datasetPath);
return Response.noContent().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class DatasetTagsResource method deleteTag.
@ApiOperation(value = "Delete tag attached to a dataset")
@DELETE
@Path("/schema/{schemaName}/{path: .+}")
@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.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response deleteTag(@Context SecurityContext sc, @ApiParam(value = "Name of the tag", required = true) @PathParam("schemaName") String schemaName, @PathParam("path") String path, @QueryParam("datasetType") DatasetType datasetType) throws DatasetException, MetadataException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
tagsController.delete(user, datasetPath, schemaName);
return Response.noContent().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class DatasetResource method getByPath.
@GET
@Path("{path: .+}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get or list files in path.", response = InodeDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.DATASET_VIEW }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getByPath(@PathParam("path") String path, @QueryParam("type") DatasetType datasetType, @QueryParam("action") DatasetActions.Get action, @QueryParam("mode") FilePreviewMode mode, @BeanParam Pagination pagination, @BeanParam InodeBeanParam inodeBeanParam, @BeanParam DatasetExpansionBeanParam datasetExpansionBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws DatasetException, ProjectException, MetadataException, SchematizedTagException {
Users user = jwtHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.INODES);
resourceRequest.setExpansions(datasetExpansionBeanParam.getResources());
Project project = this.getProject();
DatasetPath datasetPath = datasetHelper.getDatasetPathIfFileExist(project, path, datasetType);
InodeDTO dto;
switch(action == null ? DatasetActions.Get.STAT : action) {
case BLOB:
dto = inodeBuilder.buildBlob(uriInfo, resourceRequest, user, datasetPath, mode);
break;
case LISTING:
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(inodeBeanParam.getSortBySet());
resourceRequest.setFilter(inodeBeanParam.getFilter());
dto = inodeBuilder.buildItems(uriInfo, resourceRequest, user, datasetPath);
break;
case STAT:
if (datasetPath.isTopLevelDataset()) {
ResourceRequest datasetResourceRequest = new ResourceRequest(ResourceRequest.Name.DATASET);
datasetResourceRequest.setExpansions(datasetExpansionBeanParam.getResources());
DatasetDTO datasetDTO = datasetBuilder.build(uriInfo, datasetResourceRequest, user, datasetPath, null, null, true);
return Response.ok().entity(datasetDTO).build();
} else {
dto = inodeBuilder.buildStat(uriInfo, resourceRequest, user, datasetPath);
}
break;
default:
throw new WebApplicationException("Action not valid.", Response.Status.NOT_FOUND);
}
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class DatasetResource method get.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all datasets.", response = DatasetDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.DATASET_VIEW }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response get(@BeanParam Pagination pagination, @BeanParam DatasetBeanParam datasetBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ProjectException, DatasetException, MetadataException, SchematizedTagException {
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.DATASET);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(datasetBeanParam.getSortBySet());
resourceRequest.setFilter(datasetBeanParam.getFilter());
resourceRequest.setExpansions(datasetBeanParam.getExpansions().getResources());
ResourceRequest sharedDatasetResourceRequest = new ResourceRequest(ResourceRequest.Name.DATASET);
sharedDatasetResourceRequest.setOffset(pagination.getOffset());
sharedDatasetResourceRequest.setLimit(pagination.getLimit());
sharedDatasetResourceRequest.setSort(datasetBeanParam.getSharedWithSortBySet());
sharedDatasetResourceRequest.setFilter(datasetBeanParam.getSharedWithFilter());
sharedDatasetResourceRequest.setExpansions(datasetBeanParam.getExpansions().getResources());
DatasetDTO dto = datasetBuilder.buildItems(uriInfo, resourceRequest, sharedDatasetResourceRequest, this.getProject(), user);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class DatasetResource method delete.
@DELETE
@Path("{path: .+}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@ApiOperation(value = "Delete/unshare dataset")
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.DATASET_DELETE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response delete(@PathParam("path") String path, @QueryParam("type") DatasetType datasetType, @QueryParam("action") DatasetActions.Delete action, @QueryParam("target_project") String targetProject, @Context SecurityContext sc) throws DatasetException, ProjectException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(this.getProject(), path, datasetType);
Users user = jwtHelper.getUserPrincipal(sc);
Project project = this.getProject();
if (action == null) {
datasetController.delete(project, user, datasetPath.getFullPath(), datasetPath.getDataset(), datasetPath.isTopLevelDataset());
} else {
switch(action) {
case UNSHARE:
checkIfDataOwner(project, user);
datasetController.unshare(project, user, datasetPath.getDataset(), targetProject);
break;
case CORRUPTED:
if (datasetPath.isTopLevelDataset()) {
throw new IllegalArgumentException("Use DELETE /{datasetName} to delete top level dataset)");
}
datasetController.deleteCorrupted(project, user, datasetPath.getFullPath(), datasetPath.getDataset());
break;
default:
throw new WebApplicationException("Action not valid.", Response.Status.NOT_FOUND);
}
}
return Response.noContent().build();
}
Aggregations