/*
 * 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.
 */

syntax = "proto3";

import "google/protobuf/empty.proto";

package org.opennms.plugin.grpc.proto.spog;

option java_multiple_files = true;
option java_package = "org.opennms.plugin.grpc.proto.spog";

message NodeCriteria {
  uint64 id = 1;
  string foreign_source = 2;
  string foreign_id = 3;
  string node_label = 4;
  string location = 5;
}

enum Severity {
  INDETERMINATE = 0;
  CLEARED = 1;
  NORMAL = 2;
  WARNING = 3;
  MINOR = 4;
  MAJOR = 5;
  CRITICAL = 6;
}

message IpInterface {
  uint64 id = 1;
  string ip_address = 2;
  string primary_type = 3;
  repeated string service = 4;
}

message SnmpInterface {
  uint64 id = 1;
  uint32 if_index = 2;
  string if_descr = 3;
  uint32 if_type = 4;
  string if_name = 5;
  uint64 if_speed = 6;
  string if_phys_address = 7;
  uint32 if_admin_status = 8;
  uint32 if_oper_status = 9;
  string if_alias = 10;
}

message Node {
  uint64 id = 1;
  string foreign_source = 2;
  string foreign_id = 3;
  string location = 4;
  repeated string category = 5;
  string label = 6;
  uint64 create_time = 7;
  string sys_contact = 8;
  string sys_description = 9;
  string sys_object_id = 10;
  string sys_name = 11;
  repeated IpInterface ip_interface = 12;
  repeated SnmpInterface snmp_interface = 13;
}

message Alarm {
  uint64 id = 1;
  string uei = 2;
  NodeCriteria node_criteria = 3;
  string ip_address = 4;
  string service_name = 5;
  string reduction_key = 6;
  enum Type {
    PROBLEM_WITH_CLEAR = 0;
    CLEAR = 1;
    PROBLEM_WITHOUT_CLEAR = 2;
  }
  uint32 type = 7;
  uint64 count = 8;
  uint32 severity = 9;
  uint64 first_event_time = 10;
  string description = 11;
  string log_message = 12;
  string ack_user = 13;
  uint64 ack_time = 14;
  uint64 last_event_time = 16;
  uint32 if_index = 17;
  string operator_instructions = 18;
  string clear_key = 19;
  string managed_object_instance = 20;
  string managed_object_type = 21;
  repeated Alarm relatedAlarm = 22;
  uint64 last_update_time = 25;
}

message EventParameter {
  string name = 1;
  string value = 2;
  string type = 3;
}

message SnmpInfo {
  string id = 1;
  string version = 2;
  uint32 specific = 3;
  uint32 generic = 4;
  string community = 5;
  string trap_oid = 6;
}

message Event {
  uint64 id = 1;
  string uei = 2;
  uint64 time = 3;
  string source = 4;
  repeated EventParameter parameter = 5;
  uint64 create_time = 6;
  string description = 7;
  string log_message = 8;
  Severity severity = 9;
  string ip_address = 10;
  string dist_poller = 11;
  SnmpInfo snmpInfo = 12;
  uint64 node_id = 13;
  string label = 14;
}

message NmsInventoryUpdateList {
  string instance_id = 2;
  string instance_name = 3;
  bool snapshot = 4;
  repeated Node nodes = 5;
}

message AlarmUpdateList {
  string instance_id = 2;
  string instance_name = 3;
  bool snapshot = 4;
  repeated Alarm alarms = 5;
}

message EventUpdateList {
  string instance_id = 2;
  string instance_name = 3;
  bool snapshot = 4;
  repeated Event event = 5;
}

message MonitoringInstance {
  string  instance_type = 1;
  string  instance_id = 2;
  string  instance_name = 3;
}

message HeartBeat {
  MonitoringInstance monitoring_instance = 1;
  string message = 2;
  uint64 timestamp = 3;
}


service NmsInventoryServiceSync {
  rpc InventoryUpdate(stream NmsInventoryUpdateList) returns (stream google.protobuf.Empty) {}
  rpc AlarmUpdate(stream AlarmUpdateList) returns (stream google.protobuf.Empty) {}
  rpc EventUpdate(stream EventUpdateList) returns (stream google.protobuf.Empty) {}
  rpc HeartBeatUpdate(stream HeartBeat) returns (stream google.protobuf.Empty) {}
}