diff --git a/api/pom.xml b/api/pom.xml index 0829fe56..b6d49600 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 api diff --git a/api/src/main/java/org/opennms/integration/api/v1/dao/AlarmDao.java b/api/src/main/java/org/opennms/integration/api/v1/dao/AlarmDao.java index 726dad80..e37f3ddb 100644 --- a/api/src/main/java/org/opennms/integration/api/v1/dao/AlarmDao.java +++ b/api/src/main/java/org/opennms/integration/api/v1/dao/AlarmDao.java @@ -1,8 +1,8 @@ /******************************************************************************* * This file is part of OpenNMS(R). * - * Copyright (C) 2018 The OpenNMS Group, Inc. - * OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc. + * Copyright (C) 2018-2023 The OpenNMS Group, Inc. + * OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * @@ -34,6 +34,8 @@ import org.opennms.integration.api.v1.annotations.Consumable; import org.opennms.integration.api.v1.graph.NodeRef; import org.opennms.integration.api.v1.model.Alarm; +import org.opennms.integration.api.v1.model.Severity; +import org.opennms.integration.api.v1.ticketing.Ticket.State; /** * Lookup alarms. @@ -42,10 +44,88 @@ */ @Consumable public interface AlarmDao { - + /** + * Get the number of alarms. + * + * @return the number of alarms + */ Long getAlarmCount(); + /** + * Get all alarms. + * + * @return the list of alarms + */ List getAlarms(); + /** + * Retrieve the highest-severity alarm associated with a node. + * + * @param nodeRef a node reference of foreignSource:foreignId + * @return the alarm, if any + */ Optional getAlarmWithHighestSeverity(NodeRef nodeRef); + + /** + * Get the alarm associated with the given trouble ticket ID. + * + * @since 1.5.0 + * @param ticketId the ticket ID to search for + * @return the associated alarm + */ + Optional getAlarmForTicket(final String ticketId); + + /** + * Updates the ticket state for the given alarm(s). + * + * @since 1.5.0 + * @param state the ticket state to set + * @param alarmIds the alarm(s) to set the state on + */ + void setTicketState(final State state, final int... alarmIds); + + /** + * Acknowledge the specified alarm(s). + * + * @since 1.5.0 + * @param user the user acknowledging the alarm(s) + * @param alarmIds the alarm(s) to acknowledge + */ + void acknowledge(final String user, final int... alarmIds); + + /** + * Unacknowledge the specified alarm(s). + * + * @since 1.5.0 + * @param alarmIds the alarm(s) to unacknowledge + */ + void unacknowledge(final int... alarmIds); + + /** + * Escalate the specified alarm(s). + * + * @since 1.5.0 + * @param user the user escalating the alarm(s) + * @param alarmIds the alarm(s) to escalate + */ + void escalate(final String user, final int... alarmIds); + + /** + * Clear the specified alarm(s). + * + * @since 1.5.0 + * @param alarmIds the alarm(s) to clear + */ + void clear(final int... alarmIds); + + /** + * Set the severity of the specified alarm(s). + * + * @since 1.5.0 + * @param severity the severity to set + * @param alarmIds the alarm(s) to update + */ + void setSeverity(final Severity severity, final int... alarmIds); + + } diff --git a/api/src/main/java/org/opennms/integration/api/v1/model/Alarm.java b/api/src/main/java/org/opennms/integration/api/v1/model/Alarm.java index 3e1ee817..8edc1c9a 100644 --- a/api/src/main/java/org/opennms/integration/api/v1/model/Alarm.java +++ b/api/src/main/java/org/opennms/integration/api/v1/model/Alarm.java @@ -1,8 +1,8 @@ /******************************************************************************* * This file is part of OpenNMS(R). * - * Copyright (C) 2018 The OpenNMS Group, Inc. - * OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc. + * Copyright (C) 2018-2023 The OpenNMS Group, Inc. + * OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * @@ -34,6 +34,7 @@ import org.opennms.integration.api.v1.annotations.Model; import org.opennms.integration.api.v1.config.events.AlarmType; +import org.opennms.integration.api.v1.ticketing.Ticket.State; /** * An alarm. @@ -77,4 +78,16 @@ public interface Alarm { boolean isAcknowledged(); + /** + * @since 1.5.0 + * @return the ticket ID associated with this alarm + */ + String getTicketId(); + + /** + * @since 1.5.0 + * @return the state of the ticket associated with this alarm + */ + State getTicketState(); + } diff --git a/archetypes/example-kar-plugin/pom.xml b/archetypes/example-kar-plugin/pom.xml index 5429aa4c..527548b8 100644 --- a/archetypes/example-kar-plugin/pom.xml +++ b/archetypes/example-kar-plugin/pom.xml @@ -5,7 +5,7 @@ org.opennms.integration.api archetypes - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT example-kar-plugin maven-archetype diff --git a/archetypes/pom.xml b/archetypes/pom.xml index 05294342..e62ca9f4 100644 --- a/archetypes/pom.xml +++ b/archetypes/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 archetypes diff --git a/common/pom.xml b/common/pom.xml index fbe920e2..f752a698 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 common diff --git a/common/src/main/java/org/opennms/integration/api/v1/model/immutables/ImmutableAlarm.java b/common/src/main/java/org/opennms/integration/api/v1/model/immutables/ImmutableAlarm.java index debb6332..0b373b80 100644 --- a/common/src/main/java/org/opennms/integration/api/v1/model/immutables/ImmutableAlarm.java +++ b/common/src/main/java/org/opennms/integration/api/v1/model/immutables/ImmutableAlarm.java @@ -1,8 +1,8 @@ /******************************************************************************* * This file is part of OpenNMS(R). * - * Copyright (C) 2019 The OpenNMS Group, Inc. - * OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc. + * Copyright (C) 2019-2023 The OpenNMS Group, Inc. + * OpenNMS(R) is Copyright (C) 1999-2023 The OpenNMS Group, Inc. * * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. * @@ -40,6 +40,7 @@ import org.opennms.integration.api.v1.model.DatabaseEvent; import org.opennms.integration.api.v1.model.Node; import org.opennms.integration.api.v1.model.Severity; +import org.opennms.integration.api.v1.ticketing.Ticket.State; import org.opennms.integration.api.v1.util.ImmutableCollections; import org.opennms.integration.api.v1.util.MutableCollections; @@ -62,6 +63,8 @@ public final class ImmutableAlarm implements Alarm { private final Date firstEventTime; private final DatabaseEvent lastEvent; private final boolean acknowledged; + private final String ticketId; + private final State ticketState; private ImmutableAlarm(Builder builder) { reductionKey = builder.reductionKey; @@ -79,6 +82,8 @@ private ImmutableAlarm(Builder builder) { firstEventTime = builder.firstEventTime; lastEvent = builder.lastEvent; acknowledged = builder.acknowledged; + ticketId = builder.ticketId; + ticketState = builder.ticketState; } public static Builder newBuilder() { @@ -112,6 +117,8 @@ public static final class Builder { private Date firstEventTime; private DatabaseEvent lastEvent; private boolean acknowledged; + private String ticketId; + private State ticketState; private Builder() { } @@ -132,6 +139,8 @@ private Builder(Alarm alarm) { firstEventTime = alarm.getFirstEventTime(); lastEvent = alarm.getLastEvent(); acknowledged = alarm.isAcknowledged(); + ticketId = alarm.getTicketId(); + ticketState = alarm.getTicketState(); } public Builder setReductionKey(String reductionKey) { @@ -225,6 +234,16 @@ public Builder setAcknowledged(boolean acknowledged) { return this; } + public Builder setTicketId(final String id) { + this.ticketId = id; + return this; + } + + public Builder setTicketState(final State state) { + this.ticketState = state; + return this; + } + public ImmutableAlarm build() { return new ImmutableAlarm(this); } @@ -310,6 +329,16 @@ public boolean isAcknowledged() { return acknowledged; } + @Override + public String getTicketId() { + return ticketId; + } + + @Override + public State getTicketState() { + return ticketState; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -329,14 +358,16 @@ public boolean equals(Object o) { Objects.equals(lastEventTime, that.lastEventTime) && Objects.equals(firstEventTime, that.firstEventTime) && Objects.equals(lastEvent, that.lastEvent) && - Objects.equals(acknowledged, that.acknowledged); + Objects.equals(acknowledged, that.acknowledged) && + Objects.equals(ticketId, that.ticketId) && + Objects.equals(ticketState, that.ticketState); } @Override public int hashCode() { return Objects.hash(reductionKey, id, node, managedObjectInstance, managedObjectType, type, severity, attributes, relatedAlarms, logMessage, description, lastEventTime, firstEventTime, - lastEvent, acknowledged); + lastEvent, acknowledged, ticketId, ticketState); } @Override @@ -357,6 +388,9 @@ public String toString() { ", firstEventTime=" + firstEventTime + ", lastEvent=" + lastEvent + ", acknowledged=" + acknowledged + + ", ticketId=" + ticketId + + ", ticketState=" + ticketState + '}'; } + } diff --git a/config/pom.xml b/config/pom.xml index 99a78055..bfa40712 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 config diff --git a/karaf-features/pom.xml b/karaf-features/pom.xml index 4ba64e67..a531ac53 100644 --- a/karaf-features/pom.xml +++ b/karaf-features/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 karaf-features diff --git a/pom.xml b/pom.xml index 7264fd3e..541a6ee2 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.opennms.integration.api api-project pom - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT OpenNMS Integration API :: Parent https://github.com/OpenNMS/opennms-integration-api Integration and extension API for OpenNMS diff --git a/sample/pom.xml b/sample/pom.xml index fae23089..4af88449 100644 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 org.opennms.integration.api.sample diff --git a/test-api/pom.xml b/test-api/pom.xml index fe792c13..6b11f046 100644 --- a/test-api/pom.xml +++ b/test-api/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 test-api diff --git a/test-suites/pom.xml b/test-suites/pom.xml index 470fc4bd..e90745e4 100644 --- a/test-suites/pom.xml +++ b/test-suites/pom.xml @@ -2,7 +2,7 @@ org.opennms.integration.api api-project - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 test-suites diff --git a/test-suites/tss-tests/pom.xml b/test-suites/tss-tests/pom.xml index d9b9e04f..4e7bb0cc 100644 --- a/test-suites/tss-tests/pom.xml +++ b/test-suites/tss-tests/pom.xml @@ -3,7 +3,7 @@ org.opennms.integration.api test-suites - v1.4.1-SNAPSHOT + 1.5.0-SNAPSHOT 4.0.0 tss-tests