@@ -886,17 +886,21 @@ def from_proto(
886
886
@dataclass
887
887
class AlterConsumer (IToProto , IFromPublic ):
888
888
name : str
889
- set_important : bool
890
- set_read_from : datetime .datetime
891
- set_supported_codecs : SupportedCodecs
892
- alter_attributes : Dict [str , str ]
889
+ set_important : Optional [ bool ]
890
+ set_read_from : Optional [ datetime .datetime ]
891
+ set_supported_codecs : Optional [ SupportedCodecs ]
892
+ alter_attributes : Optional [ Dict [str , str ] ]
893
893
894
894
def to_proto (self ) -> ydb_topic_pb2 .AlterConsumer :
895
+ supported_codecs = None
896
+ if self .set_supported_codecs is not None :
897
+ supported_codecs = self .set_supported_codecs .to_proto ()
898
+
895
899
return ydb_topic_pb2 .AlterConsumer (
896
900
name = self .name ,
897
901
set_important = self .set_important ,
898
902
set_read_from = proto_timestamp_from_datetime (self .set_read_from ),
899
- set_supported_codecs = self . set_supported_codecs . to_proto () ,
903
+ set_supported_codecs = supported_codecs ,
900
904
alter_attributes = self .alter_attributes ,
901
905
)
902
906
@@ -905,13 +909,15 @@ def from_public(alter_consumer: ydb_topic_public_types.PublicAlterConsumer) -> A
905
909
if not alter_consumer :
906
910
return None
907
911
908
- supported_codecs = alter_consumer .set_supported_codecs if alter_consumer .set_supported_codecs else []
912
+ supported_codecs = None
913
+ if alter_consumer .set_supported_codecs is not None :
914
+ supported_codecs = SupportedCodecs (alter_consumer .set_supported_codecs )
909
915
910
916
return AlterConsumer (
911
917
name = alter_consumer .name ,
912
918
set_important = alter_consumer .set_important ,
913
919
set_read_from = alter_consumer .set_read_from ,
914
- set_supported_codecs = SupportedCodecs ( codecs = supported_codecs ) ,
920
+ set_supported_codecs = supported_codecs ,
915
921
alter_attributes = alter_consumer .alter_attributes ,
916
922
)
917
923
@@ -936,16 +942,9 @@ def to_proto(self) -> ydb_topic_pb2.PartitioningSettings:
936
942
937
943
938
944
@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
- )
945
+ class AlterPartitioningSettings (IToProto ):
946
+ set_min_active_partitions : Optional [int ]
947
+ set_partition_count_limit : Optional [int ]
949
948
950
949
def to_proto (self ) -> ydb_topic_pb2 .AlterPartitioningSettings :
951
950
return ydb_topic_pb2 .AlterPartitioningSettings (
@@ -1050,20 +1049,20 @@ class CreateTopicResult:
1050
1049
@dataclass
1051
1050
class AlterTopicRequest (IToProto , IFromPublic ):
1052
1051
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"
1052
+ add_consumers : Optional [ List ["Consumer" ] ]
1053
+ alter_partitioning_settings : Optional [ AlterPartitioningSettings ]
1054
+ set_retention_period : Optional [ datetime .timedelta ]
1055
+ set_retention_storage_mb : Optional [ int ]
1056
+ set_supported_codecs : Optional [ SupportedCodecs ]
1057
+ set_partition_write_burst_bytes : Optional [int ]
1058
+ set_partition_write_speed_bytes_per_second : Optional [int ]
1059
+ alter_attributes : Optional [ Dict [str , str ] ]
1060
+ alter_consumers : Optional [ List [AlterConsumer ] ]
1061
+ drop_consumers : Optional [ List [str ] ]
1062
+ set_metering_mode : Optional [ "MeteringMode" ]
1064
1063
1065
1064
def to_proto (self ) -> ydb_topic_pb2 .AlterTopicRequest :
1066
- supported_codecs = self .set_supported_codecs .to_proto () if self .set_supported_codecs . codecs else None
1065
+ supported_codecs = self .set_supported_codecs .to_proto () if self .set_supported_codecs else None
1067
1066
1068
1067
return ydb_topic_pb2 .AlterTopicRequest (
1069
1068
path = self .path ,
@@ -1098,7 +1097,9 @@ def from_public(req: ydb_topic_public_types.AlterTopicRequestParams) -> AlterTop
1098
1097
1099
1098
drop_consumers = req .drop_consumers if req .drop_consumers else []
1100
1099
1101
- supported_codecs = req .set_supported_codecs if req .set_supported_codecs else []
1100
+ supported_codecs = None
1101
+ if req .set_supported_codecs is not None :
1102
+ supported_codecs = SupportedCodecs (req .set_supported_codecs )
1102
1103
1103
1104
return AlterTopicRequest (
1104
1105
path = req .path ,
@@ -1109,9 +1110,7 @@ def from_public(req: ydb_topic_public_types.AlterTopicRequestParams) -> AlterTop
1109
1110
add_consumers = add_consumers ,
1110
1111
set_retention_period = req .set_retention_period ,
1111
1112
set_retention_storage_mb = req .set_retention_storage_mb ,
1112
- set_supported_codecs = SupportedCodecs (
1113
- codecs = supported_codecs ,
1114
- ),
1113
+ set_supported_codecs = supported_codecs ,
1115
1114
set_partition_write_burst_bytes = req .set_partition_write_burst_bytes ,
1116
1115
set_partition_write_speed_bytes_per_second = req .set_partition_write_speed_bytes_per_second ,
1117
1116
alter_attributes = req .alter_attributes ,
0 commit comments