use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ModelsResource method getTag.
@ApiOperation(value = "Get tag attached to a model", response = TagsDTO.class)
@GET
@Path("/{id}/tags/{name}")
@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 getTag(@Context SecurityContext sc, @Context UriInfo uriInfo, @ApiParam(value = "Id of the model", required = true) @PathParam("id") String id, @ApiParam(value = "Name of the tag", required = true) @PathParam("name") String name, @BeanParam TagsExpansionBeanParam tagsExpansionBeanParam) throws DatasetException, MetadataException, SchematizedTagException, ProvenanceException, ModelRegistryException {
Users user = jwtHelper.getUserPrincipal(sc);
ProvStateDTO fileState = modelsController.getModel(modelRegistryProject, id);
ModelDTO model = modelUtils.convertProvenanceHitToModel(fileState);
Map<String, String> result = new HashMap<>();
result.put(name, tagController.get(userProject, user, modelUtils.getModelFullPath(modelRegistryProject, model.getName(), model.getVersion()), name));
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.TAGS);
resourceRequest.setExpansions(tagsExpansionBeanParam.getResources());
TagsDTO dto = tagBuilder.build(uriInfo, resourceRequest, userProject, modelRegistryProject, fileState.getMlId(), result);
return Response.status(Response.Status.OK).entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class GitResource method getRepositoryRemotes.
@ApiOperation(value = "Get repository configured remotes: git remotes -v", response = GitRepositoryRemoteDTO.class)
@GET
@Path("/repository/{repositoryId}/remote")
@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 getRepositoryRemotes(@Context UriInfo uriInfo, @Context SecurityContext sc, @PathParam("repositoryId") Integer repositoryId) throws GitOpException {
GitRepository repository = commandConfigurationValidator.verifyRepository(project, repositoryId);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.REMOTE);
GitRepositoryRemoteDTO dto = gitRepositoryRemoteBuilder.build(uriInfo, resourceRequest, project, repository);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class GitResource method getRepositoryBranches.
@ApiOperation(value = "Get branches for the given repository", response = BranchDTO.class)
@GET
@Path("/repository/{repositoryId}/branch")
@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 getRepositoryBranches(@Context UriInfo uriInfo, @Context SecurityContext sc, @BeanParam Pagination pagination, @PathParam("repositoryId") Integer repositoryId) throws GitOpException {
GitRepository repository = commandConfigurationValidator.verifyRepository(project, repositoryId);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.BRANCH);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
BranchDTO repositoryBranches = branchBuilder.build(uriInfo, resourceRequest, project, repository);
return Response.ok().entity(repositoryBranches).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class GitResource method branch.
@ApiOperation(value = "Executes a git branch --option command action: add, checkout, delete", response = GitOpExecutionDTO.class)
@POST
@Path("/repository/{repositoryId}/branch")
@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 branch(@PathParam("repositoryId") Integer repositoryId, @QueryParam("action") GitBranchAction action, @QueryParam("branchName") String branchName, @QueryParam("commit") String commit, @Context HttpServletRequest req, @Context SecurityContext sc, @Context UriInfo uriInfo, @BeanParam ExecutionBeanParam executionBeanParam) throws IllegalArgumentException, GitOpException, HopsSecurityException {
if (action == null) {
throw new IllegalArgumentException(RESTCodes.GitOpErrorCode.INVALID_BRANCH_ACTION.getMessage());
}
Users hopsworksUser = jWTHelper.getUserPrincipal(sc);
GitOpExecution execution = gitController.executeBranchAction(action, project, hopsworksUser, repositoryId, branchName, commit);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXECUTION);
resourceRequest.setExpansions(executionBeanParam.getExpansions().getResources());
GitOpExecutionDTO dto = executionBuilder.build(uriInfo, resourceRequest, execution);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class KafkaResource method createTopic.
@ApiOperation(value = "Create a new Kafka topic.")
@POST
@Path("/topics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.KAFKA }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response createTopic(TopicDTO topicDto, @Context UriInfo uriInfo, @Context SecurityContext sc) throws KafkaException, ProjectException, UserException {
kafkaController.createTopic(project, topicDto);
URI uri = uriInfo.getAbsolutePathBuilder().path(topicDto.getName()).build();
topicDto.setHref(uri);
return Response.created(uri).entity(topicDto).build();
}
Aggregations