use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class LibraryResource method get.
@ApiOperation(value = "Get the python libraries installed in this environment", response = LibraryDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.PYTHON }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response get(@BeanParam Pagination pagination, @BeanParam LibrariesBeanParam librariesBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws PythonException {
environmentController.checkCondaEnabled(project, pythonVersion, true);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.LIBRARIES);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(librariesBeanParam.getSortBySet());
resourceRequest.setFilter(librariesBeanParam.getFilter());
if (librariesBeanParam.getExpansions() != null) {
resourceRequest.setExpansions(librariesBeanParam.getExpansions().getResources());
}
LibraryDTO libraryDTO = librariesBuilder.buildItems(uriInfo, resourceRequest, project);
return Response.ok().entity(libraryDTO).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class LibraryCommandsResource method get.
@ApiOperation(value = "Get all commands for this library", response = CommandDTO.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
@ApiKeyRequired(acceptedScopes = { ApiScope.PYTHON }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response get(@PathParam("library") String library, @BeanParam Pagination pagination, @BeanParam CommandBeanParam libraryCommandBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws PythonException {
environmentController.checkCondaEnabled(project, pythonVersion, true);
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.COMMANDS);
resourceRequest.setOffset(pagination.getOffset());
resourceRequest.setLimit(pagination.getLimit());
resourceRequest.setSort(libraryCommandBeanParam.getSortBySet());
resourceRequest.setFilter(libraryCommandBeanParam.getFilter());
CommandDTO dto = commandBuilder.buildItems(uriInfo, resourceRequest, project, library);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ProjectAlertsResource method getAllAlerts.
@GET
@Path("all")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get project, job and feature group alerts.", response = ProjectAllAlertsDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getAllAlerts(@Context UriInfo uriInfo, @Context SecurityContext sc) throws ProjectException {
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
ProjectAlertsDTO projectAlertsDTO = projectAlertsBuilder.buildItemsAll(uriInfo, resourceRequest, getProject());
JobAlertsDTO jobAlertsDTO = jobAlertsBuilder.buildItems(uriInfo, resourceRequest, getProject());
FeatureGroupAlertDTO featureGroupAlertDTO = featureGroupAlertBuilder.buildItems(uriInfo, resourceRequest, getProject());
ProjectAllAlertsDTO projectAllAlertsDTO = new ProjectAllAlertsDTO();
projectAllAlertsDTO.setProjectAlerts(projectAlertsDTO);
projectAllAlertsDTO.setJobAlerts(jobAlertsDTO);
projectAllAlertsDTO.setFeatureGroupAlerts(featureGroupAlertDTO);
return Response.ok().entity(projectAllAlertsDTO).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ProjectAlertsResource method getById.
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Find alert by Id.", response = ProjectAlertsDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getById(@PathParam("id") Integer id, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ProjectException {
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
ProjectAlertsDTO dto = projectAlertsBuilder.build(uriInfo, resourceRequest, getProject(), id);
return Response.ok().entity(dto).build();
}
use of io.hops.hopsworks.common.api.ResourceRequest in project hopsworks by logicalclocks.
the class ProjectAlertsResource method getTestById.
@POST
@Path("{id}/test")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Test alert by Id.", response = ProjectAlertsDTO.class)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getTestById(@PathParam("id") Integer id, @Context UriInfo uriInfo, @Context SecurityContext sc) throws ProjectException, AlertException {
Project project = getProject();
ProjectServiceAlert projectServiceAlert = projectServiceAlertsFacade.findByProjectAndId(project, id);
List<Alert> alerts;
try {
alerts = alertController.testAlert(project, projectServiceAlert);
} catch (AlertManagerUnreachableException | AlertManagerClientCreateException e) {
throw new AlertException(RESTCodes.AlertErrorCode.FAILED_TO_CONNECT, Level.FINE, e.getMessage());
} catch (AlertManagerAccessControlException e) {
throw new AlertException(RESTCodes.AlertErrorCode.ACCESS_CONTROL_EXCEPTION, Level.FINE, e.getMessage());
} catch (AlertManagerResponseException e) {
throw new AlertException(RESTCodes.AlertErrorCode.RESPONSE_ERROR, Level.FINE, e.getMessage());
}
ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
AlertDTO alertDTO = alertBuilder.getAlertDTOs(uriInfo, resourceRequest, alerts, project);
return Response.ok().entity(alertDTO).build();
}
Aggregations