use of io.hops.hopsworks.common.dataset.util.DatasetPath in project hopsworks by logicalclocks.
the class DatasetTagsResource method getTag.
@ApiOperation(value = "Get tag attached to a dataset", response = TagsDTO.class)
@GET
@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 getTag(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Name of the tag", required = true) @PathParam("schemaName") String schemaName, @PathParam("path") String path, @QueryParam("datasetType") DatasetType datasetType, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, SchematizedTagException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, user, datasetPath, schemaName);
return Response.status(Response.Status.OK).entity(dto).build();
}
use of io.hops.hopsworks.common.dataset.util.DatasetPath in project hopsworks by logicalclocks.
the class DatasetTagsResource method getTags.
@ApiOperation(value = "Get all tags attached to a dataset", response = TagsDTO.class)
@GET
@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 getTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @PathParam("path") String path, @QueryParam("datasetType") DatasetType datasetType, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, SchematizedTagException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, user, datasetPath);
return Response.status(Response.Status.OK).entity(dto).build();
}
use of io.hops.hopsworks.common.dataset.util.DatasetPath in project hopsworks by logicalclocks.
the class DatasetTagsResource method bulkPutTags.
@ApiOperation(value = "Create or update tags(bulk) for a featuregroup", response = TagsDTO.class)
@PUT
@Path("/bulk/{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 bulkPutTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @PathParam("path") String path, @QueryParam("datasetType") DatasetType datasetType, TagsDTO tags) throws DatasetException, MetadataException, SchematizedTagException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
AttachTagResult result;
if (tags.getItems().size() == 0) {
result = tagsController.upsert(user, datasetPath, tags.getName(), tags.getValue());
} else {
Map<String, String> newTags = new HashMap<>();
for (TagsDTO tag : tags.getItems()) {
newTags.put(tag.getName(), tag.getValue());
}
result = tagsController.upsert(user, datasetPath, newTags);
}
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, datasetPath, result.getItems());
UriBuilder builder = uriInfo.getAbsolutePathBuilder();
if (result.isCreated()) {
return Response.created(builder.build()).entity(dto).build();
} else {
return Response.ok(builder.build()).entity(dto).build();
}
}
use of io.hops.hopsworks.common.dataset.util.DatasetPath in project hopsworks by logicalclocks.
the class DatasetBuilder method build.
/**
* Build a single Dataset
*
* @param uriInfo
* @param resourceRequest
* @param name
* @return
*/
public DatasetDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project accessProject, Users user, String name) throws DatasetException, MetadataException, SchematizedTagException {
Dataset dataset = datasetController.getByProjectAndDsName(accessProject, null, name);
if (dataset == null) {
throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE);
}
DatasetPath datasetPath = datasetHelper.getTopLevelDatasetPath(accessProject, dataset);
return build(uriInfo, resourceRequest, user, datasetPath, null, null, false);
}
use of io.hops.hopsworks.common.dataset.util.DatasetPath in project hopsworks by logicalclocks.
the class TrainingDatasetService method provenance.
@Path("/{trainingDatasetId}/provenance")
public ProvArtifactResource provenance(@PathParam("trainingDatasetId") Integer trainingDatasetId) throws FeaturestoreException, GenericException {
String tdName = featurestore.getProject().getName() + "_" + Settings.ServiceDataset.TRAININGDATASETS.getName();
DatasetPath targetEndpointPath;
try {
Dataset targetEndpoint = datasetController.getByName(featurestore.getProject(), tdName);
targetEndpointPath = datasetHelper.getTopLevelDatasetPath(project, targetEndpoint);
} catch (DatasetException ex) {
throw new GenericException(RESTCodes.GenericErrorCode.ILLEGAL_ARGUMENT, Level.FINE, "training dataset not found");
}
this.provenanceResource.setContext(project, targetEndpointPath);
TrainingDataset td = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
this.provenanceResource.setArtifactId(td.getName(), td.getVersion());
return provenanceResource;
}
Aggregations