// Copyright 2018 The gRPC Authors
// 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.
// Service exported by server reflection

// IMPORTANT NOTE:
// This proto was never stabilized, and is now deprecated.
// The released proto can be found at: grpc/binlog/v1/binarylog.proto

syntax = "proto3";

package grpc.binarylog.v1alpha;

import "google/protobuf/duration.proto";

option java_multiple_files = true;
option java_package = "io.grpc.binarylog.v1alpha";
option java_outer_classname = "BinaryLogProto";

// Log entry we store in binary logs
message GrpcLogEntry {
  // Enumerates the type of logs
  enum Type {
    UNKNOWN_TYPE = 0;
    SEND_INITIAL_METADATA = 1;
    SEND_TRAILING_METADATA = 2;
    SEND_MESSAGE = 3;
    RECV_INITIAL_METADATA = 4;
    RECV_TRAILING_METADATA = 5;
    RECV_MESSAGE = 6;
  };

  // Enumerates the entity that generates the log entry
  enum Logger {
    UNKNOWN_LOGGER = 0;
    CLIENT = 1;
    SERVER = 2;
  }

  Type type = 1 [deprecated = true];      // One of the above Type enum
  Logger logger = 2 [deprecated = true];  // One of the above Logger enum

  // Uniquely identifies a call. Each call may have several log entries, they
  // will share the same call_id. 128 bits split into 2 64-bit parts.
  Uint128 call_id = 3 [deprecated = true];

  // The logger uses one of the following fields to record the payload,
  // according to the type of the log entry.
  oneof payload {
    // Used by {SEND,RECV}_INITIAL_METADATA and
    // {SEND,RECV}_TRAILING_METADATA. This contains only the metadata
    // from the application.
    Metadata metadata = 4 [deprecated = true];
    // Used by {SEND,RECV}_MESSAGE
    Message message = 5 [deprecated = true];
  }

  // Peer address information, will only be recorded in SEND_INITIAL_METADATA
  // and RECV_INITIAL_METADATA entries.
  Peer peer = 6 [deprecated = true];

  // true if payload does not represent the full message or metadata.
  bool truncated = 7 [deprecated = true];

  // The method name. Logged for the first entry:
  // RECV_INITIAL_METADATA for server side or
  // SEND_INITIAL_METADATA for client side.
  string method_name = 8 [deprecated = true];

  // status_code and status_message:
  // Only present for SEND_TRAILING_METADATA on server side or
  // RECV_TRAILING_METADATA on client side.
  uint32 status_code = 9 [deprecated = true];

  // An original status message before any transport specific
  // encoding.
  string status_message = 10 [deprecated = true];

  // The value of the 'grpc-status-details-bin' metadata key. If
  // present, this is always an encoded 'google.rpc.Status' message.
  bytes status_details = 11 [deprecated = true];

  // the RPC timeout
  google.protobuf.Duration timeout = 12 [deprecated = true];

  // The entry sequence id for this call. The first GrpcLogEntry has a
  // value of 1, to disambiguate from an unset value. The purpose of
  // this field is to detect missing entries in environments where
  // durability or ordering is not guaranteed.
  uint32 sequence_id_within_call = 13 [deprecated = true];
};

// Message payload, used by REQUEST and RESPONSE
message Message {
  // This flag is currently used to indicate whether the payload is compressed,
  // it may contain other semantics in the future. Value of 1 indicates that the
  // binary octet sequence of Message is compressed using the mechanism declared
  // by the Message-Encoding header. A value of 0 indicates that no encoding of
  // Message bytes has occurred.
  uint32 flags = 1 [deprecated = true]; // TODO(zpencer): this is changed because there is no uint8
  // Length of the message. It may not be the same as the length of the
  // data field, as the logging payload can be truncated or omitted.
  uint32 length = 2 [deprecated = true];
  // May be truncated or omitted.
  bytes data = 3 [deprecated = true];
}

// A list of metadata pairs, used in the payload of CLIENT_INIT_METADATA,
// SERVER_INIT_METADATA and TRAILING_METADATA
// Implementations may omit some entries to honor the header limits
// of GRPC_BINARY_LOG_CONFIG.
// 
// Implementations will not log the following entries, and this is
// not to be treated as a truncation:
// - entries handled by grpc that are not user visible, such as those
//   that begin with 'grpc-' or keys like 'lb-token'
// - transport specific entries, including but not limited to:
//   ':path', ':authority', 'content-encoding', 'user-agent', 'te', etc
// - entries added for call credentials
message Metadata {
  repeated MetadataEntry entry = 1 [deprecated = true];
}

// A metadata key value pair
message MetadataEntry {
  bytes key = 1 [deprecated = true];
  bytes value = 2 [deprecated = true];
}

// Peer information
message Peer {
  enum PeerType {
    UNKNOWN_PEERTYPE = 0;
    // address is the address in 1.2.3.4 form
    PEER_IPV4 = 1;
    // address the address in canonical form (RFC5952 section 4)
    // The scope is NOT included in the peer string.
    PEER_IPV6 = 2;
    // address is UDS string
    PEER_UNIX = 3;
  };
  PeerType peer_type = 1 [deprecated = true];
  bytes peer = 2 [deprecated = true]; // will be removed: do not use
  string address = 3 [deprecated = true];
  // only for PEER_IPV4 and PEER_IPV6
  uint32 ip_port = 4 [deprecated = true];
}

// Used to record call_id.
message Uint128 {
  fixed64 high = 1 [deprecated = true];
  fixed64 low = 2 [deprecated = true];
};
