@@ -883,6 +883,39 @@ def from_proto(
883
883
)
884
884
885
885
886
+ @dataclass
887
+ class AlterConsumer (IToProto , IFromPublic ):
888
+ name : str
889
+ set_important : bool
890
+ set_read_from : datetime .datetime
891
+ set_supported_codecs : SupportedCodecs
892
+ alter_attributes : Dict [str , str ]
893
+
894
+ def to_proto (self ) -> ydb_topic_pb2 .AlterConsumer :
895
+ return ydb_topic_pb2 .AlterConsumer (
896
+ name = self .name ,
897
+ set_important = self .set_important ,
898
+ set_read_from = proto_timestamp_from_datetime (self .set_read_from ),
899
+ set_supported_codecs = self .set_supported_codecs .to_proto (),
900
+ alter_attributes = self .alter_attributes ,
901
+ )
902
+
903
+ @staticmethod
904
+ def from_public (alter_consumer : ydb_topic_public_types .PublicAlterConsumer ) -> AlterConsumer :
905
+ if not alter_consumer :
906
+ return None
907
+
908
+ supported_codecs = alter_consumer .set_supported_codecs if alter_consumer .set_supported_codecs else []
909
+
910
+ return AlterConsumer (
911
+ name = alter_consumer .name ,
912
+ set_important = alter_consumer .set_important ,
913
+ set_read_from = alter_consumer .set_read_from ,
914
+ set_supported_codecs = SupportedCodecs (codecs = supported_codecs ),
915
+ alter_attributes = alter_consumer .alter_attributes ,
916
+ )
917
+
918
+
886
919
@dataclass
887
920
class PartitioningSettings (IToProto , IFromProto ):
888
921
min_active_partitions : int
@@ -902,6 +935,25 @@ def to_proto(self) -> ydb_topic_pb2.PartitioningSettings:
902
935
)
903
936
904
937
938
+ @dataclass
939
+ class AlterPartitioningSettings (IToProto , IFromProto ):
940
+ set_min_active_partitions : int
941
+ set_partition_count_limit : int
942
+
943
+ @staticmethod
944
+ def from_proto (msg : ydb_topic_pb2 .AlterPartitioningSettings ) -> "AlterPartitioningSettings" :
945
+ return AlterPartitioningSettings (
946
+ set_min_active_partitions = msg .set_min_active_partitions ,
947
+ set_partition_count_limit = msg .set_partition_count_limit ,
948
+ )
949
+
950
+ def to_proto (self ) -> ydb_topic_pb2 .AlterPartitioningSettings :
951
+ return ydb_topic_pb2 .AlterPartitioningSettings (
952
+ set_min_active_partitions = self .set_min_active_partitions ,
953
+ set_partition_count_limit = self .set_partition_count_limit ,
954
+ )
955
+
956
+
905
957
class MeteringMode (int , IFromProto , IFromPublic , IToPublic ):
906
958
UNSPECIFIED = 0
907
959
RESERVED_CAPACITY = 1
@@ -995,6 +1047,83 @@ class CreateTopicResult:
995
1047
pass
996
1048
997
1049
1050
+ @dataclass
1051
+ class AlterTopicRequest (IToProto , IFromPublic ):
1052
+ path : str
1053
+ add_consumers : List ["Consumer" ]
1054
+ alter_partitioning_settings : AlterPartitioningSettings
1055
+ set_retention_period : datetime .timedelta
1056
+ set_retention_storage_mb : int
1057
+ set_supported_codecs : SupportedCodecs
1058
+ set_partition_write_burst_bytes : typing .Optional [int ]
1059
+ set_partition_write_speed_bytes_per_second : typing .Optional [int ]
1060
+ alter_attributes : Dict [str , str ]
1061
+ alter_consumers : List [AlterConsumer ]
1062
+ drop_consumers : List [str ]
1063
+ set_metering_mode : "MeteringMode"
1064
+
1065
+ def to_proto (self ) -> ydb_topic_pb2 .AlterTopicRequest :
1066
+ return ydb_topic_pb2 .AlterTopicRequest (
1067
+ path = self .path ,
1068
+ add_consumers = [consumer .to_proto () for consumer in self .add_consumers ],
1069
+ alter_partitioning_settings = self .alter_partitioning_settings .to_proto (),
1070
+ set_retention_period = proto_duration_from_timedelta (self .set_retention_period ),
1071
+ set_retention_storage_mb = self .set_retention_storage_mb ,
1072
+ set_supported_codecs = self .set_supported_codecs .to_proto (),
1073
+ set_partition_write_burst_bytes = self .set_partition_write_burst_bytes ,
1074
+ set_partition_write_speed_bytes_per_second = self .set_partition_write_speed_bytes_per_second ,
1075
+ alter_attributes = self .alter_attributes ,
1076
+ alter_consumers = [consumer .to_proto () for consumer in self .alter_consumers ],
1077
+ drop_consumers = list (self .drop_consumers ),
1078
+ set_metering_mode = self .set_metering_mode ,
1079
+ )
1080
+
1081
+ @staticmethod
1082
+ def from_public (req : ydb_topic_public_types .AlterTopicRequestParams ) -> AlterTopicRequest :
1083
+ add_consumers = []
1084
+ if req .add_consumers :
1085
+ for consumer in req .add_consumers :
1086
+ if isinstance (consumer , str ):
1087
+ consumer = ydb_topic_public_types .PublicConsumer (name = consumer )
1088
+ add_consumers .append (Consumer .from_public (consumer ))
1089
+
1090
+ alter_consumers = []
1091
+ if req .alter_consumers :
1092
+ for consumer in req .alter_consumers :
1093
+ if isinstance (consumer , str ):
1094
+ consumer = ydb_topic_public_types .PublicAlterConsumer (name = consumer )
1095
+ alter_consumers .append (AlterConsumer .from_public (consumer ))
1096
+
1097
+ drop_consumers = req .drop_consumers if req .drop_consumers else []
1098
+
1099
+ supported_codecs = req .set_supported_codecs if req .set_supported_codecs else []
1100
+
1101
+ return AlterTopicRequest (
1102
+ path = req .path ,
1103
+ alter_partitioning_settings = AlterPartitioningSettings (
1104
+ set_min_active_partitions = req .set_min_active_partitions ,
1105
+ set_partition_count_limit = req .set_partition_count_limit ,
1106
+ ),
1107
+ add_consumers = add_consumers ,
1108
+ set_retention_period = req .set_retention_period ,
1109
+ set_retention_storage_mb = req .set_retention_storage_mb ,
1110
+ set_supported_codecs = SupportedCodecs (
1111
+ codecs = supported_codecs ,
1112
+ ),
1113
+ set_partition_write_burst_bytes = req .set_partition_write_burst_bytes ,
1114
+ set_partition_write_speed_bytes_per_second = req .set_partition_write_speed_bytes_per_second ,
1115
+ alter_attributes = req .alter_attributes ,
1116
+ alter_consumers = alter_consumers ,
1117
+ drop_consumers = drop_consumers ,
1118
+ set_metering_mode = MeteringMode .from_public (req .set_metering_mode ),
1119
+ )
1120
+
1121
+
1122
+ @dataclass
1123
+ class AlterTopicResult :
1124
+ pass
1125
+
1126
+
998
1127
@dataclass
999
1128
class DescribeTopicRequest :
1000
1129
path : str
0 commit comments