
= Situation Feedback

Situation feedback is an optional feature for the management of user-contributed feedback regarding correlation of alarms.

It is a simple API for the submission and retrieval of correlation feedback.

== GET (reading data)

[caption=]
.Situation Feedback API GET function
[options="autowidth"]
|===
| Parameter | Description

| /situation-feedback/\{situationid}
| Get situation feedback for the situation with `AlarmId` = `\{situationid}`.
|===

NOTE: `situationId` is the same as the `AlarmId` for the situation.

== Use examples with cURL

.Retrieve situation feedback for the situation with AlarmId == 210
[source,bash]
----
curl -u admin:admin "http://localhost:8980/opennms/rest/situation-feedback/210"
----

.Response
[source,json]
----
[
    {
        "situationKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
        "situationFingerprint": "NDg3ZjdiMjJmNjgzMTJkMmMxYmJjOTNiMWFlYTQ0NWI=",
        "alarmKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:ALARM_A",
        "feedbackType": "CORRECT",
        "reason": "okay",
        "user": "admin",
        "timestamp": 1535057676107
    },
    {
        "situationKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
        "situationFingerprint": "NDg3ZjdiMjJmNjgzMTJkMmMxYmJjOTNiMWFlYTQ0NWI=",
        "alarmKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:ALARM_B",
        "feedbackType": "CORRECT",
        "reason": "okay",
        "user": "admin",
        "timestamp": 1535057676107
    }
]

----

== POST (adding data)

POST requires using `application/json` as a `Content-Type`.

On a successful request, the feedback will be persisted.

[caption=]
.Situation Feedback API POST function
[options="autowidth"]
|===
| Resource  | Description

| /situation-feedback/\{situationid}
| Submits feedback for the situation identified with `AlarmId` = `\{situationid}`.
|===

== Use examples with cURL

.Submit positive Feedback for a Situation with 2 alarms.
[source,bash]
----
curl -X POST  -H "Accept: application/json" -H "Content-Type: application/json" -u admin:admin  -d @feedback.json  http://127.0.0.1:8980/opennms/rest/situation-feedback/210
----

.Contents of feedback.json
[source,javascript]
----
[
    {
        "situationKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
        "situationFingerprint": "NDg3ZjdiMjJmNjgzMTJkMmMxYmJjOTNiMWFlYTQ0NWI=",
        "alarmKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:ALARM_A",
        "feedbackType": "CORRECT",
        "reason": "okay",
        "user": "admin",
        "timestamp": 1535057676107
    },
    {
        "situationKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
        "situationFingerprint": "NDg3ZjdiMjJmNjgzMTJkMmMxYmJjOTNiMWFlYTQ0NWI=",
        "alarmKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:ALARM_B",
        "feedbackType": "CORRECT",
        "reason": "okay",
        "user": "admin",
        "timestamp": 1535057676107
    }
]
----

.Response
[source,javascript]
----
204 No Content
----
