Search in sources :

Example 1 with TagsDTO

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();
    }
}
Also used : TagsDTO(io.hops.hopsworks.common.tags.TagsDTO) AttachTagResult(io.hops.hopsworks.common.tags.AttachTagResult) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) UriBuilder(javax.ws.rs.core.UriBuilder) Path(javax.ws.rs.Path) DatasetPath(io.hops.hopsworks.common.dataset.util.DatasetPath) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles) PUT(javax.ws.rs.PUT)

Example 2 with TagsDTO

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;
}
Also used : TagsDTO(io.hops.hopsworks.common.tags.TagsDTO)

Example 3 with TagsDTO

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();
    }
}
Also used : ModelDTO(io.hops.hopsworks.api.modelregistry.models.dto.ModelDTO) TagsDTO(io.hops.hopsworks.common.tags.TagsDTO) HashMap(java.util.HashMap) AttachTagResult(io.hops.hopsworks.common.tags.AttachTagResult) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) UriBuilder(javax.ws.rs.core.UriBuilder) ProvStateDTO(io.hops.hopsworks.common.provenance.state.dto.ProvStateDTO) 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 4 with TagsDTO

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;
}
Also used : TagsDTO(io.hops.hopsworks.common.tags.TagsDTO)

Example 5 with TagsDTO

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;
}
Also used : TagsDTO(io.hops.hopsworks.common.tags.TagsDTO)

Aggregations

TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)27 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)17 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)16 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)16 Users (io.hops.hopsworks.persistence.entity.user.Users)16 ApiOperation (io.swagger.annotations.ApiOperation)16 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)15 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)13 AttachTagResult (io.hops.hopsworks.common.tags.AttachTagResult)8 GET (javax.ws.rs.GET)8 PUT (javax.ws.rs.PUT)8 UriBuilder (javax.ws.rs.core.UriBuilder)8 HashMap (java.util.HashMap)7 Consumes (javax.ws.rs.Consumes)6 ModelDTO (io.hops.hopsworks.api.modelregistry.models.dto.ModelDTO)4 ProvStateDTO (io.hops.hopsworks.common.provenance.state.dto.ProvStateDTO)4 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)4 TrainingDataset (io.hops.hopsworks.persistence.entity.featurestore.trainingdataset.TrainingDataset)4