use of io.hops.hopsworks.common.tags.TagsDTO in project hopsworks by logicalclocks.
the class DatasetTagsResource method putTag.
@ApiOperation(value = "Create or update tag for a dataset", response = TagsDTO.class)
@PUT
@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" })
public Response putTag(@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, @ApiParam(value = "Value to set for the tag") String value) throws DatasetException, MetadataException, SchematizedTagException {
DatasetPath datasetPath = datasetHelper.getDatasetPath(project, path, datasetType);
Users user = jWTHelper.getUserPrincipal(sc);
AttachTagResult result = tagsController.upsert(user, datasetPath, schemaName, value);
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.tags.TagsDTO in project hopsworks by logicalclocks.
the class DatasetTagsBuilder method build.
public TagsDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, DatasetPath dsPath, Map<String, String> tags) throws DatasetException, SchematizedTagException, MetadataException {
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, tags);
uriAll(dto, uriInfo, dsPath);
return dto;
}
use of io.hops.hopsworks.common.tags.TagsDTO in project hopsworks by logicalclocks.
the class ModelsResource method bulkPutTags.
@ApiOperation(value = "Create or update tags(bulk) for a model", response = TagsDTO.class)
@PUT
@Path("/{id}/tags")
@Consumes(MediaType.APPLICATION_JSON)
@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 bulkPutTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the model", required = true) @PathParam("id") String id, TagsDTO tags) throws MetadataException, SchematizedTagException, DatasetException, ProvenanceException, ModelRegistryException {
Users user = jwtHelper.getUserPrincipal(sc);
ProvStateDTO fileState = modelsController.getModel(modelRegistryProject, id);
ModelDTO model = modelUtils.convertProvenanceHitToModel(fileState);
AttachTagResult result;
if (tags.getItems().size() == 0) {
result = tagController.upsert(userProject, user, modelUtils.getModelFullPath(modelRegistryProject, model.getName(), model.getVersion()), tags.getName(), tags.getValue());
} else {
Map<String, String> newTags = new HashMap<>();
for (TagsDTO tag : tags.getItems()) {
newTags.put(tag.getName(), tag.getValue());
}
result = tagController.upsertAll(userProject, user, modelUtils.getModelFullPath(modelRegistryProject, model.getName(), model.getVersion()), newTags);
}
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, userProject, modelRegistryProject, fileState.getMlId(), 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.tags.TagsDTO in project hopsworks by logicalclocks.
the class ModelTagsBuilder method build.
public TagsDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project userProject, Project modelRegistryProject, String modelId, Map<String, String> tags) throws SchematizedTagException, DatasetException, MetadataException {
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, tags);
uriAll(dto, uriInfo, userProject, modelRegistryProject, modelId);
return dto;
}
use of io.hops.hopsworks.common.tags.TagsDTO in project hopsworks by logicalclocks.
the class ModelTagsBuilder method build.
public TagsDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project userProject, Project modelRegistryProject, String modelId, String name, String value) throws SchematizedTagException {
TagsDTO dto = tagsBuilder.build(uriInfo, resourceRequest, name, value);
uri(dto, uriInfo, userProject, modelRegistryProject, modelId, name);
return dto;
}
Aggregations