use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ServingService method put.
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Create or update a serving instance")
public Response put(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "serving specification", required = true) ServingView serving) throws ServingException, ServiceException, KafkaException, ProjectException, UserException, InterruptedException, ExecutionException, UnsupportedEncodingException {
Users user = jWTHelper.getUserPrincipal(sc);
if (serving == null) {
throw new IllegalArgumentException("serving was not provided");
}
ServingWrapper servingWrapper = serving.getServingWrapper();
servingUtil.validateUserInput(servingWrapper, project);
servingController.put(project, user, servingWrapper);
ServingView servingView = new ServingView(servingWrapper);
UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(String.valueOf(servingView.getId()));
GenericEntity<ServingView> servingEntity = new GenericEntity<ServingView>(servingView) {
};
return Response.created(builder.build()).entity(servingEntity).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ServingService method startOrStop.
@POST
@Path("/{servingId}")
@Consumes(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.SERVING }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Start or stop a Serving instance")
public Response startOrStop(@Context SecurityContext sc, @ApiParam(value = "ID of the Serving instance to start/stop", required = true) @PathParam("servingId") Integer servingId, @ApiParam(value = "Action", required = true) @QueryParam("action") ServingCommands servingCommand) throws ServingException {
Users user = jWTHelper.getUserPrincipal(sc);
if (servingId == null) {
throw new IllegalArgumentException("servingId was not provided");
}
if (servingCommand == null) {
throw new IllegalArgumentException(RESTCodes.ServingErrorCode.COMMANDNOTPROVIDED.getMessage());
}
servingController.startOrStop(project, user, servingId, servingCommand);
return Response.ok().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class FeaturestoreStorageConnectorService method createNewStorageConnector.
/**
* Endpoint for creating a storage connector with a particular type in a feature store
*
* @return a JSON representation of the connector
* @throws FeaturestoreException
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Create a new storage connector for the feature store", response = FeaturestoreStorageConnectorDTO.class)
public Response createNewStorageConnector(@Context SecurityContext sc, FeaturestoreStorageConnectorDTO featurestoreStorageConnectorDTO) throws FeaturestoreException, UserException, ProjectException {
if (featurestoreStorageConnectorDTO == null) {
throw new IllegalArgumentException("Input JSON for creating a new Feature Store Storage Connector Cannot be " + "null");
}
Users user = jWTHelper.getUserPrincipal(sc);
FeaturestoreStorageConnectorDTO createdFeaturestoreStorageConnectorDTO = storageConnectorController.createStorageConnector(user, project, featurestore, featurestoreStorageConnectorDTO);
GenericEntity<FeaturestoreStorageConnectorDTO> featurestoreStorageConnectorDTOGenericEntity = new GenericEntity<FeaturestoreStorageConnectorDTO>(createdFeaturestoreStorageConnectorDTO) {
};
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.CREATED).entity(featurestoreStorageConnectorDTOGenericEntity).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method delete.
/**
* Endpoint for deleting a training dataset, this will delete both the metadata and the data storage
*
* @param trainingdatasetid the id of the trainingDataset
* @return JSON representation of the deleted trainingDataset
* @throws FeaturestoreException
* @throws DatasetException
* @throws ProjectException
*/
@DELETE
@Path("/{trainingdatasetid: [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiOperation(value = "Delete a training datasets with a specific id from a featurestore", response = TrainingDatasetDTO.class)
public Response delete(@Context SecurityContext sc, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingdatasetid") Integer trainingdatasetid) throws FeaturestoreException {
verifyIdProvided(trainingdatasetid);
Users user = jWTHelper.getUserPrincipal(sc);
String trainingDsName = trainingDatasetController.delete(user, project, featurestore, trainingdatasetid);
activityFacade.persistActivity(ActivityFacade.DELETED_TRAINING_DATASET + trainingDsName, project, user, ActivityFlag.SERVICE);
return Response.ok().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class TrainingDatasetService method bulkPutTags.
@ApiOperation(value = "Create or update tags(bulk) for a training dataset", response = TagsDTO.class)
@PUT
@Path("/{trainingDatasetId}/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.FEATURESTORE }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response bulkPutTags(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the training dataset", required = true) @PathParam("trainingDatasetId") Integer trainingDatasetId, TagsDTO tags) throws MetadataException, FeaturestoreException, SchematizedTagException, DatasetException {
verifyIdProvided(trainingDatasetId);
Users user = jWTHelper.getUserPrincipal(sc);
TrainingDataset trainingDataset = trainingDatasetController.getTrainingDatasetById(featurestore, trainingDatasetId);
AttachTagResult result;
if (tags.getItems().size() == 0) {
result = tagController.upsert(project, user, featurestore, trainingDataset, tags.getName(), tags.getValue());
} else {
Map<String, String> newTags = new HashMap<>();
for (TagsDTO tag : tags.getItems()) {
newTags.put(tag.getName(), tag.getValue());
}
result = tagController.upsert(project, user, featurestore, trainingDataset, newTags);
}
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, project, featurestore.getId(), ResourceRequest.Name.TRAININGDATASETS.name(), trainingDatasetId, 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();
}
}
Aggregations