// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You 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.

{
  "apiKey": 52,
  "type": "request",
  "listeners": ["controller"],
  "name": "VoteRequest",
  // Version 1 adds voter key and directory id (KIP-853)
  // Version 2 adds PreVote field and renames candidate to replica
  "validVersions": "0-2",
  "flexibleVersions": "0+",
  "fields": [
    { "name": "ClusterId", "type": "string", "versions": "0+",
      "nullableVersions": "0+", "default": "null",
      "about":  "The cluster id."},
    { "name": "VoterId", "type": "int32", "versions": "1+", "ignorable": true, "default": "-1", "entityType": "brokerId",
      "about": "The replica id of the voter receiving the request." },
    { "name": "Topics", "type": "[]TopicData", "versions": "0+",
      "about": "The topic data.", "fields": [
        { "name": "TopicName", "type": "string", "versions": "0+", "entityType": "topicName",
          "about": "The topic name." },
        { "name": "Partitions", "type": "[]PartitionData",
          "versions": "0+", "about": "The partition data.", "fields": [
            { "name": "PartitionIndex", "type": "int32", "versions": "0+",
              "about": "The partition index." },
            { "name": "ReplicaEpoch", "type": "int32", "versions": "0+",
              "about": "The epoch of the voter sending the request"},
            { "name": "ReplicaId", "type": "int32", "versions": "0+", "entityType": "brokerId",
              "about": "The replica id of the voter sending the request"},
            { "name": "ReplicaDirectoryId", "type": "uuid", "versions": "1+", "ignorable": true,
              "about": "The directory id of the voter sending the request" },
            { "name": "VoterDirectoryId", "type": "uuid", "versions": "1+", "ignorable": true,
              "about": "The directory id of the voter receiving the request"},
            { "name": "LastOffsetEpoch", "type": "int32", "versions": "0+",
              "about": "The epoch of the last record written to the metadata log."},
            { "name": "LastOffset", "type": "int64", "versions": "0+",
              "about": "The log end offset of the metadata log of the voter sending the request."},
            { "name": "PreVote", "type": "bool", "versions": "2+",
              "about": "Whether the request is a PreVote request (not persisted) or not."}
          ]
        }
      ]
    }
  ]
}
