Search in sources :

Example 26 with AlertException

use of io.hops.hopsworks.exceptions.AlertException in project hopsworks by logicalclocks.

the class AdminSilenceResource method update.

@PUT
@Path("{silenceId}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update a silence.", response = SilenceDTO.class)
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN" })
public Response update(@PathParam("silenceId") String silenceId, PostableSilenceDTO postableSilenceDTO, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException, ProjectException {
    if (postableSilenceDTO == null) {
        throw new AlertException(RESTCodes.AlertErrorCode.ILLEGAL_ARGUMENT, Level.FINE, "No payload.");
    }
    Users user = jWTHelper.getUserPrincipal(sc);
    postableSilenceDTO.setId(silenceId);
    SilenceID silenceID = postSilence(postableSilenceDTO, user);
    SilenceDTO dto = silenceBuilder.build(uriInfo, new ResourceRequest(ResourceRequest.Name.SILENCES), silenceID.getSilenceID(), null);
    return Response.ok().entity(dto).build();
}
Also used : SilenceDTO(io.hops.hopsworks.api.alert.silence.SilenceDTO) PostableSilenceDTO(io.hops.hopsworks.api.alert.silence.PostableSilenceDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) ResourceRequest(io.hops.hopsworks.common.api.ResourceRequest) AlertException(io.hops.hopsworks.exceptions.AlertException) SilenceID(io.hops.hopsworks.alerting.api.alert.dto.SilenceID) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT)

Aggregations

AlertException (io.hops.hopsworks.exceptions.AlertException)26 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)20 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)20 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)20 Produces (javax.ws.rs.Produces)20 Consumes (javax.ws.rs.Consumes)17 ApiOperation (io.swagger.annotations.ApiOperation)15 AlertManagerConfigCtrlCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException)14 AlertManagerConfigReadException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException)14 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)14 Path (javax.ws.rs.Path)14 AlertManagerConfigUpdateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException)13 AlertManagerAccessControlException (io.hops.hopsworks.alert.exception.AlertManagerAccessControlException)10 POST (javax.ws.rs.POST)10 PUT (javax.ws.rs.PUT)10 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)9 AlertManagerDuplicateEntryException (io.hops.hopsworks.alerting.exceptions.AlertManagerDuplicateEntryException)8 AlertManagerNoSuchElementException (io.hops.hopsworks.alerting.exceptions.AlertManagerNoSuchElementException)7 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)7 Route (io.hops.hopsworks.alerting.config.dto.Route)6