kf_protocol_message/kf_code_gen/
create_topics.rs

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