Search in sources :

Example 96 with AllowedProjectRoles

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

the class GitExecutionResource method getExecution.

@ApiOperation(value = "Get execution of particular Id in a repository", response = GitOpExecutionDTO.class)
@GET
@Path("/{executionId}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.GIT }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getExecution(@PathParam("executionId") Integer executionId, @Context SecurityContext sc, @Context UriInfo uriInfo, @BeanParam ExecutionBeanParam executionBeanParam) throws GitOpException {
    GitOpExecution executionObj = executionController.getExecutionInRepository(gitRepository, executionId);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXECUTION);
    resourceRequest.setExpansions(executionBeanParam.getExpansions().getResources());
    GitOpExecutionDTO dto = gitOpExecutionBuilder.build(uriInfo, resourceRequest, executionObj);
    return Response.ok().entity(dto).build();
}
Also used : GitOpExecution(io.hops.hopsworks.persistence.entity.git.GitOpExecution) 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 97 with AllowedProjectRoles

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

the class FeaturestoreKeywordResource method getKeywords.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get keywords")
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
public Response getKeywords(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo) throws FeaturestoreException, MetadataException {
    Users user = jwtHelper.getUserPrincipal(sc);
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS);
    List<String> keywords = keywordControllerIface.getAll(project, user, featuregroup, trainingDataset, featureView);
    KeywordDTO dto;
    if (featuregroup != null) {
        dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, featuregroup, keywords);
    } else if (trainingDataset != null) {
        dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, trainingDataset, keywords);
    } else if (featureView != null) {
        dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, featureView, keywords);
    } else {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.KEYWORD_ERROR, Level.FINE, "Error building keyword object");
    }
    return Response.ok().entity(dto).build();
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) 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 98 with AllowedProjectRoles

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

the class FeaturestoreService method getUsedKeywords.

@Path("keywords")
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiOperation(value = "Get available keywords for the featurestore", response = KeywordDTO.class)
public Response getUsedKeywords(@Context SecurityContext sc, @Context HttpServletRequest req, @Context UriInfo uriInfo) throws FeaturestoreException {
    List<String> keywords = keywordControllerIface.getUsedKeywords();
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.KEYWORDS);
    KeywordDTO dto = featurestoreKeywordBuilder.build(uriInfo, resourceRequest, project, keywords);
    return Response.ok().entity(dto).build();
}
Also used : KeywordDTO(io.hops.hopsworks.common.featurestore.keyword.KeywordDTO) 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 99 with AllowedProjectRoles

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

the class FeaturestoreService method getFeaturestore.

/**
 * Endpoint for getting a featurestore with a particular Id
 *
 * @param featurestoreId the id of the featurestore
 * @return JSON representation of the featurestore
 */
@GET
@Path("/{featurestoreId: [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiOperation(value = "Get featurestore with specific Id", response = FeaturestoreDTO.class)
public Response getFeaturestore(@ApiParam(value = "Id of the featurestore", required = true) @PathParam("featurestoreId") Integer featurestoreId, @Context HttpServletRequest req, @Context SecurityContext sc) throws FeaturestoreException {
    if (featurestoreId == null) {
        throw new IllegalArgumentException(RESTCodes.FeaturestoreErrorCode.FEATURESTORE_ID_NOT_PROVIDED.getMessage());
    }
    FeaturestoreDTO featurestoreDTO = featurestoreController.getFeaturestoreForProjectWithId(project, featurestoreId);
    GenericEntity<FeaturestoreDTO> featurestoreDTOGeneric = new GenericEntity<FeaturestoreDTO>(featurestoreDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreDTOGeneric).build();
}
Also used : FeaturestoreDTO(io.hops.hopsworks.common.featurestore.FeaturestoreDTO) GenericEntity(javax.ws.rs.core.GenericEntity) 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 100 with AllowedProjectRoles

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

the class FeaturestoreService method getFeaturestoreSettings.

/**
 * Endpoint for getting a featurestore's settings
 **
 * @return JSON representation of the featurestore settings
 */
@GET
@Path("/settings")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER", "HOPS_SERVICE_USER" })
@ApiOperation(value = "Get featurestore settings", response = FeaturestoreClientSettingsDTO.class)
public Response getFeaturestoreSettings(@Context HttpServletRequest req, @Context SecurityContext sc) {
    FeaturestoreClientSettingsDTO featurestoreClientSettingsDTO = new FeaturestoreClientSettingsDTO();
    featurestoreClientSettingsDTO.setOnlineFeaturestoreEnabled(settings.isOnlineFeaturestore());
    GenericEntity<FeaturestoreClientSettingsDTO> featurestoreClientSettingsDTOGeneric = new GenericEntity<FeaturestoreClientSettingsDTO>(featurestoreClientSettingsDTO) {
    };
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(featurestoreClientSettingsDTOGeneric).build();
}
Also used : GenericEntity(javax.ws.rs.core.GenericEntity) FeaturestoreClientSettingsDTO(io.hops.hopsworks.common.featurestore.settings.FeaturestoreClientSettingsDTO) 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

AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)373 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)364 Produces (javax.ws.rs.Produces)353 ApiOperation (io.swagger.annotations.ApiOperation)327 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)263 Path (javax.ws.rs.Path)260 Users (io.hops.hopsworks.persistence.entity.user.Users)224 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)188 GET (javax.ws.rs.GET)188 Consumes (javax.ws.rs.Consumes)97 POST (javax.ws.rs.POST)81 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)74 DELETE (javax.ws.rs.DELETE)56 PUT (javax.ws.rs.PUT)52 GenericEntity (javax.ws.rs.core.GenericEntity)46 Project (io.hops.hopsworks.persistence.entity.project.Project)40 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)27 UriBuilder (javax.ws.rs.core.UriBuilder)21 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)19 AlertException (io.hops.hopsworks.exceptions.AlertException)18