Search in sources :

Example 6 with SilenceID

use of io.hops.hopsworks.alerting.api.alert.dto.SilenceID 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

SilenceID (io.hops.hopsworks.alerting.api.alert.dto.SilenceID)6 AlertException (io.hops.hopsworks.exceptions.AlertException)4 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)4 Users (io.hops.hopsworks.persistence.entity.user.Users)4 ApiOperation (io.swagger.annotations.ApiOperation)4 Consumes (javax.ws.rs.Consumes)4 Produces (javax.ws.rs.Produces)4 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)3 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)2 Project (io.hops.hopsworks.persistence.entity.project.Project)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)1 AlertManagerServerException (io.hops.hopsworks.alerting.exceptions.AlertManagerServerException)1 PostableSilenceDTO (io.hops.hopsworks.api.alert.silence.PostableSilenceDTO)1 SilenceDTO (io.hops.hopsworks.api.alert.silence.SilenceDTO)1 WebTarget (javax.ws.rs.client.WebTarget)1