-
Notifications
You must be signed in to change notification settings - Fork 0
/
etcd_client.pyi
377 lines (320 loc) · 10.4 KB
/
etcd_client.pyi
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
"""
Type hints for Native Rust Extension
"""
from dataclasses import dataclass
from enum import Enum
from typing import Any, AsyncIterator, Final, Optional
@dataclass
class EtcdLockOption:
lock_name: bytes
timeout: Optional[float]
ttl: Optional[int]
class CompareOp:
""" """
EQUAL: Final[Any]
"""
"""
NOT_EQUAL: Final[Any]
"""
"""
GREATER: Final[Any]
"""
"""
LESS: Final[Any]
"""
"""
class Compare:
@staticmethod
def version(key: bytes, cmp: "CompareOp", version: int) -> "Compare": ...
"""
Compares the version of the given key.
"""
@staticmethod
def create_revision(key: bytes, cmp: "CompareOp", revision: int) -> "Compare": ...
"""
Compares the creation revision of the given key.
"""
@staticmethod
def mod_revision(key: bytes, cmp: "CompareOp", revision: int) -> "Compare": ...
"""
Compares the last modified revision of the given key.
"""
@staticmethod
def value(key: bytes, cmp: "CompareOp", value: bytes) -> "Compare": ...
"""
Compares the value of the given key.
"""
@staticmethod
def lease(key: bytes, cmp: "CompareOp", lease: int) -> "Compare": ...
"""
Compares the lease id of the given key.
"""
def with_range(self, end: bytes) -> "Compare": ...
"""
Sets the comparison to scan the range [key, end).
"""
def with_prefix(self) -> "Compare": ...
"""
Sets the comparison to scan all keys prefixed by the key.
"""
class Txn:
"""
Transaction of multiple operations.
"""
def __init__(self) -> None: ...
"""
Creates a new transaction.
"""
def when(self, compares: list["Compare"]) -> "Txn": ...
"""
Takes a list of comparison. If all comparisons passed in succeed,
the operations passed into `and_then()` will be executed. Or the operations
passed into `or_else()` will be executed.
"""
def and_then(self, operations: list["TxnOp"]) -> "Txn": ...
"""
Takes a list of operations. The operations list will be executed, if the
comparisons passed in `when()` succeed.
"""
def or_else(self, operations: list["TxnOp"]) -> "Txn": ...
"""
Takes a list of operations. The operations list will be executed, if the
comparisons passed in `when()` fail.
"""
class TxnOp:
"""
Transaction operation.
"""
@staticmethod
def get(key: bytes) -> "TxnOp": ...
@staticmethod
def put(key: bytes, value: bytes) -> "TxnOp": ...
@staticmethod
def delete(key: bytes) -> "TxnOp": ...
@staticmethod
def txn(txn: "Txn") -> "TxnOp": ...
class TxnResponse:
def succeeded(self) -> bool: ...
class Client:
""" """
def __init__(
self, endpoints: list[str], connect_options: Optional["ConnectOptions"] = None
) -> None:
""" """
def connect(self, connect_options: Optional["ConnectOptions"] = None) -> "Client":
""" """
def with_lock(
self,
lock_options: "EtcdLockOption",
connect_options: Optional["ConnectOptions"] = None,
) -> "Client":
""" """
async def __aenter__(self) -> "Communicator":
""" """
async def __aexit__(self, *args) -> None:
""" """
class ConnectOptions:
def __init__(self) -> None: ...
def with_user(self, user: str, password: str) -> "ConnectOptions": ...
def with_keep_alive(self, interval: float, timeout: float) -> "ConnectOptions": ...
def with_keep_alive_while_idle(self, enabled: bool) -> "ConnectOptions": ...
def with_connect_timeout(self, connect_timeout: float) -> "ConnectOptions": ...
def with_timeout(self, timeout: float) -> "ConnectOptions": ...
def with_tcp_keepalive(self, tcp_keepalive: float) -> "ConnectOptions": ...
class Watch:
""" """
def __aiter__(self) -> AsyncIterator["WatchEvent"]:
""" """
async def __anext__(self) -> "WatchEvent":
""" """
class CondVar:
""" """
def __init__(self) -> None:
""" """
async def wait(self) -> None:
""" """
async def notify_waiters(self) -> None:
""" """
class Communicator:
async def get(self, key: bytes) -> list[int]:
"""
Gets the key from the key-value store.
"""
async def get_prefix(self, key: bytes) -> list[tuple[list[int], list[int]]]:
"""
Gets the key from the key-value store.
"""
async def put(self, key: bytes, value: bytes) -> None:
"""
Put the given key into the key-value store.
A put request increments the revision of the key-value store
and generates one event in the event history.
"""
async def txn(self, txn: "Txn") -> "TxnResponse":
"""
Processes multiple operations in a single transaction.
A txn request increments the revision of the key-value store
and generates events with the same revision for every completed operation.
It is not allowed to modify the same key several times within one txn.
"""
async def delete(self, key: bytes) -> None:
"""
Deletes the given key from the key-value store.
"""
async def delete_prefix(self, key: bytes) -> None:
"""
Deletes the given key from the key-value store.
"""
async def keys_prefix(self, key: bytes) -> list[list[int]]:
""" """
async def lock(self, name: bytes) -> None:
"""
Lock acquires a distributed shared lock on a given named lock.
On success, it will return a unique key that exists so long as the
lock is held by the caller. This key can be used in conjunction with
transactions to safely ensure updates to etcd only occur while holding
lock ownership. The lock is held until Unlock is called on the key or the
lease associate with the owner expires.
"""
async def unlock(self, name: bytes) -> None:
"""
Unlock takes a key returned by Lock and releases the hold on lock. The
next Lock caller waiting for the lock will then be woken up and given
ownership of the lock.
"""
async def lease_grant(self, ttl: int) -> None:
"""
Creates a lease which expires if the server does not receive a keepAlive
within a given time to live period. All keys attached to the lease will be expired and
deleted if the lease expires. Each expired key generates a delete event in the event history.
"""
async def lease_revoke(self, id: int) -> None:
"""Revokes a lease. All keys attached to the lease will expire and be deleted."""
async def lease_time_to_live(self, id: int) -> None:
"""Retrieves lease information."""
async def lease_keep_alive(self, id: int) -> None:
"""
Keeps the lease alive by streaming keep alive requests from the client
to the server and streaming keep alive responses from the server to the client.
"""
def watch(
self,
key: bytes,
*,
once: Optional[bool] = False,
ready_event: Optional["CondVar"] = None,
) -> "Watch":
"""
Watches for events happening or that have happened. Both input and output
are streams; the input stream is for creating and canceling watcher and the output
stream sends events. The entire event history can be watched starting from the
last compaction revision.
"""
def watch_prefix(
self,
key: bytes,
*,
once: Optional[bool] = False,
ready_event: Optional["CondVar"] = None,
) -> "Watch":
"""
Watches for events happening or that have happened. Both input and output
are streams; the input stream is for creating and canceling watcher and the output
stream sends events. The entire event history can be watched starting from the
last compaction revision.
"""
class Watch:
""" """
async def __aiter__(self) -> AsyncIterator["Watch"]:
""" """
async def __anext__(self) -> "WatchEvent":
""" """
class WatchEvent:
""" """
key: bytes
value: bytes
event: "WatchEventType"
prev_value: Optional[bytes]
def __init__(
key: bytes,
value: bytes,
event: "WatchEventType",
prev_value: Optional[bytes] = None,
) -> None: ...
class WatchEventType:
""" """
PUT: Final[Any]
"""
"""
DELETE: Final[Any]
"""
"""
class CondVar:
""" """
def __init__(self) -> None:
""" """
async def wait(self) -> None:
""" """
async def notify_waiters(self) -> None:
""" """
class ClientError(Exception):
""" """
class GRPCStatusError(ClientError):
""" """
class InvalidArgsError(ClientError):
""" """
class IoError(ClientError):
""" """
class InvalidUriError(ClientError):
""" """
class TransportError(ClientError):
""" """
class WatchError(ClientError):
""" """
class Utf8Error(ClientError):
""" """
class LeaseKeepAliveError(ClientError):
""" """
class ElectError(ClientError):
""" """
class InvalidHeaderValueError(ClientError):
""" """
class EndpointError(ClientError):
""" """
class LockError(ClientError):
""" """
class GRPCStatusCode(Enum):
Ok = 0
"""The operation completed successfully."""
Cancelled = 1
"""The operation was cancelled."""
Unknown = 2
"""Unknown error."""
InvalidArgument = 3
"""Client specified an invalid argument."""
DeadlineExceeded = 4
"""Deadline expired before operation could complete."""
NotFound = 5
"""Some requested entity was not found."""
AlreadyExists = 6
"""Some entity that we attempted to create already exists."""
PermissionDenied = 7
"""The caller does not have permission to execute the specified operation."""
ResourceExhausted = 8
"""Some resource has been exhausted."""
FailedPrecondition = 9
"""The system is not in a state required for the operation's execution."""
Aborted = 10
"""The operation was aborted."""
OutOfRange = 11
"""Operation was attempted past the valid range."""
Unimplemented = 12
"""Operation is not implemented or not supported."""
Internal = 13
"""Internal error."""
Unavailable = 14
"""The service is currently unavailable."""
DataLoss = 15
"""Unrecoverable data loss or corruption."""
Unauthenticated = 16
"""The request does not have valid authentication credentials."""