use of io.hops.hopsworks.api.git.execution.GitOpExecutionDTO in project hopsworks by logicalclocks.
the class GitResource method remotes.
@ApiOperation(value = "Add or delete a git remote", response = GitOpExecutionDTO.class)
@POST
@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 remotes(@PathParam("repositoryId") Integer repositoryId, @QueryParam("action") GitRemotesAction action, @QueryParam("url") String remoteUrl, @QueryParam("name") String remoteName, @Context SecurityContext sc, @Context UriInfo uriInfo, @BeanParam ExecutionBeanParam executionBeanParam) throws GitOpException, HopsSecurityException, IllegalArgumentException {
if (action == null) {
throw new IllegalArgumentException(RESTCodes.GitOpErrorCode.INVALID_REMOTES_ACTION.getMessage());
}
Users hopsworksUser = jWTHelper.getUserPrincipal(sc);
GitOpExecution execution = gitController.addOrDeleteRemote(action, project, hopsworksUser, repositoryId, remoteName, remoteUrl);
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.git.execution.GitOpExecutionDTO in project hopsworks by logicalclocks.
the class GitResource method executeRepositoryAction.
@ApiOperation(value = "Perform a git repository action: commit, pull, push, status", response = GitOpExecutionDTO.class)
@POST
@Path("/repository/{repositoryId}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(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 executeRepositoryAction(@PathParam("repositoryId") Integer repository, @QueryParam("action") GitRepositoryAction action, RepositoryActionCommandConfiguration configuration, @Context SecurityContext sc, @Context UriInfo uriInfo, @BeanParam ExecutionBeanParam executionBeanParam) throws GitOpException, HopsSecurityException, IllegalArgumentException {
Users hopsworksUser = jWTHelper.getUserPrincipal(sc);
GitOpExecution execution = gitController.executeRepositoryAction(configuration, project, hopsworksUser, action, repository);
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.git.execution.GitOpExecutionDTO in project hopsworks by logicalclocks.
the class GitResource method clone.
@ApiOperation(value = "Clone a git repository", response = GitOpExecutionDTO.class)
@POST
@Path("/clone")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(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 clone(CloneCommandConfiguration commandDTO, @Context SecurityContext sc, @Context UriInfo uriInfo, @BeanParam ExecutionBeanParam executionBeanParam) throws GitOpException, HopsSecurityException, IllegalArgumentException, UserException, DatasetException {
Users hopsworksUser = jWTHelper.getUserPrincipal(sc);
GitOpExecution execution = gitController.clone(commandDTO, project, hopsworksUser);
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.git.execution.GitOpExecutionDTO 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.git.execution.GitOpExecutionDTO in project hopsworks by logicalclocks.
the class GitResource method fileCheckout.
@ApiOperation(value = "Execute git checkout --filename. The final execution message will " + "contain the list of files in the status. If some of the files in the argument are present in the final " + "execution message then they failed to be checkout out", response = GitOpExecutionDTO.class)
@POST
@Path("/repository/{repositoryId}/file")
@Consumes(MediaType.APPLICATION_JSON)
@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 fileCheckout(@Context UriInfo uriInfo, @PathParam("repositoryId") Integer repositoryId, @Context SecurityContext sc, GitFileCheckout files, @BeanParam ExecutionBeanParam executionBeanParam) throws GitOpException, HopsSecurityException {
Users hopsworksUser = jWTHelper.getUserPrincipal(sc);
GitOpExecution execution = gitController.fileCheckout(project, hopsworksUser, repositoryId, files.getFiles());
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();
}
Aggregations