Search in sources :

Example 71 with ResourceRequest

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();
}
Also used : ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 72 with ResourceRequest

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();
}
Also used : Execution(io.hops.hopsworks.persistence.entity.jobs.history.Execution) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) UriBuilder(javax.ws.rs.core.UriBuilder) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 73 with ResourceRequest

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();
}
Also used : Execution(io.hops.hopsworks.persistence.entity.jobs.history.Execution) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 74 with ResourceRequest

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();
}
Also used : Jobs(io.hops.hopsworks.persistence.entity.jobs.description.Jobs) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 75 with ResourceRequest

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();
}
Also used : GitOpExecutionDTO(io.hops.hopsworks.api.git.execution.GitOpExecutionDTO) GitOpExecution(io.hops.hopsworks.persistence.entity.git.GitOpExecution) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) ApiKeyRequired(io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)171 ApiOperation (io.swagger.annotations.ApiOperation)163 Produces (javax.ws.rs.Produces)157 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)151 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)127 GET (javax.ws.rs.GET)107 Path (javax.ws.rs.Path)99 ApiKeyRequired (io.hops.hopsworks.api.filter.apiKey.ApiKeyRequired)94 Users (io.hops.hopsworks.persistence.entity.user.Users)75 Consumes (javax.ws.rs.Consumes)37 POST (javax.ws.rs.POST)30 PUT (javax.ws.rs.PUT)27 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)20 TagsDTO (io.hops.hopsworks.common.tags.TagsDTO)17 AlertException (io.hops.hopsworks.exceptions.AlertException)14 Project (io.hops.hopsworks.persistence.entity.project.Project)14 UriBuilder (javax.ws.rs.core.UriBuilder)12 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)11 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)11 HashMap (java.util.HashMap)9