-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created separate resource for Muting/Unmuting/ Getting mute status, R…
…emoved obsolete resource
- Loading branch information
Showing
5 changed files
with
69 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
ui/src/main/java/org/moskito/control/ui/resource/NotificationsConfiguratorReply.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
ui/src/main/java/org/moskito/control/ui/resource/NotificationsConfiguratorResource.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
ui/src/main/java/org/moskito/control/ui/restapi/control/NotificationSettingsResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.moskito.control.ui.restapi.control; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.info.Contact; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.info.License; | ||
import io.swagger.v3.oas.annotations.media.ArraySchema; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.servers.Server; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.ws.rs.*; | ||
import jakarta.ws.rs.core.MediaType; | ||
import net.anotheria.util.TimeUnit; | ||
import org.moskito.control.core.MuteStatus; | ||
import org.moskito.control.core.Repository; | ||
import org.moskito.control.ui.restapi.ReplyObject; | ||
|
||
@Path("notificationSettings") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Server(url = "/api/v2") | ||
@Tag(name = "Notification Settings API", description = "API for notification settings") | ||
public class NotificationSettingsResource { | ||
@Operation(summary = "Returns mute status", | ||
description = "Returns whether the system is muted currently and for how long" | ||
) | ||
@ApiResponse(description = "Current mute status", | ||
content = @Content(schema = @Schema(implementation = MuteStatus.class))) | ||
@GET | ||
@Path("status") | ||
public ReplyObject getMuteStatus(){ | ||
return new ReplyObject("muteStatus", Repository.getInstance().getEventsDispatcher().getMuteStatus()); | ||
} | ||
|
||
@Operation(summary = "Mutes the system", | ||
description = "Mutes all notifications for the provided number of minutes, or default if not provided. Used for planed maintenance windows" | ||
) | ||
@ApiResponse(description = "Current mute status", | ||
content = @Content(schema = @Schema(implementation = MuteStatus.class))) | ||
@POST @Path("mute") | ||
public ReplyObject mute(@QueryParam("minutes") Integer minutes){ | ||
if (minutes==null) | ||
Repository.getInstance().getEventsDispatcher().mute(); | ||
else | ||
Repository.getInstance().getEventsDispatcher().mute(TimeUnit.MINUTE.getMillis(minutes)); | ||
return new ReplyObject("muteStatus", Repository.getInstance().getEventsDispatcher().getMuteStatus()); | ||
} | ||
|
||
@Operation(summary = "Unmutes the system", | ||
description = "Cancels previously set mute status. This is useful if you muted for a maintenace window and want to unmute after it is over" | ||
) | ||
@ApiResponse(description = "Current mute status", | ||
content = @Content(schema = @Schema(implementation = MuteStatus.class))) | ||
@POST @Path("unmute") | ||
public ReplyObject unmute(){ | ||
Repository.getInstance().getEventsDispatcher().unmute(); | ||
return new ReplyObject("muteStatus", Repository.getInstance().getEventsDispatcher().getMuteStatus()); | ||
} | ||
} |