diff --git a/opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/NotificationConfigRestService.java b/opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/NotificationConfigRestService.java new file mode 100644 index 000000000000..4205b930442f --- /dev/null +++ b/opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/NotificationConfigRestService.java @@ -0,0 +1,505 @@ +/* + * Licensed to The OpenNMS Group, Inc (TOG) under one or more + * contributor license agreements. See the LICENSE.md file + * distributed with this work for additional information + * regarding copyright ownership. + * + * TOG licenses this file to You under the GNU Affero General + * Public License Version 3 (the "License") or (at your option) + * any later version. You may not use this file except in + * compliance with the License. You may obtain a copy of the + * License at: + * + * https://www.gnu.org/licenses/agpl-3.0.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.opennms.web.rest.v1; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.SecurityContext; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +import org.opennms.core.db.DataSourceFactory; +import org.opennms.core.utils.DBUtils; +import org.opennms.core.utils.InetAddressUtils; +import org.opennms.netmgt.config.DestinationPathFactory; +import org.opennms.netmgt.config.NotifdConfigFactory; +import org.opennms.netmgt.config.destinationPaths.DestinationPaths; +import org.opennms.netmgt.events.api.EventProxy; +import org.opennms.netmgt.filter.FilterDaoFactory; +import org.opennms.netmgt.filter.api.FilterParseException; +import org.opennms.netmgt.model.events.EventBuilder; +import org.opennms.web.api.Authentication; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; + +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * REST access to the notification configuration that has historically only been + * reachable through the admin JSP wizards. All operations delegate to the same + * file-backed config factories the legacy servlets use, so the XML files + * (notifications.xml, destinationPaths.xml, notificationCommands.xml, + * notifd-configuration.xml) remain the system of record and stay fully + * editable by hand. + * + *
+ When important events are detected by OpenNMS, users may receive a notice, a + descriptive message sent automatically to a pager, an email address, or both. In order to + receive notices, the user must have their notification information configured in their + user profile (see your Administrator for assistance), notices must be on, and an + important event must be received. +
++ From this panel, you may: Check your outstanding notices, which displays + all unacknowledged notices sent to your user ID; View all outstanding + notices, which displays all unacknowledged notices for all users; or + View all acknowledged notices, which provides a summary of all notices + sent and acknowledged for all users. +
++ You may also search for notices associated with a specific user ID by entering that user + ID in the Check notices for user text box. And finally, you can jump + immediately to a page with details specific to a given notice identifier by entering that + numeric identifier in the Get details for notice text box. Note that + this is particularly useful if you are using a numeric paging service and receive the + numeric notice identifier as part of the page. +
++ Once a notice is sent, it is considered outstanding until someone + acknowledges receipt of the notice via the OpenNMS Notification interface. If + the event that triggered the notice was related to managed network devices or systems, + the Network/Systems group will be notified, one by one, with a notice + sent to the next member on the list only after 15 minutes has elapsed since the last + message was sent. This progression through the list, or escalation, can be + stopped at any time by acknowledging the notice. Note that this is not + the same as acknowledging the event which triggered the notice. If all members of the + group have been notified and the notice has not been acknowledged, the notice will be + escalated to the Management group, where all members of that group will + be notified at once with no 15 minute escalation interval. +
++ Define a critical path for a group of nodes so node-down notifications are suppressed when + the critical path is unreachable. The rule selects the nodes; leaving the IP address blank + clears the critical path for the matching nodes. +
+ ++ Enter the critical path IP address in xxx.xxx.xxx.xxx or + xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx format. Or leave it blank to clear previously + set paths for the nodes matching the rule. The critical path service is typically ICMP, + and at this time ICMP is the only critical path service supported. +
++ Filtering on TCP/IP address uses a very flexible format, allowing you to separate the + four octets (fields) of a TCP/IP address into specific searches. An asterisk (*) in + place of any octet matches any value for that octet. Ranges are indicated by two + numbers separated by a dash (-), and commas are used for list demarcation. +
+The following examples are all valid and yield the set of addresses from 192.168.0.0 through 192.168.3.255:
+192.168.0-3.*192.168.0-3.0-255192.168.0,1,2,3.*
+ To use a rule based on TCP/IP addresses as described above, enter
+ IPADDR IPLIKE *.*.*.* substituting your desired address fields for
+ *.*.*.*. Otherwise, you may enter any valid rule.
+
+ Set the critical path to {{ criticalIp }} ({{ criticalSvc }}) for the
+ {{ applyCount ?? '?' }} node{{ applyCount === 1 ? '' : 's' }} matching
+ {{ rule }}?
+
+ Clear the critical path for the {{ applyCount ?? '?' }}
+ node{{ applyCount === 1 ? '' : 's' }} matching {{ rule }}?
+
Remove the critical path for {{ outageToRemove?.nodeLabel ?? outageToRemove?.nodeId }}?
+ +