1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/// WARNING: CODE GENERATED FILE
/// * This file is generated by kfspec2code.
/// * Any changes applied to this file will be lost when a new spec is generated.
use serde::{Deserialize, Serialize};
use kf_protocol_api::ErrorCode;
use kf_protocol_api::Request;
use kf_protocol_derive::Decode;
use kf_protocol_derive::Encode;
use kf_protocol_derive::KfDefault;
// -----------------------------------
// KfCreateTopicsRequest
// -----------------------------------
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct KfCreateTopicsRequest {
/// The topics to create.
pub topics: Vec<CreatableTopic>,
/// How long to wait in milliseconds before timing out the request.
pub timeout_ms: i32,
/// If true, check that the topics can be created as specified, but don't create anything.
#[fluvio_kf(min_version = 1)]
pub validate_only: bool,
}
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct CreatableTopic {
/// The topic name.
pub name: String,
/// The number of partitions to create in the topic, or -1 if we are specifying a manual
/// partition assignment.
pub num_partitions: i32,
/// The number of replicas to create for each partition in the topic, or -1 if we are specifying
/// a manual partition assignment.
pub replication_factor: i16,
/// The manual partition assignment, or the empty array if we are using automatic assignment.
pub assignments: Vec<CreatableReplicaAssignment>,
/// The custom topic configurations to set.
pub configs: Vec<CreateableTopicConfig>,
}
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct CreatableReplicaAssignment {
/// The partition index.
pub partition_index: i32,
/// The brokers to place the partition on.
pub broker_ids: Vec<i32>,
}
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct CreateableTopicConfig {
/// The configuration name.
pub name: String,
/// The configuration value.
pub value: Option<String>,
}
// -----------------------------------
// KfCreateTopicsResponse
// -----------------------------------
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct KfCreateTopicsResponse {
/// The duration in milliseconds for which the request was throttled due to a quota violation,
/// or zero if the request did not violate any quota.
#[fluvio_kf(min_version = 2, ignorable)]
pub throttle_time_ms: i32,
/// Results for each topic we tried to create.
pub topics: Vec<CreatableTopicResult>,
}
#[derive(Encode, Decode, Serialize, Deserialize, KfDefault, Debug)]
pub struct CreatableTopicResult {
/// The topic name.
pub name: String,
/// The error code, or 0 if there was no error.
pub error_code: ErrorCode,
/// The error message, or null if there was no error.
#[fluvio_kf(min_version = 1, ignorable)]
pub error_message: Option<String>,
}
// -----------------------------------
// Implementation - KfCreateTopicsRequest
// -----------------------------------
impl Request for KfCreateTopicsRequest {
const API_KEY: u16 = 19;
const MIN_API_VERSION: i16 = 0;
const MAX_API_VERSION: i16 = 3;
const DEFAULT_API_VERSION: i16 = 3;
type Response = KfCreateTopicsResponse;
}