use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired 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.api.filter.apiKey.ApiKeyRequired 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.api.filter.apiKey.ApiKeyRequired 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.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class JobsResource method delete.
@ApiOperation(value = "Delete the job with the given ID")
@DELETE
@Path("{name}")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ 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 = "id", required = true) @PathParam("name") String name, @Context SecurityContext sc, @Context UriInfo uriInfo) throws JobException {
Users user = jWTHelper.getUserPrincipal(sc);
Jobs job = jobController.getJob(project, name);
if (job.getJobConfig().getSchedule() != null) {
jobController.unscheduleJob(job);
}
switch(job.getJobType()) {
case SPARK:
case PYSPARK:
case FLINK:
jobController.deleteJob(job, user);
break;
default:
throw new JobException(RESTCodes.JobErrorCode.JOB_TYPE_UNSUPPORTED, Level.FINEST, job.getJobType().toString());
}
return Response.noContent().build();
}
use of io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired in project hopsworks by logicalclocks.
the class JobsResource method inspect.
@ApiOperation(value = "Inspect user program and return a JobConfiguration", response = SparkJobConfiguration.class)
@GET
@Path("{jobtype : python|docker|spark|pyspark|flink}/inspection")
@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.JOB }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response inspect(@ApiParam(value = "job type", example = "spark") @PathParam("jobtype") JobType jobtype, @ApiParam(value = "path", example = "/Projects/demo_spark_admin000/Resources/spark-examples.jar", required = true) @QueryParam("path") String path, @Context SecurityContext sc) throws JobException {
Users user = jWTHelper.getUserPrincipal(sc);
JobConfiguration config = jobController.inspectProgram(path, project, user, jobtype);
return Response.ok().entity(config).build();
}
Aggregations