use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired 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.filter.apiKey.ApiKeyRequired 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.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ExecutionsResource method retryLog.
@ApiOperation(value = "Retry log aggregation of given execution and type", response = JobLogDTO.class)
@POST
@Path("{id}/log/{type}")
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response retryLog(@PathParam("id") Integer id, @PathParam("type") JobLogDTO.LogType type, @Context SecurityContext sc) throws JobException {
Execution execution = executionController.authorize(job, id);
JobLogDTO dto = executionController.retryLogAggregation(execution, type);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ExecutionsResource method getLog.
@ApiOperation(value = "Retrieve log of given execution and type", response = JobLogDTO.class)
@GET
@Path("{id}/log/{type}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getLog(@PathParam("id") Integer id, @PathParam("type") JobLogDTO.LogType type, @Context SecurityContext sc) throws JobException {
Execution execution = executionController.authorize(job, id);
JobLogDTO dto = executionController.getLog(execution, type);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class ExecutionsResource method delete.
@ApiOperation(value = "Delete an execution of a job by Id", response = ExecutionDTO.class)
@DELETE
@Path("{id}")
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API, Audience.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response delete(@ApiParam(value = "execution id", required = true) @PathParam("id") Integer id, @Context UriInfo uriInfo, @Context SecurityContext sc) throws JobException {
Users user = jWTHelper.getUserPrincipal(sc);
// If requested execution does not belong to job
Execution execution = executionController.authorize(job, id);
executionController.delete(execution, user);
return Response.noContent().build();
}
Aggregations