Search in sources :

Example 1 with AlertDTO

use of io.hops.hopsworks.api.alert.AlertDTO 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();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) FeatureGroupAlertDTO(io.hops.hopsworks.api.featurestore.datavalidation.alert.FeatureGroupAlertDTO) Project(io.hops.hopsworks.persistence.entity.project.Project) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) ProjectServiceAlert(io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 2 with AlertDTO

use of io.hops.hopsworks.api.alert.AlertDTO in project hopsworks by logicalclocks.

the class AdminAlertResource method getAlerts.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get alerts.", response = ActivitiesDTO.class)
public Response getAlerts(@BeanParam Pagination pagination, @BeanParam AlertBeanParam alertBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.ALERTS);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    AlertDTO alertDTO = alertBuilder.buildItems(uriInfo, resourceRequest, alertBeanParam, null);
    return Response.ok().entity(alertDTO).build();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with AlertDTO

use of io.hops.hopsworks.api.alert.AlertDTO in project hopsworks by logicalclocks.

the class JobAlertsResource 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 AlertException {
    JobAlert jobAlert = jobalertsFacade.findByJobAndId(job, id);
    List<Alert> alerts;
    try {
        alerts = alertController.testAlert(job.getProject(), jobAlert);
    } 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, job.getProject());
    return Response.ok().entity(alertDTO).build();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) JobAlert(io.hops.hopsworks.persistence.entity.jobs.description.JobAlert) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 4 with AlertDTO

use of io.hops.hopsworks.api.alert.AlertDTO in project hopsworks by logicalclocks.

the class FeatureGroupAlertResource 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 AlertException {
    FeatureGroupAlert featureGroupAlert = featureGroupAlertFacade.findByFeatureGroupAndId(featuregroup, id);
    List<Alert> alerts;
    try {
        alerts = alertController.testAlert(featuregroup.getFeaturestore().getProject(), featureGroupAlert);
    } 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, featuregroup.getFeaturestore().getProject());
    return Response.ok().entity(alertDTO).build();
}
Also used : AlertDTO(io.hops.hopsworks.api.alert.AlertDTO) FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerAccessControlException(io.hops.hopsworks.alert.exception.AlertManagerAccessControlException) FeatureGroupAlert(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert) Alert(io.hops.hopsworks.alerting.api.alert.dto.Alert) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) AlertException(io.hops.hopsworks.exceptions.AlertException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

AlertDTO (io.hops.hopsworks.api.alert.AlertDTO)4 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)4 ApiOperation (io.swagger.annotations.ApiOperation)4 Produces (javax.ws.rs.Produces)4 AlertManagerAccessControlException (io.hops.hopsworks.alert.exception.AlertManagerAccessControlException)3 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)3 Alert (io.hops.hopsworks.alerting.api.alert.dto.Alert)3 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)3 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)3 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)3 AlertException (io.hops.hopsworks.exceptions.AlertException)3 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 FeatureGroupAlertDTO (io.hops.hopsworks.api.featurestore.datavalidation.alert.FeatureGroupAlertDTO)1 FeatureGroupAlert (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.alert.FeatureGroupAlert)1 JobAlert (io.hops.hopsworks.persistence.entity.jobs.description.JobAlert)1 Project (io.hops.hopsworks.persistence.entity.project.Project)1 ProjectServiceAlert (io.hops.hopsworks.persistence.entity.project.alert.ProjectServiceAlert)1 GET (javax.ws.rs.GET)1