//
// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// 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";

// Package target contains messages for defining a configuration of a caching
// collector to connect to multiple gNMI targets.
package target;

import "github.com/openconfig/gnmi/proto/gnmi/gnmi.proto";

option go_package = "github.com/openconfig/gnmi/proto/target";

// Configuration holds all information necessary for a caching gNMI collector
// to establish subscriptions to a list of gNMI targets.
message Configuration {
  // Request is a keyed list of all SubscriptionRequests that can be sent to
  // to targets in the Configuration.
  // The request must have at minimum a SubscriptionList with a prefix
  // containing origin and one or more Subscriptions.  Only the STREAM mode is
  // supported.
  map<string, gnmi.SubscribeRequest> request = 1;
  // Target is the full list of targets connected to by a caching gNMI
  // collector.  The key of the map is a unique name to identify a target and
  // is set in the prefix.target of a SubscriptionRequest message when connecting
  // to each respective target.
  map<string, Target> target = 2;
  // Identifier for the caching collector.
  string instance_id = 3;
  // Revision for this Configuration. Systems that non-atomically write
  // configuration should populate and require revision, leveraging canonical
  // protobuf serialization of fields in order. Presence of this field makes no
  // guarantee. Consumers should account for atomicity constraints of their
  // environment and any custom encoding.
  int64 revision = 536870911;

}

// Target is the information necessary to establish a single gNMI Subscribe RPC
// to be collected and cached.
message Target {
  // A list of address and port or name that resolves to an address and port.
  repeated string addresses = 1;
  // Credentials to use in metadata for authorization of the RPC
  Credentials credentials = 2;
  // The request to be sent to the target. The string supplied is looked up in
  // the request map of the Configuration message.
  string request = 3;
  // Additional target metadata.
  map<string, string> meta = 4;
}

// Credentials contains the fields necessary for authentication of the client to
// the target.
message Credentials {
  string username = 1;
  string password = 2;
  // Password lookup ID.
  string password_id = 3;
}
