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

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

message ServiceComponent {
  string foreign_service = 1;

  string name = 2;

  bool healthy = 3;

  map<string, string> attributes = 4;
  repeated string tags = 5;
}

message InventoryUpdateList {
  string foreign_type = 1;
  string foreign_source = 2;

  bool snapshot = 3;

  repeated ServiceComponent services = 4;
}

message StateUpdate {
  string foreign_service = 1;

  bool healthy = 2;
}

message StateUpdateList {
  string foreign_type = 1;
  string foreign_source = 2;

  repeated StateUpdate updates = 3;
}

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 ServiceSync {
  rpc InventoryUpdate(stream InventoryUpdateList) returns (stream google.protobuf.Empty) {}
  rpc StateUpdate(stream StateUpdateList) returns (stream google.protobuf.Empty) {}
  rpc HeartBeatUpdate(stream HeartBeat) returns (stream google.protobuf.Empty) {}
}