Search in sources :

Example 1 with SilenceDTO

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

the class AdminSilenceResource method get.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all silences.", response = SilenceDTO.class)
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN" })
public Response get(@BeanParam Pagination pagination, @BeanParam SilenceBeanParam silenceBeanParam, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.SILENCES);
    resourceRequest.setOffset(pagination.getOffset());
    resourceRequest.setLimit(pagination.getLimit());
    SilenceDTO dto = silenceBuilder.buildItems(uriInfo, resourceRequest, silenceBeanParam, 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) 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)

Example 2 with SilenceDTO

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

the class AdminSilenceResource method getById.

@GET
@Path("{silenceId}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Find silence by Id.", response = SilenceDTO.class)
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN" })
public Response getById(@PathParam("silenceId") String silenceId, @Context UriInfo uriInfo, @Context SecurityContext sc) throws AlertException {
    ResourceRequest resourceRequest = new ResourceRequest(ResourceRequest.Name.SILENCES);
    SilenceDTO dto = silenceBuilder.build(uriInfo, resourceRequest, silenceId, 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) 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)

Example 3 with SilenceDTO

use of io.hops.hopsworks.api.alert.silence.SilenceDTO 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

PostableSilenceDTO (io.hops.hopsworks.api.alert.silence.PostableSilenceDTO)3 SilenceDTO (io.hops.hopsworks.api.alert.silence.SilenceDTO)3 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)3 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Produces (javax.ws.rs.Produces)3 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 SilenceID (io.hops.hopsworks.alerting.api.alert.dto.SilenceID)1 AlertException (io.hops.hopsworks.exceptions.AlertException)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1