@@ -55,3 +55,201 @@ def to_proto(self) -> ydb_coordination_pb2.DropNodeRequest:
5555 return ydb_coordination_pb2 .DropNodeRequest (
5656 path = self .path ,
5757 )
58+
59+
60+ @dataclass
61+ class SessionStart (IToProto ):
62+ path : str
63+ timeout_millis : int
64+ description : str = ""
65+ session_id : int = 0
66+ seq_no : int = 0
67+ protection_key : bytes = b""
68+
69+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
70+ return ydb_coordination_pb2 .SessionRequest (session_start = ydb_coordination_pb2 .SessionRequest .SessionStart (
71+ path = self .path ,
72+ session_id = self .session_id ,
73+ timeout_millis = self .timeout_millis ,
74+ description = self .description ,
75+ seq_no = self .seq_no ,
76+ protection_key = self .protection_key ,
77+ ))
78+
79+
80+ @dataclass
81+ class SessionStop (IToProto ):
82+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
83+ return ydb_coordination_pb2 .SessionRequest (session_stop = ydb_coordination_pb2 .SessionRequest .SessionStop ())
84+
85+
86+ @dataclass
87+ class Ping (IToProto ):
88+ opaque : int = 0
89+
90+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
91+ return ydb_coordination_pb2 .SessionRequest (
92+ ping = ydb_coordination_pb2 .SessionRequest .PingPong (opaque = self .opaque ))
93+
94+
95+ @dataclass
96+ class CreateSemaphore (IToProto ):
97+ name : str
98+ req_id : int
99+ limit : int
100+ data : bytes = b""
101+
102+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
103+ return ydb_coordination_pb2 .SessionRequest (create_semaphore = ydb_coordination_pb2 .SessionRequest .CreateSemaphore (
104+ req_id = self .req_id , name = self .name , limit = self .limit , data = self .data
105+ ))
106+
107+
108+ @dataclass
109+ class UpdateSemaphore (IToProto ):
110+ name : str
111+ req_id : int
112+ data : bytes
113+
114+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
115+ return ydb_coordination_pb2 .SessionRequest (update_semaphore = ydb_coordination_pb2 .SessionRequest .UpdateSemaphore (
116+ req_id = self .req_id , name = self .name , data = self .data
117+ ))
118+
119+
120+ @dataclass
121+ class DeleteSemaphore (IToProto ):
122+ name : str
123+ req_id : int
124+ force : bool = False
125+
126+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
127+ return ydb_coordination_pb2 .SessionRequest (delete_semaphore = ydb_coordination_pb2 .SessionRequest .DeleteSemaphore (
128+ req_id = self .req_id , name = self .name , force = self .force
129+ ))
130+
131+
132+ @dataclass
133+ class AcquireSemaphore (IToProto ):
134+ name : str
135+ req_id : int
136+ count : int = 1
137+ timeout_millis : int = 0
138+ data : bytes = b""
139+ ephemeral : bool = False
140+
141+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
142+ return ydb_coordination_pb2 .SessionRequest (
143+ acquire_semaphore = ydb_coordination_pb2 .SessionRequest .AcquireSemaphore (
144+ req_id = self .req_id ,
145+ name = self .name ,
146+ timeout_millis = self .timeout_millis ,
147+ count = self .count ,
148+ data = self .data ,
149+ ephemeral = self .ephemeral ,
150+ ))
151+
152+
153+ @dataclass
154+ class ReleaseSemaphore (IToProto ):
155+ name : str
156+ req_id : int
157+
158+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
159+ return ydb_coordination_pb2 .SessionRequest (
160+ release_semaphore = ydb_coordination_pb2 .SessionRequest .ReleaseSemaphore (
161+ req_id = self .req_id , name = self .name
162+ ))
163+
164+ @dataclass
165+ class DescribeSemaphore (IToProto ):
166+ include_owners : bool
167+ include_waiters : bool
168+ name : str
169+ req_id : int
170+ watch_data : bool
171+ watch_owners : bool
172+
173+ def to_proto (self ) -> ydb_coordination_pb2 .SessionRequest :
174+ return ydb_coordination_pb2 .SessionRequest (
175+ describe_semaphore = ydb_coordination_pb2 .SessionRequest .DescribeSemaphore (
176+ include_owners = self .include_owners ,
177+ include_waiters = self .include_waiters ,
178+ name = self .name ,
179+ req_id = self .req_id ,
180+ watch_data = self .watch_data ,
181+ watch_owners = self .watch_owners
182+ )
183+ )
184+
185+
186+ @dataclass
187+ class FromServer :
188+ raw : ydb_coordination_pb2 .SessionResponse
189+
190+ @staticmethod
191+ def from_proto (resp : ydb_coordination_pb2 .SessionResponse ) -> "FromServer" :
192+ return FromServer (raw = resp )
193+
194+ def __getattr__ (self , name : str ):
195+ return getattr (self .raw , name )
196+
197+ @property
198+ def status (self ) -> typing .Optional [int ]:
199+ return getattr (self .raw , "status" , None )
200+
201+ @property
202+ def session_started (self ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .SessionStarted ]:
203+ x = getattr (self .raw , "session_started" , None )
204+ return x if getattr (x , "session_id" , 0 ) else None
205+
206+ @property
207+ def session_stopped (self ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .SessionStopped ]:
208+ return getattr (self .raw , "session_stopped" , None ) or None
209+
210+ @property
211+ def failure (self ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .Failure ]:
212+ return getattr (self .raw , "failure" , None ) or None
213+
214+ @property
215+ def pong (self ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .PingPong ]:
216+ return getattr (self .raw , "pong" , None ) or None
217+
218+ @property
219+ def ping (self ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .PingPong ]:
220+ return getattr (self .raw , "ping" , None ) or None
221+
222+ @property
223+ def opaque (self ) -> typing .Optional [int ]:
224+ if getattr (self .raw , "ping" ) is not None :
225+ return getattr (getattr (self .raw , "ping" ), "opaque" , None )
226+
227+ @property
228+ def acquire_semaphore_result (
229+ self ,
230+ ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .AcquireSemaphoreResult ]:
231+ return getattr (self .raw , "acquire_semaphore_result" , None ) or None
232+
233+ @property
234+ def create_semaphore_result (
235+ self ,
236+ ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .CreateSemaphoreResult ]:
237+ return getattr (self .raw , "create_semaphore_result" , None ) or None
238+
239+ @property
240+ def delete_semaphore_result (
241+ self ,
242+ ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .DeleteSemaphoreResult ]:
243+ return getattr (self .raw , "delete_semaphore_result" , None ) or None
244+
245+ @property
246+ def update_semaphore_result (
247+ self ,
248+ ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .UpdateSemaphoreResult ]:
249+ return getattr (self .raw , "update_semaphore_result" , None ) or None
250+
251+ @property
252+ def describe_semaphore_result (
253+ self ,
254+ ) -> typing .Optional [ydb_coordination_pb2 .SessionResponse .DescribeSemaphoreResult ]:
255+ return getattr (self .raw , "describe_semaphore_result" , None ) or None
0 commit comments