use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ExecutionsResource method getExecutions.
@ApiOperation(value = "Get a list of executions for the job.", response = ExecutionDTO.class)
@GET
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getExecutions(@BeanParam Pagination pagination, @BeanParam ExecutionsBeanParam executionsBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) {
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXECUTIONS);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(executionsBeanParam.getSortBySet());
resourceRequest.setFilter(executionsBeanParam.getFilter());
resourceRequest.setExpansions(executionsBeanParam.getExpansions().getResources());
ExecutionDTO dto = executionsBuilder.build(uriInfo, resourceRequest, job);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ExecutionsResource method startExecution.
@ApiOperation(value = "Start an execution(run) of the job", notes = "Starts a job by creating and starting an Execution.", response = ExecutionDTO.class)
@POST
@Consumes(MediaType.TEXT_PLAIN)
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response startExecution(@ApiParam(value = "Arguments for executing the job") String args, @Context SecurityContext sc, @Context UriInfo uriInfo) throws JobException, GenericException, ServiceException, ProjectException {
Users user = jWTHelper.getUserPrincipal(sc);
Execution exec;
if (!Strings.isNullOrEmpty(job.getJobConfig().getDefaultArgs()) && Strings.isNullOrEmpty(args)) {
exec = executionController.start(job, job.getJobConfig().getDefaultArgs(), user);
} else {
exec = executionController.start(job, args, user);
}
UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
uriBuilder.path(Integer.toString(exec.getId()));
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXECUTIONS);
return Response.created(uriBuilder.build()).entity(executionsBuilder.build(uriInfo, resourceRequest, exec)).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ExecutionsResource method getExecution.
@ApiOperation(value = "Find Execution by Id", response = ExecutionDTO.class)
@GET
@Path("{id}")
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getExecution(@ApiParam(value = "execution id", required = true) @PathParam("id") Integer id, @BeanParam ExecutionsBeanParam executionsBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws JobException {
// If requested execution does not belong to job
Execution execution = executionController.authorize(job, id);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.EXECUTIONS);
resourceRequest.setExpansions(executionsBeanParam.getExpansions().getResources());
ExecutionDTO dto = executionsBuilder.build(uriInfo, resourceRequest, execution);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class JobsResource method getJob.
@ApiOperation(value = "Get the job with requested ID", response = JobDTO.class)
@GET
@Path("{name}")
@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 getJob(@PathParam("name") String name, @BeanParam JobsBeanParam jobsBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws JobException {
Jobs job = jobController.getJob(project, name);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.JOBS);
resourceRequest.setExpansions(jobsBeanParam.getExpansions().getResources());
JobDTO dto = jobsBuilder.build(uriInfo, resourceRequest, job);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest 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();
}
Aggregations