ouisync.session

Session API: connects to a running Ouisync service's local control socket.

Includes the bindgen-generated data types, Request/Response tagged unions and Session/Repository/File API classes, plus the parts bindgen doesn't generate: connect/close, and the streaming endpoints (handled by hand in every other binding too).

 1"""Session API: connects to a running Ouisync service's local control socket.
 2
 3Includes the bindgen-generated data types, `Request`/`Response` tagged unions
 4and `Session`/`Repository`/`File` API classes, plus the parts bindgen doesn't
 5generate: connect/close, and the streaming endpoints (handled by hand in
 6every other binding too)."""
 7
 8import inspect
 9import typing
10
11from ._generated import api as _api
12from ._generated.api import *
13from .client import Client as _Client
14from .state_monitor import MonitorId
15
16
17async def connect(config_dir) -> Session:
18    client = await _Client.connect(config_dir)
19    return Session(client)
20
21
22async def close(session: Session):
23    await session._client.close()
24
25
26async def subscribe_to_network_events(session: Session) -> typing.AsyncIterator[NetworkEvent]:
27    async for response in session._client.subscribe(Request_SessionSubscribeToNetwork()):
28        if isinstance(response, Response_NetworkEvent):
29            yield response.value
30        elif isinstance(response, Response_Unit):
31            yield NetworkEvent.PEER_SET_CHANGE
32
33# Re-export everything from the generated api module.
34_all = []
35
36for name, member in inspect.getmembers(_api):
37    if not inspect.isclass(member):
38        continue
39
40    # Don't re-export private clases
41    if name.startswith('_'):
42        continue
43
44    # Don't re-export "handle" classes as they are used only internally by the API classes (which
45    # are re-exported).
46    if name.endswith('Handle'):
47        continue
48
49    _all.append(name)
50
51# Re-export handwritten classes
52_all.append('MonitorId')
53
54__all__ = _all
class AccessChange:
122class AccessChange:
123    """How to change access to a repository."""
124    _variants: ClassVar[dict[str, type]] = {}

How to change access to a repository.

@dataclass
class AccessChange_Disable(ouisync.session.AccessChange):
133@dataclass
134class AccessChange_Disable(AccessChange):
135    """Disable access"""
136    _tag: ClassVar[str] = "Disable"
137    _shape: ClassVar[str] = "unit"

Disable access

@dataclass
class AccessChange_Enable(ouisync.session.AccessChange):
126@dataclass
127class AccessChange_Enable(AccessChange):
128    """Enable read or write access, optionally with local secret"""
129    _tag: ClassVar[str] = "Enable"
130    _shape: ClassVar[str] = "unnamed"
131    value: SetLocalSecret | None

Enable read or write access, optionally with local secret

AccessChange_Enable(value: SetLocalSecret | None)
value: SetLocalSecret | None
class AccessMode(ouisync.session.IntEnum):
54class AccessMode(IntEnum):
55    """Access mode of a repository."""
56    BLIND = 0
57    """Repository is neither readable not writtable (but can still be synced)."""
58    READ = 1
59    """Repository is readable but not writtable."""
60    WRITE = 2
61    """Repository is both readable and writable."""

Access mode of a repository.

BLIND = <AccessMode.BLIND: 0>

Repository is neither readable not writtable (but can still be synced).

READ = <AccessMode.READ: 1>

Repository is readable but not writtable.

WRITE = <AccessMode.WRITE: 2>

Repository is both readable and writable.

@dataclass
class Datagram:
566@dataclass
567class Datagram:
568    _shape: ClassVar[str] = "named"
569    data: bytes
570    addr: str
Datagram(data: bytes, addr: str)
data: bytes
addr: str
@dataclass
class DirectoryEntry:
553@dataclass
554class DirectoryEntry:
555    _shape: ClassVar[str] = "named"
556    name: str
557    entry_type: EntryType
558    version_hash: bytes
DirectoryEntry( name: str, entry_type: EntryType, version_hash: bytes)
name: str
entry_type: EntryType
version_hash: bytes
class EntryType(ouisync.session.IntEnum):
144class EntryType(IntEnum):
145    """Type of filesystem entry."""
146    FILE = 1
147    DIRECTORY = 2

Type of filesystem entry.

FILE = <EntryType.FILE: 1>
DIRECTORY = <EntryType.DIRECTORY: 2>
class ErrorCode(ouisync.session.IntEnum):
263class ErrorCode(IntEnum):
264    OK = 0
265    """No error"""
266    PERMISSION_DENIED = 1
267    """Insuficient permission to perform the intended operation"""
268    INVALID_INPUT = 2
269    """Invalid input parameter"""
270    INVALID_DATA = 3
271    """Invalid data (e.g., malformed incoming message, config file, etc...)"""
272    ALREADY_EXISTS = 4
273    """Entry already exists"""
274    NOT_FOUND = 5
275    """Entry not found"""
276    AMBIGUOUS = 6
277    """Multiple matching entries found"""
278    UNSUPPORTED = 8
279    """The indended operation is not supported"""
280    INTERRUPTED = 9
281    """The operation was interrupted"""
282    CONNECTION_REFUSED = 1025
283    """Failed to establish connection to the server"""
284    CONNECTION_ABORTED = 1026
285    """Connection aborted by the server"""
286    TRANSPORT_ERROR = 1027
287    """Failed to send or receive message"""
288    LISTENER_BIND_ERROR = 1028
289    """Listener failed to bind to the specified address"""
290    LISTENER_ACCEPT_ERROR = 1029
291    """Listener failed to accept client connection"""
292    STORE_ERROR = 2049
293    """Operation on the internal repository store failed"""
294    IS_DIRECTORY = 2050
295    """Entry was expected to not be a directory but it is"""
296    NOT_DIRECTORY = 2051
297    """Entry was expected to be a directory but it isn't"""
298    DIRECTORY_NOT_EMPTY = 2052
299    """Directory was expected to be empty but it isn't"""
300    RESOURCE_BUSY = 2053
301    """File or directory is busy"""
302    SNAPSHOT_NOT_FOUND = 2054
303    """Snapshot no longer exists (e.g., because it has been replaced by a newer one)"""
304    RUNTIME_INITIALIZE_ERROR = 4097
305    """Failed to initialize runtime"""
306    CONFIG_ERROR = 4099
307    """Failed to read from or write into the config file"""
308    TLS_CERTIFICATES_NOT_FOUND = 4100
309    """TLS certificated not found"""
310    TLS_CERTIFICATES_INVALID = 4101
311    """TLS certificates failed to load"""
312    TLS_KEYS_NOT_FOUND = 4102
313    """TLS keys not found"""
314    TLS_CONFIG_ERROR = 4103
315    """Failed to create TLS config"""
316    VFS_DRIVER_INSTALL_ERROR = 4104
317    """Failed to install virtual filesystem driver"""
318    VFS_OTHER_ERROR = 4105
319    """Unspecified virtual filesystem error"""
320    SERVICE_ALREADY_RUNNING = 4106
321    """Another instance of the service is already running"""
322    STORE_DIR_UNSPECIFIED = 4107
323    """Store directory is not specified"""
324    MOUNT_DIR_UNSPECIFIED = 4108
325    """Mount directory is not specified"""
326    OTHER = 65535
327    """Unspecified error"""
OK = <ErrorCode.OK: 0>

No error

PERMISSION_DENIED = <ErrorCode.PERMISSION_DENIED: 1>

Insuficient permission to perform the intended operation

INVALID_INPUT = <ErrorCode.INVALID_INPUT: 2>

Invalid input parameter

INVALID_DATA = <ErrorCode.INVALID_DATA: 3>

Invalid data (e.g., malformed incoming message, config file, etc...)

ALREADY_EXISTS = <ErrorCode.ALREADY_EXISTS: 4>

Entry already exists

NOT_FOUND = <ErrorCode.NOT_FOUND: 5>

Entry not found

AMBIGUOUS = <ErrorCode.AMBIGUOUS: 6>

Multiple matching entries found

UNSUPPORTED = <ErrorCode.UNSUPPORTED: 8>

The indended operation is not supported

INTERRUPTED = <ErrorCode.INTERRUPTED: 9>

The operation was interrupted

CONNECTION_REFUSED = <ErrorCode.CONNECTION_REFUSED: 1025>

Failed to establish connection to the server

CONNECTION_ABORTED = <ErrorCode.CONNECTION_ABORTED: 1026>

Connection aborted by the server

TRANSPORT_ERROR = <ErrorCode.TRANSPORT_ERROR: 1027>

Failed to send or receive message

LISTENER_BIND_ERROR = <ErrorCode.LISTENER_BIND_ERROR: 1028>

Listener failed to bind to the specified address

LISTENER_ACCEPT_ERROR = <ErrorCode.LISTENER_ACCEPT_ERROR: 1029>

Listener failed to accept client connection

STORE_ERROR = <ErrorCode.STORE_ERROR: 2049>

Operation on the internal repository store failed

IS_DIRECTORY = <ErrorCode.IS_DIRECTORY: 2050>

Entry was expected to not be a directory but it is

NOT_DIRECTORY = <ErrorCode.NOT_DIRECTORY: 2051>

Entry was expected to be a directory but it isn't

DIRECTORY_NOT_EMPTY = <ErrorCode.DIRECTORY_NOT_EMPTY: 2052>

Directory was expected to be empty but it isn't

RESOURCE_BUSY = <ErrorCode.RESOURCE_BUSY: 2053>

File or directory is busy

SNAPSHOT_NOT_FOUND = <ErrorCode.SNAPSHOT_NOT_FOUND: 2054>

Snapshot no longer exists (e.g., because it has been replaced by a newer one)

RUNTIME_INITIALIZE_ERROR = <ErrorCode.RUNTIME_INITIALIZE_ERROR: 4097>

Failed to initialize runtime

CONFIG_ERROR = <ErrorCode.CONFIG_ERROR: 4099>

Failed to read from or write into the config file

TLS_CERTIFICATES_NOT_FOUND = <ErrorCode.TLS_CERTIFICATES_NOT_FOUND: 4100>

TLS certificated not found

TLS_CERTIFICATES_INVALID = <ErrorCode.TLS_CERTIFICATES_INVALID: 4101>

TLS certificates failed to load

TLS_KEYS_NOT_FOUND = <ErrorCode.TLS_KEYS_NOT_FOUND: 4102>

TLS keys not found

TLS_CONFIG_ERROR = <ErrorCode.TLS_CONFIG_ERROR: 4103>

Failed to create TLS config

VFS_DRIVER_INSTALL_ERROR = <ErrorCode.VFS_DRIVER_INSTALL_ERROR: 4104>

Failed to install virtual filesystem driver

VFS_OTHER_ERROR = <ErrorCode.VFS_OTHER_ERROR: 4105>

Unspecified virtual filesystem error

SERVICE_ALREADY_RUNNING = <ErrorCode.SERVICE_ALREADY_RUNNING: 4106>

Another instance of the service is already running

STORE_DIR_UNSPECIFIED = <ErrorCode.STORE_DIR_UNSPECIFIED: 4107>

Store directory is not specified

MOUNT_DIR_UNSPECIFIED = <ErrorCode.MOUNT_DIR_UNSPECIFIED: 4108>

Mount directory is not specified

OTHER = <ErrorCode.OTHER: 65535>

Unspecified error

class File:
3425class File:
3426    def __init__(self, client: Client, handle: FileHandle):
3427        """@private"""
3428        self._client = client
3429        self._handle = handle
3430
3431    async def close(
3432        self,
3433    ):
3434        """Closes the file."""
3435        request = Request_FileClose(
3436            self._handle,
3437        )
3438        response = await self._client.invoke(request)
3439        if isinstance(response, Response_Unit):
3440            return
3441        raise UnexpectedResponse()
3442
3443    async def flush(
3444        self,
3445    ):
3446        """Flushes any pending writes to the file."""
3447        request = Request_FileFlush(
3448            self._handle,
3449        )
3450        response = await self._client.invoke(request)
3451        if isinstance(response, Response_Unit):
3452            return
3453        raise UnexpectedResponse()
3454
3455    async def get_length(
3456        self,
3457    ) -> int:
3458        """Returns the length of the file in bytes"""
3459        request = Request_FileGetLength(
3460            self._handle,
3461        )
3462        response = await self._client.invoke(request)
3463        if isinstance(response, Response_U64):
3464            return response.value
3465        raise UnexpectedResponse()
3466
3467    async def get_progress(
3468        self,
3469    ) -> int:
3470        """
3471        Returns the sync progress of this file, that is, the total byte size of all the blocks of
3472        this file that's already been downloaded.
3473
3474        Note that Ouisync downloads the blocks in random order, so until the file's been completely
3475        downloaded, the already downloaded blocks are not guaranteed to continuous (there might be
3476        gaps).
3477        """
3478        request = Request_FileGetProgress(
3479            self._handle,
3480        )
3481        response = await self._client.invoke(request)
3482        if isinstance(response, Response_U64):
3483            return response.value
3484        raise UnexpectedResponse()
3485
3486    async def read(
3487        self,
3488        *,
3489        offset: int,
3490        size: int,
3491    ) -> bytes:
3492        """Reads `size` bytes from the file starting at `offset` bytes from the beginning of the file."""
3493        request = Request_FileRead(
3494            self._handle,
3495            offset,
3496            size,
3497        )
3498        response = await self._client.invoke(request)
3499        if isinstance(response, Response_Bytes):
3500            return response.value
3501        raise UnexpectedResponse()
3502
3503    async def truncate(
3504        self,
3505        *,
3506        len: int,
3507    ):
3508        """Truncates the file to the given length."""
3509        request = Request_FileTruncate(
3510            self._handle,
3511            len,
3512        )
3513        response = await self._client.invoke(request)
3514        if isinstance(response, Response_Unit):
3515            return
3516        raise UnexpectedResponse()
3517
3518    async def write(
3519        self,
3520        *,
3521        offset: int,
3522        data: bytes,
3523    ):
3524        """Writes the data to the file at the given offset."""
3525        request = Request_FileWrite(
3526            self._handle,
3527            offset,
3528            data,
3529        )
3530        response = await self._client.invoke(request)
3531        if isinstance(response, Response_Unit):
3532            return
3533        raise UnexpectedResponse()
async def close(self):
3431    async def close(
3432        self,
3433    ):
3434        """Closes the file."""
3435        request = Request_FileClose(
3436            self._handle,
3437        )
3438        response = await self._client.invoke(request)
3439        if isinstance(response, Response_Unit):
3440            return
3441        raise UnexpectedResponse()

Closes the file.

async def flush(self):
3443    async def flush(
3444        self,
3445    ):
3446        """Flushes any pending writes to the file."""
3447        request = Request_FileFlush(
3448            self._handle,
3449        )
3450        response = await self._client.invoke(request)
3451        if isinstance(response, Response_Unit):
3452            return
3453        raise UnexpectedResponse()

Flushes any pending writes to the file.

async def get_length(self) -> int:
3455    async def get_length(
3456        self,
3457    ) -> int:
3458        """Returns the length of the file in bytes"""
3459        request = Request_FileGetLength(
3460            self._handle,
3461        )
3462        response = await self._client.invoke(request)
3463        if isinstance(response, Response_U64):
3464            return response.value
3465        raise UnexpectedResponse()

Returns the length of the file in bytes

async def get_progress(self) -> int:
3467    async def get_progress(
3468        self,
3469    ) -> int:
3470        """
3471        Returns the sync progress of this file, that is, the total byte size of all the blocks of
3472        this file that's already been downloaded.
3473
3474        Note that Ouisync downloads the blocks in random order, so until the file's been completely
3475        downloaded, the already downloaded blocks are not guaranteed to continuous (there might be
3476        gaps).
3477        """
3478        request = Request_FileGetProgress(
3479            self._handle,
3480        )
3481        response = await self._client.invoke(request)
3482        if isinstance(response, Response_U64):
3483            return response.value
3484        raise UnexpectedResponse()

Returns the sync progress of this file, that is, the total byte size of all the blocks of this file that's already been downloaded.

Note that Ouisync downloads the blocks in random order, so until the file's been completely downloaded, the already downloaded blocks are not guaranteed to continuous (there might be gaps).

async def read(self, *, offset: int, size: int) -> bytes:
3486    async def read(
3487        self,
3488        *,
3489        offset: int,
3490        size: int,
3491    ) -> bytes:
3492        """Reads `size` bytes from the file starting at `offset` bytes from the beginning of the file."""
3493        request = Request_FileRead(
3494            self._handle,
3495            offset,
3496            size,
3497        )
3498        response = await self._client.invoke(request)
3499        if isinstance(response, Response_Bytes):
3500            return response.value
3501        raise UnexpectedResponse()

Reads size bytes from the file starting at offset bytes from the beginning of the file.

async def truncate(self, *, len: int):
3503    async def truncate(
3504        self,
3505        *,
3506        len: int,
3507    ):
3508        """Truncates the file to the given length."""
3509        request = Request_FileTruncate(
3510            self._handle,
3511            len,
3512        )
3513        response = await self._client.invoke(request)
3514        if isinstance(response, Response_Unit):
3515            return
3516        raise UnexpectedResponse()

Truncates the file to the given length.

async def write(self, *, offset: int, data: bytes):
3518    async def write(
3519        self,
3520        *,
3521        offset: int,
3522        data: bytes,
3523    ):
3524        """Writes the data to the file at the given offset."""
3525        request = Request_FileWrite(
3526            self._handle,
3527            offset,
3528            data,
3529        )
3530        response = await self._client.invoke(request)
3531        if isinstance(response, Response_Unit):
3532            return
3533        raise UnexpectedResponse()

Writes the data to the file at the given offset.

class IntEnum(builtins.int, enum.ReprEnum):
1270class IntEnum(int, ReprEnum):
1271    """
1272    Enum where members are also (and must be) ints
1273    """
@dataclass
class JointSnapshot:
234@dataclass
235class JointSnapshot:
236    """
237    Identifies a set of snapshots, one per branch, to read a repository from. Reading at a joint
238    snapshot (see [Repository::open_directory_at](crate::Repository::open_directory_at)) gives a
239    consistent view of the repository even when it's changing in the meantime, and never falls
240    back to older snapshots when some blocks are missing: such reads fail instead.
241
242    It's an opaque token. Equal tokens identify the same snapshots.
243    """
244    _shape: ClassVar[str] = "unnamed"
245    value: bytes

Identifies a set of snapshots, one per branch, to read a repository from. Reading at a joint snapshot (see Repository::open_directory_at) gives a consistent view of the repository even when it's changing in the meantime, and never falls back to older snapshots when some blocks are missing: such reads fail instead.

It's an opaque token. Equal tokens identify the same snapshots.

JointSnapshot(value: bytes)
value: bytes
class LocalSecret:
63class LocalSecret:
64    """Type of secret to unlock a repository."""
65    _variants: ClassVar[dict[str, type]] = {}

Type of secret to unlock a repository.

@dataclass
class LocalSecret_Password(ouisync.session.LocalSecret):
67@dataclass
68class LocalSecret_Password(LocalSecret):
69    """Password provided by the user"""
70    _tag: ClassVar[str] = "Password"
71    _shape: ClassVar[str] = "unnamed"
72    value: Password

Password provided by the user

LocalSecret_Password(value: Password)
value: Password
@dataclass
class LocalSecret_SecretKey(ouisync.session.LocalSecret):
74@dataclass
75class LocalSecret_SecretKey(LocalSecret):
76    """Secret key generated by secure means (e.g., crypto-secure RNG, KDF, ...)"""
77    _tag: ClassVar[str] = "SecretKey"
78    _shape: ClassVar[str] = "unnamed"
79    value: SecretKey

Secret key generated by secure means (e.g., crypto-secure RNG, KDF, ...)

LocalSecret_SecretKey(value: SecretKey)
value: SecretKey
class LogLevel(ouisync.session.IntEnum):
525class LogLevel(IntEnum):
526    ERROR = 1
527    WARN = 2
528    INFO = 3
529    DEBUG = 4
530    TRACE = 5
ERROR = <LogLevel.ERROR: 1>
WARN = <LogLevel.WARN: 2>
INFO = <LogLevel.INFO: 3>
DEBUG = <LogLevel.DEBUG: 4>
TRACE = <LogLevel.TRACE: 5>
@dataclass
class MessageId:
532@dataclass
533class MessageId:
534    _shape: ClassVar[str] = "unnamed"
535    value: int
MessageId(value: int)
value: int
@dataclass
class MetadataEdit:
537@dataclass
538class MetadataEdit:
539    """Edit of a single metadata entry."""
540    _shape: ClassVar[str] = "named"
541    key: str
542    old_value: str | None
543    new_value: str | None

Edit of a single metadata entry.

MetadataEdit(key: str, old_value: str | None, new_value: str | None)
key: str
old_value: str | None
new_value: str | None
class NatBehavior(ouisync.session.IntEnum):
258class NatBehavior(IntEnum):
259    ENDPOINT_INDEPENDENT = 0
260    ADDRESS_DEPENDENT = 1
261    ADDRESS_AND_PORT_DEPENDENT = 2
ENDPOINT_INDEPENDENT = <NatBehavior.ENDPOINT_INDEPENDENT: 0>
ADDRESS_DEPENDENT = <NatBehavior.ADDRESS_DEPENDENT: 1>
ADDRESS_AND_PORT_DEPENDENT = <NatBehavior.ADDRESS_AND_PORT_DEPENDENT: 2>
@dataclass
class NetworkDefaults:
545@dataclass
546class NetworkDefaults:
547    """Default network parameters"""
548    _shape: ClassVar[str] = "named"
549    bind: list[str]
550    port_forwarding_enabled: bool
551    local_discovery_enabled: bool

Default network parameters

NetworkDefaults( bind: list[str], port_forwarding_enabled: bool, local_discovery_enabled: bool)
bind: list[str]
port_forwarding_enabled: bool
local_discovery_enabled: bool
class NetworkEvent(ouisync.session.IntEnum):
149class NetworkEvent(IntEnum):
150    """Network notification event."""
151    PROTOCOL_VERSION_MISMATCH = 0
152    """
153    A peer has appeared with higher protocol version than us. Probably means we are using
154    outdated library. This event can be used to notify the user that they should update the app.
155    """
156    PEER_SET_CHANGE = 1
157    """The set of known peers has changed (e.g., a new peer has been discovered)"""

Network notification event.

PROTOCOL_VERSION_MISMATCH = <NetworkEvent.PROTOCOL_VERSION_MISMATCH: 0>

A peer has appeared with higher protocol version than us. Probably means we are using outdated library. This event can be used to notify the user that they should update the app.

PEER_SET_CHANGE = <NetworkEvent.PEER_SET_CHANGE: 1>

The set of known peers has changed (e.g., a new peer has been discovered)

class NetworkSocket:
3536class NetworkSocket:
3537    def __init__(self, client: Client, handle: NetworkSocketHandle):
3538        """@private"""
3539        self._client = client
3540        self._handle = handle
3541
3542    async def close(
3543        self,
3544    ):
3545        request = Request_NetworkSocketClose(
3546            self._handle,
3547        )
3548        response = await self._client.invoke(request)
3549        if isinstance(response, Response_Unit):
3550            return
3551        raise UnexpectedResponse()
3552
3553    async def recv_from(
3554        self,
3555        *,
3556        len: int,
3557    ) -> Datagram:
3558        request = Request_NetworkSocketRecvFrom(
3559            self._handle,
3560            len,
3561        )
3562        response = await self._client.invoke(request)
3563        if isinstance(response, Response_Datagram):
3564            return response.value
3565        raise UnexpectedResponse()
3566
3567    async def send_to(
3568        self,
3569        *,
3570        data: bytes,
3571        addr: str,
3572    ) -> int:
3573        request = Request_NetworkSocketSendTo(
3574            self._handle,
3575            data,
3576            addr,
3577        )
3578        response = await self._client.invoke(request)
3579        if isinstance(response, Response_U64):
3580            return response.value
3581        raise UnexpectedResponse()
async def close(self):
3542    async def close(
3543        self,
3544    ):
3545        request = Request_NetworkSocketClose(
3546            self._handle,
3547        )
3548        response = await self._client.invoke(request)
3549        if isinstance(response, Response_Unit):
3550            return
3551        raise UnexpectedResponse()
async def recv_from(self, *, len: int) -> Datagram:
3553    async def recv_from(
3554        self,
3555        *,
3556        len: int,
3557    ) -> Datagram:
3558        request = Request_NetworkSocketRecvFrom(
3559            self._handle,
3560            len,
3561        )
3562        response = await self._client.invoke(request)
3563        if isinstance(response, Response_Datagram):
3564            return response.value
3565        raise UnexpectedResponse()
async def send_to(self, *, data: bytes, addr: str) -> int:
3567    async def send_to(
3568        self,
3569        *,
3570        data: bytes,
3571        addr: str,
3572    ) -> int:
3573        request = Request_NetworkSocketSendTo(
3574            self._handle,
3575            data,
3576            addr,
3577        )
3578        response = await self._client.invoke(request)
3579        if isinstance(response, Response_U64):
3580            return response.value
3581        raise UnexpectedResponse()
class NetworkStream:
3584class NetworkStream:
3585    def __init__(self, client: Client, handle: NetworkStreamHandle):
3586        """@private"""
3587        self._client = client
3588        self._handle = handle
3589
3590    async def close(
3591        self,
3592    ):
3593        """Gracefully closes the given raw byte stream."""
3594        request = Request_NetworkStreamClose(
3595            self._handle,
3596        )
3597        response = await self._client.invoke(request)
3598        if isinstance(response, Response_Unit):
3599            return
3600        raise UnexpectedResponse()
3601
3602    async def read_exact(
3603        self,
3604        *,
3605        len: int,
3606    ) -> bytes:
3607        """Reads exactly the given number of bytes from the given raw byte stream."""
3608        request = Request_NetworkStreamReadExact(
3609            self._handle,
3610            len,
3611        )
3612        response = await self._client.invoke(request)
3613        if isinstance(response, Response_Bytes):
3614            return response.value
3615        raise UnexpectedResponse()
3616
3617    async def write_all(
3618        self,
3619        *,
3620        buf: bytes,
3621    ):
3622        """Writes the whole buffer to the given raw byte stream."""
3623        request = Request_NetworkStreamWriteAll(
3624            self._handle,
3625            buf,
3626        )
3627        response = await self._client.invoke(request)
3628        if isinstance(response, Response_Unit):
3629            return
3630        raise UnexpectedResponse()
async def close(self):
3590    async def close(
3591        self,
3592    ):
3593        """Gracefully closes the given raw byte stream."""
3594        request = Request_NetworkStreamClose(
3595            self._handle,
3596        )
3597        response = await self._client.invoke(request)
3598        if isinstance(response, Response_Unit):
3599            return
3600        raise UnexpectedResponse()

Gracefully closes the given raw byte stream.

async def read_exact(self, *, len: int) -> bytes:
3602    async def read_exact(
3603        self,
3604        *,
3605        len: int,
3606    ) -> bytes:
3607        """Reads exactly the given number of bytes from the given raw byte stream."""
3608        request = Request_NetworkStreamReadExact(
3609            self._handle,
3610            len,
3611        )
3612        response = await self._client.invoke(request)
3613        if isinstance(response, Response_Bytes):
3614            return response.value
3615        raise UnexpectedResponse()

Reads exactly the given number of bytes from the given raw byte stream.

async def write_all(self, *, buf: bytes):
3617    async def write_all(
3618        self,
3619        *,
3620        buf: bytes,
3621    ):
3622        """Writes the whole buffer to the given raw byte stream."""
3623        request = Request_NetworkStreamWriteAll(
3624            self._handle,
3625            buf,
3626        )
3627        response = await self._client.invoke(request)
3628        if isinstance(response, Response_Unit):
3629            return
3630        raise UnexpectedResponse()

Writes the whole buffer to the given raw byte stream.

class OuisyncError(builtins.Exception):
329class OuisyncError(Exception):
330    def __init__(self, code: ErrorCode, message: str | None = None, sources: list[str] | None = None):
331        self.code = code
332        self.message = message
333        self.sources = sources or []
334        super().__init__(message or str(code))

Common base class for all non-exit exceptions.

OuisyncError( code: ErrorCode, message: str | None = None, sources: list[str] | None = None)
330    def __init__(self, code: ErrorCode, message: str | None = None, sources: list[str] | None = None):
331        self.code = code
332        self.message = message
333        self.sources = sources or []
334        super().__init__(message or str(code))
code
message
sources
class OuisyncError_AlreadyExists(ouisync.session.OuisyncError):
351class OuisyncError_AlreadyExists(OuisyncError):
352    """Entry already exists"""
353    def __init__(self, message: str | None = None, sources: list[str] | None = None):
354        super().__init__(ErrorCode.ALREADY_EXISTS, message, sources)

Entry already exists

OuisyncError_AlreadyExists(message: str | None = None, sources: list[str] | None = None)
353    def __init__(self, message: str | None = None, sources: list[str] | None = None):
354        super().__init__(ErrorCode.ALREADY_EXISTS, message, sources)
class OuisyncError_Ambiguous(ouisync.session.OuisyncError):
361class OuisyncError_Ambiguous(OuisyncError):
362    """Multiple matching entries found"""
363    def __init__(self, message: str | None = None, sources: list[str] | None = None):
364        super().__init__(ErrorCode.AMBIGUOUS, message, sources)

Multiple matching entries found

OuisyncError_Ambiguous(message: str | None = None, sources: list[str] | None = None)
363    def __init__(self, message: str | None = None, sources: list[str] | None = None):
364        super().__init__(ErrorCode.AMBIGUOUS, message, sources)
class OuisyncError_ConfigError(ouisync.session.OuisyncError):
436class OuisyncError_ConfigError(OuisyncError):
437    """Failed to read from or write into the config file"""
438    def __init__(self, message: str | None = None, sources: list[str] | None = None):
439        super().__init__(ErrorCode.CONFIG_ERROR, message, sources)

Failed to read from or write into the config file

OuisyncError_ConfigError(message: str | None = None, sources: list[str] | None = None)
438    def __init__(self, message: str | None = None, sources: list[str] | None = None):
439        super().__init__(ErrorCode.CONFIG_ERROR, message, sources)
class OuisyncError_ConnectionAborted(ouisync.session.OuisyncError):
381class OuisyncError_ConnectionAborted(OuisyncError):
382    """Connection aborted by the server"""
383    def __init__(self, message: str | None = None, sources: list[str] | None = None):
384        super().__init__(ErrorCode.CONNECTION_ABORTED, message, sources)

Connection aborted by the server

OuisyncError_ConnectionAborted(message: str | None = None, sources: list[str] | None = None)
383    def __init__(self, message: str | None = None, sources: list[str] | None = None):
384        super().__init__(ErrorCode.CONNECTION_ABORTED, message, sources)
class OuisyncError_ConnectionRefused(ouisync.session.OuisyncError):
376class OuisyncError_ConnectionRefused(OuisyncError):
377    """Failed to establish connection to the server"""
378    def __init__(self, message: str | None = None, sources: list[str] | None = None):
379        super().__init__(ErrorCode.CONNECTION_REFUSED, message, sources)

Failed to establish connection to the server

OuisyncError_ConnectionRefused(message: str | None = None, sources: list[str] | None = None)
378    def __init__(self, message: str | None = None, sources: list[str] | None = None):
379        super().__init__(ErrorCode.CONNECTION_REFUSED, message, sources)
class OuisyncError_DirectoryNotEmpty(ouisync.session.OuisyncError):
416class OuisyncError_DirectoryNotEmpty(OuisyncError):
417    """Directory was expected to be empty but it isn't"""
418    def __init__(self, message: str | None = None, sources: list[str] | None = None):
419        super().__init__(ErrorCode.DIRECTORY_NOT_EMPTY, message, sources)

Directory was expected to be empty but it isn't

OuisyncError_DirectoryNotEmpty(message: str | None = None, sources: list[str] | None = None)
418    def __init__(self, message: str | None = None, sources: list[str] | None = None):
419        super().__init__(ErrorCode.DIRECTORY_NOT_EMPTY, message, sources)
class OuisyncError_Interrupted(ouisync.session.OuisyncError):
371class OuisyncError_Interrupted(OuisyncError):
372    """The operation was interrupted"""
373    def __init__(self, message: str | None = None, sources: list[str] | None = None):
374        super().__init__(ErrorCode.INTERRUPTED, message, sources)

The operation was interrupted

OuisyncError_Interrupted(message: str | None = None, sources: list[str] | None = None)
373    def __init__(self, message: str | None = None, sources: list[str] | None = None):
374        super().__init__(ErrorCode.INTERRUPTED, message, sources)
class OuisyncError_InvalidData(ouisync.session.OuisyncError):
346class OuisyncError_InvalidData(OuisyncError):
347    """Invalid data (e.g., malformed incoming message, config file, etc...)"""
348    def __init__(self, message: str | None = None, sources: list[str] | None = None):
349        super().__init__(ErrorCode.INVALID_DATA, message, sources)

Invalid data (e.g., malformed incoming message, config file, etc...)

OuisyncError_InvalidData(message: str | None = None, sources: list[str] | None = None)
348    def __init__(self, message: str | None = None, sources: list[str] | None = None):
349        super().__init__(ErrorCode.INVALID_DATA, message, sources)
class OuisyncError_InvalidInput(ouisync.session.OuisyncError):
341class OuisyncError_InvalidInput(OuisyncError):
342    """Invalid input parameter"""
343    def __init__(self, message: str | None = None, sources: list[str] | None = None):
344        super().__init__(ErrorCode.INVALID_INPUT, message, sources)

Invalid input parameter

OuisyncError_InvalidInput(message: str | None = None, sources: list[str] | None = None)
343    def __init__(self, message: str | None = None, sources: list[str] | None = None):
344        super().__init__(ErrorCode.INVALID_INPUT, message, sources)
class OuisyncError_IsDirectory(ouisync.session.OuisyncError):
406class OuisyncError_IsDirectory(OuisyncError):
407    """Entry was expected to not be a directory but it is"""
408    def __init__(self, message: str | None = None, sources: list[str] | None = None):
409        super().__init__(ErrorCode.IS_DIRECTORY, message, sources)

Entry was expected to not be a directory but it is

OuisyncError_IsDirectory(message: str | None = None, sources: list[str] | None = None)
408    def __init__(self, message: str | None = None, sources: list[str] | None = None):
409        super().__init__(ErrorCode.IS_DIRECTORY, message, sources)
class OuisyncError_ListenerAcceptError(ouisync.session.OuisyncError):
396class OuisyncError_ListenerAcceptError(OuisyncError):
397    """Listener failed to accept client connection"""
398    def __init__(self, message: str | None = None, sources: list[str] | None = None):
399        super().__init__(ErrorCode.LISTENER_ACCEPT_ERROR, message, sources)

Listener failed to accept client connection

OuisyncError_ListenerAcceptError(message: str | None = None, sources: list[str] | None = None)
398    def __init__(self, message: str | None = None, sources: list[str] | None = None):
399        super().__init__(ErrorCode.LISTENER_ACCEPT_ERROR, message, sources)
class OuisyncError_ListenerBindError(ouisync.session.OuisyncError):
391class OuisyncError_ListenerBindError(OuisyncError):
392    """Listener failed to bind to the specified address"""
393    def __init__(self, message: str | None = None, sources: list[str] | None = None):
394        super().__init__(ErrorCode.LISTENER_BIND_ERROR, message, sources)

Listener failed to bind to the specified address

OuisyncError_ListenerBindError(message: str | None = None, sources: list[str] | None = None)
393    def __init__(self, message: str | None = None, sources: list[str] | None = None):
394        super().__init__(ErrorCode.LISTENER_BIND_ERROR, message, sources)
class OuisyncError_MountDirUnspecified(ouisync.session.OuisyncError):
481class OuisyncError_MountDirUnspecified(OuisyncError):
482    """Mount directory is not specified"""
483    def __init__(self, message: str | None = None, sources: list[str] | None = None):
484        super().__init__(ErrorCode.MOUNT_DIR_UNSPECIFIED, message, sources)

Mount directory is not specified

OuisyncError_MountDirUnspecified(message: str | None = None, sources: list[str] | None = None)
483    def __init__(self, message: str | None = None, sources: list[str] | None = None):
484        super().__init__(ErrorCode.MOUNT_DIR_UNSPECIFIED, message, sources)
class OuisyncError_NotDirectory(ouisync.session.OuisyncError):
411class OuisyncError_NotDirectory(OuisyncError):
412    """Entry was expected to be a directory but it isn't"""
413    def __init__(self, message: str | None = None, sources: list[str] | None = None):
414        super().__init__(ErrorCode.NOT_DIRECTORY, message, sources)

Entry was expected to be a directory but it isn't

OuisyncError_NotDirectory(message: str | None = None, sources: list[str] | None = None)
413    def __init__(self, message: str | None = None, sources: list[str] | None = None):
414        super().__init__(ErrorCode.NOT_DIRECTORY, message, sources)
class OuisyncError_NotFound(ouisync.session.OuisyncError):
356class OuisyncError_NotFound(OuisyncError):
357    """Entry not found"""
358    def __init__(self, message: str | None = None, sources: list[str] | None = None):
359        super().__init__(ErrorCode.NOT_FOUND, message, sources)

Entry not found

OuisyncError_NotFound(message: str | None = None, sources: list[str] | None = None)
358    def __init__(self, message: str | None = None, sources: list[str] | None = None):
359        super().__init__(ErrorCode.NOT_FOUND, message, sources)
class OuisyncError_PermissionDenied(ouisync.session.OuisyncError):
336class OuisyncError_PermissionDenied(OuisyncError):
337    """Insuficient permission to perform the intended operation"""
338    def __init__(self, message: str | None = None, sources: list[str] | None = None):
339        super().__init__(ErrorCode.PERMISSION_DENIED, message, sources)

Insuficient permission to perform the intended operation

OuisyncError_PermissionDenied(message: str | None = None, sources: list[str] | None = None)
338    def __init__(self, message: str | None = None, sources: list[str] | None = None):
339        super().__init__(ErrorCode.PERMISSION_DENIED, message, sources)
class OuisyncError_ResourceBusy(ouisync.session.OuisyncError):
421class OuisyncError_ResourceBusy(OuisyncError):
422    """File or directory is busy"""
423    def __init__(self, message: str | None = None, sources: list[str] | None = None):
424        super().__init__(ErrorCode.RESOURCE_BUSY, message, sources)

File or directory is busy

OuisyncError_ResourceBusy(message: str | None = None, sources: list[str] | None = None)
423    def __init__(self, message: str | None = None, sources: list[str] | None = None):
424        super().__init__(ErrorCode.RESOURCE_BUSY, message, sources)
class OuisyncError_RuntimeInitializeError(ouisync.session.OuisyncError):
431class OuisyncError_RuntimeInitializeError(OuisyncError):
432    """Failed to initialize runtime"""
433    def __init__(self, message: str | None = None, sources: list[str] | None = None):
434        super().__init__(ErrorCode.RUNTIME_INITIALIZE_ERROR, message, sources)

Failed to initialize runtime

OuisyncError_RuntimeInitializeError(message: str | None = None, sources: list[str] | None = None)
433    def __init__(self, message: str | None = None, sources: list[str] | None = None):
434        super().__init__(ErrorCode.RUNTIME_INITIALIZE_ERROR, message, sources)
class OuisyncError_ServiceAlreadyRunning(ouisync.session.OuisyncError):
471class OuisyncError_ServiceAlreadyRunning(OuisyncError):
472    """Another instance of the service is already running"""
473    def __init__(self, message: str | None = None, sources: list[str] | None = None):
474        super().__init__(ErrorCode.SERVICE_ALREADY_RUNNING, message, sources)

Another instance of the service is already running

OuisyncError_ServiceAlreadyRunning(message: str | None = None, sources: list[str] | None = None)
473    def __init__(self, message: str | None = None, sources: list[str] | None = None):
474        super().__init__(ErrorCode.SERVICE_ALREADY_RUNNING, message, sources)
class OuisyncError_SnapshotNotFound(ouisync.session.OuisyncError):
426class OuisyncError_SnapshotNotFound(OuisyncError):
427    """Snapshot no longer exists (e.g., because it has been replaced by a newer one)"""
428    def __init__(self, message: str | None = None, sources: list[str] | None = None):
429        super().__init__(ErrorCode.SNAPSHOT_NOT_FOUND, message, sources)

Snapshot no longer exists (e.g., because it has been replaced by a newer one)

OuisyncError_SnapshotNotFound(message: str | None = None, sources: list[str] | None = None)
428    def __init__(self, message: str | None = None, sources: list[str] | None = None):
429        super().__init__(ErrorCode.SNAPSHOT_NOT_FOUND, message, sources)
class OuisyncError_StoreDirUnspecified(ouisync.session.OuisyncError):
476class OuisyncError_StoreDirUnspecified(OuisyncError):
477    """Store directory is not specified"""
478    def __init__(self, message: str | None = None, sources: list[str] | None = None):
479        super().__init__(ErrorCode.STORE_DIR_UNSPECIFIED, message, sources)

Store directory is not specified

OuisyncError_StoreDirUnspecified(message: str | None = None, sources: list[str] | None = None)
478    def __init__(self, message: str | None = None, sources: list[str] | None = None):
479        super().__init__(ErrorCode.STORE_DIR_UNSPECIFIED, message, sources)
class OuisyncError_StoreError(ouisync.session.OuisyncError):
401class OuisyncError_StoreError(OuisyncError):
402    """Operation on the internal repository store failed"""
403    def __init__(self, message: str | None = None, sources: list[str] | None = None):
404        super().__init__(ErrorCode.STORE_ERROR, message, sources)

Operation on the internal repository store failed

OuisyncError_StoreError(message: str | None = None, sources: list[str] | None = None)
403    def __init__(self, message: str | None = None, sources: list[str] | None = None):
404        super().__init__(ErrorCode.STORE_ERROR, message, sources)
class OuisyncError_TlsCertificatesInvalid(ouisync.session.OuisyncError):
446class OuisyncError_TlsCertificatesInvalid(OuisyncError):
447    """TLS certificates failed to load"""
448    def __init__(self, message: str | None = None, sources: list[str] | None = None):
449        super().__init__(ErrorCode.TLS_CERTIFICATES_INVALID, message, sources)

TLS certificates failed to load

OuisyncError_TlsCertificatesInvalid(message: str | None = None, sources: list[str] | None = None)
448    def __init__(self, message: str | None = None, sources: list[str] | None = None):
449        super().__init__(ErrorCode.TLS_CERTIFICATES_INVALID, message, sources)
class OuisyncError_TlsCertificatesNotFound(ouisync.session.OuisyncError):
441class OuisyncError_TlsCertificatesNotFound(OuisyncError):
442    """TLS certificated not found"""
443    def __init__(self, message: str | None = None, sources: list[str] | None = None):
444        super().__init__(ErrorCode.TLS_CERTIFICATES_NOT_FOUND, message, sources)

TLS certificated not found

OuisyncError_TlsCertificatesNotFound(message: str | None = None, sources: list[str] | None = None)
443    def __init__(self, message: str | None = None, sources: list[str] | None = None):
444        super().__init__(ErrorCode.TLS_CERTIFICATES_NOT_FOUND, message, sources)
class OuisyncError_TlsConfigError(ouisync.session.OuisyncError):
456class OuisyncError_TlsConfigError(OuisyncError):
457    """Failed to create TLS config"""
458    def __init__(self, message: str | None = None, sources: list[str] | None = None):
459        super().__init__(ErrorCode.TLS_CONFIG_ERROR, message, sources)

Failed to create TLS config

OuisyncError_TlsConfigError(message: str | None = None, sources: list[str] | None = None)
458    def __init__(self, message: str | None = None, sources: list[str] | None = None):
459        super().__init__(ErrorCode.TLS_CONFIG_ERROR, message, sources)
class OuisyncError_TlsKeysNotFound(ouisync.session.OuisyncError):
451class OuisyncError_TlsKeysNotFound(OuisyncError):
452    """TLS keys not found"""
453    def __init__(self, message: str | None = None, sources: list[str] | None = None):
454        super().__init__(ErrorCode.TLS_KEYS_NOT_FOUND, message, sources)

TLS keys not found

OuisyncError_TlsKeysNotFound(message: str | None = None, sources: list[str] | None = None)
453    def __init__(self, message: str | None = None, sources: list[str] | None = None):
454        super().__init__(ErrorCode.TLS_KEYS_NOT_FOUND, message, sources)
class OuisyncError_TransportError(ouisync.session.OuisyncError):
386class OuisyncError_TransportError(OuisyncError):
387    """Failed to send or receive message"""
388    def __init__(self, message: str | None = None, sources: list[str] | None = None):
389        super().__init__(ErrorCode.TRANSPORT_ERROR, message, sources)

Failed to send or receive message

OuisyncError_TransportError(message: str | None = None, sources: list[str] | None = None)
388    def __init__(self, message: str | None = None, sources: list[str] | None = None):
389        super().__init__(ErrorCode.TRANSPORT_ERROR, message, sources)
class OuisyncError_Unsupported(ouisync.session.OuisyncError):
366class OuisyncError_Unsupported(OuisyncError):
367    """The indended operation is not supported"""
368    def __init__(self, message: str | None = None, sources: list[str] | None = None):
369        super().__init__(ErrorCode.UNSUPPORTED, message, sources)

The indended operation is not supported

OuisyncError_Unsupported(message: str | None = None, sources: list[str] | None = None)
368    def __init__(self, message: str | None = None, sources: list[str] | None = None):
369        super().__init__(ErrorCode.UNSUPPORTED, message, sources)
class OuisyncError_VfsDriverInstallError(ouisync.session.OuisyncError):
461class OuisyncError_VfsDriverInstallError(OuisyncError):
462    """Failed to install virtual filesystem driver"""
463    def __init__(self, message: str | None = None, sources: list[str] | None = None):
464        super().__init__(ErrorCode.VFS_DRIVER_INSTALL_ERROR, message, sources)

Failed to install virtual filesystem driver

OuisyncError_VfsDriverInstallError(message: str | None = None, sources: list[str] | None = None)
463    def __init__(self, message: str | None = None, sources: list[str] | None = None):
464        super().__init__(ErrorCode.VFS_DRIVER_INSTALL_ERROR, message, sources)
class OuisyncError_VfsOtherError(ouisync.session.OuisyncError):
466class OuisyncError_VfsOtherError(OuisyncError):
467    """Unspecified virtual filesystem error"""
468    def __init__(self, message: str | None = None, sources: list[str] | None = None):
469        super().__init__(ErrorCode.VFS_OTHER_ERROR, message, sources)

Unspecified virtual filesystem error

OuisyncError_VfsOtherError(message: str | None = None, sources: list[str] | None = None)
468    def __init__(self, message: str | None = None, sources: list[str] | None = None):
469        super().__init__(ErrorCode.VFS_OTHER_ERROR, message, sources)
@dataclass
class Password:
32@dataclass
33class Password:
34    """
35    A simple wrapper over String to avoid certain kinds of attack. For more elaboration please see
36    the documentation for the SecretKey structure.
37    """
38    _shape: ClassVar[str] = "unnamed"
39    value: str
40    def __repr__(self) -> str:
41        return f"{type(self).__name__}(******)"

A simple wrapper over String to avoid certain kinds of attack. For more elaboration please see the documentation for the SecretKey structure.

Password(value: str)
value: str
@dataclass
class PasswordSalt:
43@dataclass
44class PasswordSalt:
45    _shape: ClassVar[str] = "unnamed"
46    value: bytes
PasswordSalt(value: bytes)
value: bytes
@dataclass
class PeerInfo:
159@dataclass
160class PeerInfo:
161    """Information about a peer."""
162    _shape: ClassVar[str] = "named"
163    addr: str
164    source: PeerSource
165    state: PeerState
166    stats: Stats

Information about a peer.

PeerInfo( addr: str, source: PeerSource, state: PeerState, stats: Stats)
addr: str
source: PeerSource
state: PeerState
stats: Stats
class PeerSource(ouisync.session.IntEnum):
168class PeerSource(IntEnum):
169    """How was the peer discovered."""
170    USER_PROVIDED = 0
171    """Explicitly added by the user."""
172    LISTENER = 1
173    """Peer connected to us."""
174    LOCAL_DISCOVERY = 2
175    """Discovered on the Local Discovery."""
176    DHT = 3
177    """Discovered on the DHT."""
178    PEER_EXCHANGE = 4
179    """Discovered on the Peer Exchange."""

How was the peer discovered.

USER_PROVIDED = <PeerSource.USER_PROVIDED: 0>

Explicitly added by the user.

LISTENER = <PeerSource.LISTENER: 1>

Peer connected to us.

LOCAL_DISCOVERY = <PeerSource.LOCAL_DISCOVERY: 2>

Discovered on the Local Discovery.

DHT = <PeerSource.DHT: 3>

Discovered on the DHT.

PEER_EXCHANGE = <PeerSource.PEER_EXCHANGE: 4>

Discovered on the Peer Exchange.

class PeerState:
181class PeerState:
182    _variants: ClassVar[dict[str, type]] = {}
@dataclass
class PeerState_Active(ouisync.session.PeerState):
199@dataclass
200class PeerState_Active(PeerState):
201    _tag: ClassVar[str] = "Active"
202    _shape: ClassVar[str] = "named"
203    id: PublicRuntimeId
204    since: typing.Any
PeerState_Active(id: PublicRuntimeId, since: Any)
since: Any
@dataclass
class PeerState_Connecting(ouisync.session.PeerState):
189@dataclass
190class PeerState_Connecting(PeerState):
191    _tag: ClassVar[str] = "Connecting"
192    _shape: ClassVar[str] = "unit"
@dataclass
class PeerState_Handshaking(ouisync.session.PeerState):
194@dataclass
195class PeerState_Handshaking(PeerState):
196    _tag: ClassVar[str] = "Handshaking"
197    _shape: ClassVar[str] = "unit"
@dataclass
class PeerState_Known(ouisync.session.PeerState):
184@dataclass
185class PeerState_Known(PeerState):
186    _tag: ClassVar[str] = "Known"
187    _shape: ClassVar[str] = "unit"
@dataclass
class Progress:
227@dataclass
228class Progress:
229    """Progress of a task."""
230    _shape: ClassVar[str] = "named"
231    value: int
232    total: int

Progress of a task.

Progress(value: int, total: int)
value: int
total: int
@dataclass
class PublicRuntimeId:
213@dataclass
214class PublicRuntimeId:
215    _shape: ClassVar[str] = "unnamed"
216    value: bytes
PublicRuntimeId(value: bytes)
value: bytes
@dataclass
class QuotaInfo:
560@dataclass
561class QuotaInfo:
562    _shape: ClassVar[str] = "named"
563    quota: StorageSize | None
564    size: StorageSize
QuotaInfo( quota: StorageSize | None, size: StorageSize)
quota: StorageSize | None
size: StorageSize
class Repository:
2681class Repository:
2682    def __init__(self, client: Client, handle: RepositoryHandle):
2683        """@private"""
2684        self._client = client
2685        self._handle = handle
2686
2687    async def close(
2688        self,
2689    ):
2690        """Closes the repository."""
2691        request = Request_RepositoryClose(
2692            self._handle,
2693        )
2694        response = await self._client.invoke(request)
2695        if isinstance(response, Response_Unit):
2696            return
2697        raise UnexpectedResponse()
2698
2699    async def create_directory(
2700        self,
2701        *,
2702        path: str,
2703    ):
2704        """Creates a new directory at the given path in the repository."""
2705        request = Request_RepositoryCreateDirectory(
2706            self._handle,
2707            path,
2708        )
2709        response = await self._client.invoke(request)
2710        if isinstance(response, Response_Unit):
2711            return
2712        raise UnexpectedResponse()
2713
2714    async def create_file(
2715        self,
2716        *,
2717        path: str,
2718    ) -> File:
2719        """Creates a new file at the given path in the repository."""
2720        request = Request_RepositoryCreateFile(
2721            self._handle,
2722            path,
2723        )
2724        response = await self._client.invoke(request)
2725        if isinstance(response, Response_File):
2726            return File(self._client, response.value)
2727        raise UnexpectedResponse()
2728
2729    async def create_mirror(
2730        self,
2731        *,
2732        host: str,
2733    ):
2734        """
2735        Creates mirror of this repository on the given cache server host.
2736
2737        Cache servers relay traffic between Ouisync peers and also temporarily store data. They are
2738        useful when direct P2P connection fails (e.g. due to restrictive NAT) and also to allow
2739        syncing when the peers are not online at the same time (they still need to be online within
2740        ~24 hours of each other).
2741
2742        Requires the repository to be opened in write mode.
2743        """
2744        request = Request_RepositoryCreateMirror(
2745            self._handle,
2746            host,
2747        )
2748        response = await self._client.invoke(request)
2749        if isinstance(response, Response_Unit):
2750            return
2751        raise UnexpectedResponse()
2752
2753    async def delete(
2754        self,
2755    ):
2756        """Delete the repository"""
2757        request = Request_RepositoryDelete(
2758            self._handle,
2759        )
2760        response = await self._client.invoke(request)
2761        if isinstance(response, Response_Unit):
2762            return
2763        raise UnexpectedResponse()
2764
2765    async def delete_mirror(
2766        self,
2767        *,
2768        host: str,
2769    ):
2770        """
2771        Deletes mirror of this repository from the given cache server host.
2772
2773        Requires the repository to be opened in write mode.
2774        """
2775        request = Request_RepositoryDeleteMirror(
2776            self._handle,
2777            host,
2778        )
2779        response = await self._client.invoke(request)
2780        if isinstance(response, Response_Unit):
2781            return
2782        raise UnexpectedResponse()
2783
2784    async def export(
2785        self,
2786        *,
2787        output_path: str,
2788    ) -> str:
2789        """Export repository to file"""
2790        request = Request_RepositoryExport(
2791            self._handle,
2792            output_path,
2793        )
2794        response = await self._client.invoke(request)
2795        if isinstance(response, Response_Path):
2796            return response.value
2797        raise UnexpectedResponse()
2798
2799    async def file_exists(
2800        self,
2801        *,
2802        path: str,
2803    ) -> bool:
2804        request = Request_RepositoryFileExists(
2805            self._handle,
2806            path,
2807        )
2808        response = await self._client.invoke(request)
2809        if isinstance(response, Response_Bool):
2810            return response.value
2811        raise UnexpectedResponse()
2812
2813    async def get_access_mode(
2814        self,
2815    ) -> AccessMode:
2816        """Returns the access mode (*blind*, *read* or *write*) the repository is currently opened in."""
2817        request = Request_RepositoryGetAccessMode(
2818            self._handle,
2819        )
2820        response = await self._client.invoke(request)
2821        if isinstance(response, Response_AccessMode):
2822            return response.value
2823        raise UnexpectedResponse()
2824
2825    async def get_block_expiration(
2826        self,
2827    ) -> int | None:
2828        request = Request_RepositoryGetBlockExpiration(
2829            self._handle,
2830        )
2831        response = await self._client.invoke(request)
2832        if isinstance(response, Response_Duration):
2833            return response.value
2834        if isinstance(response, Response_None):
2835            return None
2836        raise UnexpectedResponse()
2837
2838    async def get_credentials(
2839        self,
2840    ) -> bytes:
2841        """
2842        Gets the current credentials of this repository. Can be used to restore access after closing
2843        and reopening the repository.
2844        """
2845        request = Request_RepositoryGetCredentials(
2846            self._handle,
2847        )
2848        response = await self._client.invoke(request)
2849        if isinstance(response, Response_Bytes):
2850            return response.value
2851        raise UnexpectedResponse()
2852
2853    async def get_entry_type(
2854        self,
2855        *,
2856        path: str,
2857    ) -> EntryType | None:
2858        """
2859        Returns the type of repository entry (file, directory, ...) or `None` if the entry doesn't
2860        exist.
2861        """
2862        request = Request_RepositoryGetEntryType(
2863            self._handle,
2864            path,
2865        )
2866        response = await self._client.invoke(request)
2867        if isinstance(response, Response_EntryType):
2868            return response.value
2869        if isinstance(response, Response_None):
2870            return None
2871        raise UnexpectedResponse()
2872
2873    async def get_expiration(
2874        self,
2875    ) -> int | None:
2876        request = Request_RepositoryGetExpiration(
2877            self._handle,
2878        )
2879        response = await self._client.invoke(request)
2880        if isinstance(response, Response_Duration):
2881            return response.value
2882        if isinstance(response, Response_None):
2883            return None
2884        raise UnexpectedResponse()
2885
2886    async def get_info_hash(
2887        self,
2888    ) -> str:
2889        """
2890        Return the info-hash of the repository formatted as hex string. This can be used as a
2891        globally unique, non-secret identifier of the repository.
2892        """
2893        request = Request_RepositoryGetInfoHash(
2894            self._handle,
2895        )
2896        response = await self._client.invoke(request)
2897        if isinstance(response, Response_String):
2898            return response.value
2899        raise UnexpectedResponse()
2900
2901    async def get_joint_snapshot(
2902        self,
2903    ) -> JointSnapshot:
2904        """
2905        Returns the current joint snapshot of the repository: an opaque token identifying the latest
2906        snapshot of each branch. Pass it to [Self::repository_read_directory] and
2907        [Self::repository_open_file] to read from exactly those snapshots.
2908
2909        Equal tokens mean the content of the repository (its directories and files) hasn't changed,
2910        but not that nothing has changed: blocks of those snapshots can keep arriving without
2911        creating new snapshots. So a read at a token that failed because some data hadn't been
2912        downloaded yet can succeed later at the same token.
2913        """
2914        request = Request_RepositoryGetJointSnapshot(
2915            self._handle,
2916        )
2917        response = await self._client.invoke(request)
2918        if isinstance(response, Response_JointSnapshot):
2919            return response.value
2920        raise UnexpectedResponse()
2921
2922    async def get_metadata(
2923        self,
2924        *,
2925        key: str,
2926    ) -> str | None:
2927        request = Request_RepositoryGetMetadata(
2928            self._handle,
2929            key,
2930        )
2931        response = await self._client.invoke(request)
2932        if isinstance(response, Response_String):
2933            return response.value
2934        if isinstance(response, Response_None):
2935            return None
2936        raise UnexpectedResponse()
2937
2938    async def get_mount_point(
2939        self,
2940    ) -> str | None:
2941        request = Request_RepositoryGetMountPoint(
2942            self._handle,
2943        )
2944        response = await self._client.invoke(request)
2945        if isinstance(response, Response_Path):
2946            return response.value
2947        if isinstance(response, Response_None):
2948            return None
2949        raise UnexpectedResponse()
2950
2951    async def get_path(
2952        self,
2953    ) -> str:
2954        request = Request_RepositoryGetPath(
2955            self._handle,
2956        )
2957        response = await self._client.invoke(request)
2958        if isinstance(response, Response_Path):
2959            return response.value
2960        raise UnexpectedResponse()
2961
2962    async def get_quota(
2963        self,
2964    ) -> QuotaInfo:
2965        request = Request_RepositoryGetQuota(
2966            self._handle,
2967        )
2968        response = await self._client.invoke(request)
2969        if isinstance(response, Response_QuotaInfo):
2970            return response.value
2971        raise UnexpectedResponse()
2972
2973    async def get_short_name(
2974        self,
2975    ) -> str:
2976        request = Request_RepositoryGetShortName(
2977            self._handle,
2978        )
2979        response = await self._client.invoke(request)
2980        if isinstance(response, Response_String):
2981            return response.value
2982        raise UnexpectedResponse()
2983
2984    async def get_stats(
2985        self,
2986    ) -> Stats:
2987        request = Request_RepositoryGetStats(
2988            self._handle,
2989        )
2990        response = await self._client.invoke(request)
2991        if isinstance(response, Response_Stats):
2992            return response.value
2993        raise UnexpectedResponse()
2994
2995    async def get_sync_progress(
2996        self,
2997    ) -> Progress:
2998        """
2999        Returns the synchronization progress of this repository as the number of bytes already
3000        synced ([Progress.value]) vs. the total size of the repository in bytes ([Progress.total]).
3001        """
3002        request = Request_RepositoryGetSyncProgress(
3003            self._handle,
3004        )
3005        response = await self._client.invoke(request)
3006        if isinstance(response, Response_Progress):
3007            return response.value
3008        raise UnexpectedResponse()
3009
3010    async def is_dht_enabled(
3011        self,
3012    ) -> bool:
3013        """Is Bittorrent DHT enabled?"""
3014        request = Request_RepositoryIsDhtEnabled(
3015            self._handle,
3016        )
3017        response = await self._client.invoke(request)
3018        if isinstance(response, Response_Bool):
3019            return response.value
3020        raise UnexpectedResponse()
3021
3022    async def is_pex_enabled(
3023        self,
3024    ) -> bool:
3025        """Is Peer Exchange enabled?"""
3026        request = Request_RepositoryIsPexEnabled(
3027            self._handle,
3028        )
3029        response = await self._client.invoke(request)
3030        if isinstance(response, Response_Bool):
3031            return response.value
3032        raise UnexpectedResponse()
3033
3034    async def is_sync_enabled(
3035        self,
3036    ) -> bool:
3037        """Returns whether syncing with other replicas is enabled for this repository."""
3038        request = Request_RepositoryIsSyncEnabled(
3039            self._handle,
3040        )
3041        response = await self._client.invoke(request)
3042        if isinstance(response, Response_Bool):
3043            return response.value
3044        raise UnexpectedResponse()
3045
3046    async def mirror_exists(
3047        self,
3048        *,
3049        host: str,
3050    ) -> bool:
3051        """Checks if this repository is mirrored on the given cache server host."""
3052        request = Request_RepositoryMirrorExists(
3053            self._handle,
3054            host,
3055        )
3056        response = await self._client.invoke(request)
3057        if isinstance(response, Response_Bool):
3058            return response.value
3059        raise UnexpectedResponse()
3060
3061    async def mount(
3062        self,
3063    ) -> str:
3064        request = Request_RepositoryMount(
3065            self._handle,
3066        )
3067        response = await self._client.invoke(request)
3068        if isinstance(response, Response_Path):
3069            return response.value
3070        raise UnexpectedResponse()
3071
3072    async def move(
3073        self,
3074        *,
3075        dst: str,
3076    ):
3077        request = Request_RepositoryMove(
3078            self._handle,
3079            dst,
3080        )
3081        response = await self._client.invoke(request)
3082        if isinstance(response, Response_Unit):
3083            return
3084        raise UnexpectedResponse()
3085
3086    async def move_entry(
3087        self,
3088        *,
3089        src: str,
3090        dst: str,
3091    ):
3092        """Moves an entry (file or directory) from `src` to `dst`."""
3093        request = Request_RepositoryMoveEntry(
3094            self._handle,
3095            src,
3096            dst,
3097        )
3098        response = await self._client.invoke(request)
3099        if isinstance(response, Response_Unit):
3100            return
3101        raise UnexpectedResponse()
3102
3103    async def open_file(
3104        self,
3105        *,
3106        path: str,
3107        joint_snapshot: JointSnapshot | None = None,
3108    ) -> File:
3109        """
3110        Opens an existing file at the given path in the repository.
3111
3112        - `joint_snapshot`: if given (see [Self::repository_get_joint_snapshot]), the file is opened
3113          and later read from exactly those snapshots, and it's read-only. Fails with
3114          `SnapshotNotFound` if any of the snapshots no longer exists.
3115        """
3116        request = Request_RepositoryOpenFile(
3117            self._handle,
3118            path,
3119            joint_snapshot,
3120        )
3121        response = await self._client.invoke(request)
3122        if isinstance(response, Response_File):
3123            return File(self._client, response.value)
3124        raise UnexpectedResponse()
3125
3126    async def read_directory(
3127        self,
3128        *,
3129        path: str,
3130        joint_snapshot: JointSnapshot | None = None,
3131    ) -> list[DirectoryEntry]:
3132        """
3133        Returns the entries of the directory at the given path in the repository.
3134
3135        - `joint_snapshot`: if given (see [Self::repository_get_joint_snapshot]), the directory is
3136          read from exactly those snapshots. If some of its data hasn't been downloaded yet, this
3137          fails instead of falling back to an older version of the directory, and if any of the
3138          snapshots no longer exists, it fails with `SnapshotNotFound`.
3139        """
3140        request = Request_RepositoryReadDirectory(
3141            self._handle,
3142            path,
3143            joint_snapshot,
3144        )
3145        response = await self._client.invoke(request)
3146        if isinstance(response, Response_DirectoryEntries):
3147            return response.value
3148        raise UnexpectedResponse()
3149
3150    async def remove_directory(
3151        self,
3152        *,
3153        path: str,
3154        recursive: bool = False,
3155    ):
3156        """
3157        Removes the directory at the given path from the repository. If `recursive` is true it removes
3158        also the contents, otherwise the directory must be empty.
3159        """
3160        request = Request_RepositoryRemoveDirectory(
3161            self._handle,
3162            path,
3163            recursive,
3164        )
3165        response = await self._client.invoke(request)
3166        if isinstance(response, Response_Unit):
3167            return
3168        raise UnexpectedResponse()
3169
3170    async def remove_file(
3171        self,
3172        *,
3173        path: str,
3174    ):
3175        """Removes (deletes) the file at the given path from the repository."""
3176        request = Request_RepositoryRemoveFile(
3177            self._handle,
3178            path,
3179        )
3180        response = await self._client.invoke(request)
3181        if isinstance(response, Response_Unit):
3182            return
3183        raise UnexpectedResponse()
3184
3185    async def reset_access(
3186        self,
3187        *,
3188        token: str,
3189    ):
3190        request = Request_RepositoryResetAccess(
3191            self._handle,
3192            token,
3193        )
3194        response = await self._client.invoke(request)
3195        if isinstance(response, Response_Unit):
3196            return
3197        raise UnexpectedResponse()
3198
3199    async def set_access(
3200        self,
3201        *,
3202        read: AccessChange | None = None,
3203        write: AccessChange | None = None,
3204    ):
3205        """
3206        Sets, unsets or changes local secrets for accessing the repository or disables the given
3207        access mode.
3208
3209        ## Examples
3210
3211        To protect both read and write access with the same password:
3212
3213        ```kotlin
3214        val password = Password("supersecret")
3215        repo.setAccess(read: AccessChange.Enable(password), write: AccessChange.Enable(password))
3216        ```
3217
3218        To require password only for writing:
3219
3220        ```kotlin
3221        repo.setAccess(read: AccessChange.Enable(null), write: AccessChange.Enable(password))
3222        ```
3223
3224        To competelly disable write access but leave read access as it was. Warning: this operation
3225        is currently irreversibe.
3226
3227        ```kotlin
3228        repo.setAccess(read: null, write: AccessChange.Disable)
3229        ```
3230        """
3231        request = Request_RepositorySetAccess(
3232            self._handle,
3233            read,
3234            write,
3235        )
3236        response = await self._client.invoke(request)
3237        if isinstance(response, Response_Unit):
3238            return
3239        raise UnexpectedResponse()
3240
3241    async def set_access_mode(
3242        self,
3243        *,
3244        access_mode: AccessMode,
3245        local_secret: LocalSecret | None = None,
3246    ):
3247        """
3248        Switches the repository to the given access mode.
3249
3250        - `access_mode` is the desired access mode to switch to.
3251        - `local_secret` is the local secret protecting the desired access mode. Can be `None` if no
3252          local secret is used.
3253        """
3254        request = Request_RepositorySetAccessMode(
3255            self._handle,
3256            access_mode,
3257            local_secret,
3258        )
3259        response = await self._client.invoke(request)
3260        if isinstance(response, Response_Unit):
3261            return
3262        raise UnexpectedResponse()
3263
3264    async def set_block_expiration(
3265        self,
3266        *,
3267        value: int | None = None,
3268    ):
3269        request = Request_RepositorySetBlockExpiration(
3270            self._handle,
3271            value,
3272        )
3273        response = await self._client.invoke(request)
3274        if isinstance(response, Response_Unit):
3275            return
3276        raise UnexpectedResponse()
3277
3278    async def set_credentials(
3279        self,
3280        *,
3281        credentials: bytes,
3282    ):
3283        """Sets the current credentials of the repository."""
3284        request = Request_RepositorySetCredentials(
3285            self._handle,
3286            credentials,
3287        )
3288        response = await self._client.invoke(request)
3289        if isinstance(response, Response_Unit):
3290            return
3291        raise UnexpectedResponse()
3292
3293    async def set_dht_enabled(
3294        self,
3295        *,
3296        enabled: bool = False,
3297    ):
3298        """Enables/disabled Bittorrent DHT (for peer discovery)."""
3299        request = Request_RepositorySetDhtEnabled(
3300            self._handle,
3301            enabled,
3302        )
3303        response = await self._client.invoke(request)
3304        if isinstance(response, Response_Unit):
3305            return
3306        raise UnexpectedResponse()
3307
3308    async def set_expiration(
3309        self,
3310        *,
3311        value: int | None = None,
3312    ):
3313        request = Request_RepositorySetExpiration(
3314            self._handle,
3315            value,
3316        )
3317        response = await self._client.invoke(request)
3318        if isinstance(response, Response_Unit):
3319            return
3320        raise UnexpectedResponse()
3321
3322    async def set_metadata(
3323        self,
3324        *,
3325        edits: list[MetadataEdit],
3326    ) -> bool:
3327        request = Request_RepositorySetMetadata(
3328            self._handle,
3329            edits,
3330        )
3331        response = await self._client.invoke(request)
3332        if isinstance(response, Response_Bool):
3333            return response.value
3334        raise UnexpectedResponse()
3335
3336    async def set_pex_enabled(
3337        self,
3338        *,
3339        enabled: bool = False,
3340    ):
3341        """Enables/disables Peer Exchange (for peer discovery)."""
3342        request = Request_RepositorySetPexEnabled(
3343            self._handle,
3344            enabled,
3345        )
3346        response = await self._client.invoke(request)
3347        if isinstance(response, Response_Unit):
3348            return
3349        raise UnexpectedResponse()
3350
3351    async def set_quota(
3352        self,
3353        *,
3354        value: StorageSize | None = None,
3355    ):
3356        request = Request_RepositorySetQuota(
3357            self._handle,
3358            value,
3359        )
3360        response = await self._client.invoke(request)
3361        if isinstance(response, Response_Unit):
3362            return
3363        raise UnexpectedResponse()
3364
3365    async def set_sync_enabled(
3366        self,
3367        *,
3368        enabled: bool = False,
3369    ):
3370        """
3371        Enabled or disables syncing with other replicas.
3372
3373        Note syncing is initially disabled.
3374        """
3375        request = Request_RepositorySetSyncEnabled(
3376            self._handle,
3377            enabled,
3378        )
3379        response = await self._client.invoke(request)
3380        if isinstance(response, Response_Unit):
3381            return
3382        raise UnexpectedResponse()
3383
3384    async def share(
3385        self,
3386        *,
3387        access_mode: AccessMode,
3388        local_secret: LocalSecret | None = None,
3389    ) -> str:
3390        """
3391        Creates a *share token* to share this repository with other devices.
3392
3393        By default the access mode of the token will be the same as the mode the repo is currently
3394        opened in but it can be escalated with the `local_secret` param or de-escalated with the
3395        `access_mode` param.
3396
3397        - `access_mode`: access mode of the token. Useful to de-escalate the access mode to below of
3398          what the repo is opened in.
3399        - `local_secret`: the local repo secret. If not `None`, the share token's access mode will
3400          be the same as what the secret provides. Useful to escalate the access mode to above of
3401          what the repo is opened in.
3402        """
3403        request = Request_RepositoryShare(
3404            self._handle,
3405            access_mode,
3406            local_secret,
3407        )
3408        response = await self._client.invoke(request)
3409        if isinstance(response, Response_ShareToken):
3410            return response.value
3411        raise UnexpectedResponse()
3412
3413    async def unmount(
3414        self,
3415    ):
3416        request = Request_RepositoryUnmount(
3417            self._handle,
3418        )
3419        response = await self._client.invoke(request)
3420        if isinstance(response, Response_Unit):
3421            return
3422        raise UnexpectedResponse()
async def close(self):
2687    async def close(
2688        self,
2689    ):
2690        """Closes the repository."""
2691        request = Request_RepositoryClose(
2692            self._handle,
2693        )
2694        response = await self._client.invoke(request)
2695        if isinstance(response, Response_Unit):
2696            return
2697        raise UnexpectedResponse()

Closes the repository.

async def create_directory(self, *, path: str):
2699    async def create_directory(
2700        self,
2701        *,
2702        path: str,
2703    ):
2704        """Creates a new directory at the given path in the repository."""
2705        request = Request_RepositoryCreateDirectory(
2706            self._handle,
2707            path,
2708        )
2709        response = await self._client.invoke(request)
2710        if isinstance(response, Response_Unit):
2711            return
2712        raise UnexpectedResponse()

Creates a new directory at the given path in the repository.

async def create_file(self, *, path: str) -> File:
2714    async def create_file(
2715        self,
2716        *,
2717        path: str,
2718    ) -> File:
2719        """Creates a new file at the given path in the repository."""
2720        request = Request_RepositoryCreateFile(
2721            self._handle,
2722            path,
2723        )
2724        response = await self._client.invoke(request)
2725        if isinstance(response, Response_File):
2726            return File(self._client, response.value)
2727        raise UnexpectedResponse()

Creates a new file at the given path in the repository.

async def create_mirror(self, *, host: str):
2729    async def create_mirror(
2730        self,
2731        *,
2732        host: str,
2733    ):
2734        """
2735        Creates mirror of this repository on the given cache server host.
2736
2737        Cache servers relay traffic between Ouisync peers and also temporarily store data. They are
2738        useful when direct P2P connection fails (e.g. due to restrictive NAT) and also to allow
2739        syncing when the peers are not online at the same time (they still need to be online within
2740        ~24 hours of each other).
2741
2742        Requires the repository to be opened in write mode.
2743        """
2744        request = Request_RepositoryCreateMirror(
2745            self._handle,
2746            host,
2747        )
2748        response = await self._client.invoke(request)
2749        if isinstance(response, Response_Unit):
2750            return
2751        raise UnexpectedResponse()

Creates mirror of this repository on the given cache server host.

Cache servers relay traffic between Ouisync peers and also temporarily store data. They are useful when direct P2P connection fails (e.g. due to restrictive NAT) and also to allow syncing when the peers are not online at the same time (they still need to be online within ~24 hours of each other).

Requires the repository to be opened in write mode.

async def delete(self):
2753    async def delete(
2754        self,
2755    ):
2756        """Delete the repository"""
2757        request = Request_RepositoryDelete(
2758            self._handle,
2759        )
2760        response = await self._client.invoke(request)
2761        if isinstance(response, Response_Unit):
2762            return
2763        raise UnexpectedResponse()

Delete the repository

async def delete_mirror(self, *, host: str):
2765    async def delete_mirror(
2766        self,
2767        *,
2768        host: str,
2769    ):
2770        """
2771        Deletes mirror of this repository from the given cache server host.
2772
2773        Requires the repository to be opened in write mode.
2774        """
2775        request = Request_RepositoryDeleteMirror(
2776            self._handle,
2777            host,
2778        )
2779        response = await self._client.invoke(request)
2780        if isinstance(response, Response_Unit):
2781            return
2782        raise UnexpectedResponse()

Deletes mirror of this repository from the given cache server host.

Requires the repository to be opened in write mode.

async def export(self, *, output_path: str) -> str:
2784    async def export(
2785        self,
2786        *,
2787        output_path: str,
2788    ) -> str:
2789        """Export repository to file"""
2790        request = Request_RepositoryExport(
2791            self._handle,
2792            output_path,
2793        )
2794        response = await self._client.invoke(request)
2795        if isinstance(response, Response_Path):
2796            return response.value
2797        raise UnexpectedResponse()

Export repository to file

async def file_exists(self, *, path: str) -> bool:
2799    async def file_exists(
2800        self,
2801        *,
2802        path: str,
2803    ) -> bool:
2804        request = Request_RepositoryFileExists(
2805            self._handle,
2806            path,
2807        )
2808        response = await self._client.invoke(request)
2809        if isinstance(response, Response_Bool):
2810            return response.value
2811        raise UnexpectedResponse()
async def get_access_mode(self) -> AccessMode:
2813    async def get_access_mode(
2814        self,
2815    ) -> AccessMode:
2816        """Returns the access mode (*blind*, *read* or *write*) the repository is currently opened in."""
2817        request = Request_RepositoryGetAccessMode(
2818            self._handle,
2819        )
2820        response = await self._client.invoke(request)
2821        if isinstance(response, Response_AccessMode):
2822            return response.value
2823        raise UnexpectedResponse()

Returns the access mode (blind, read or write) the repository is currently opened in.

async def get_block_expiration(self) -> int | None:
2825    async def get_block_expiration(
2826        self,
2827    ) -> int | None:
2828        request = Request_RepositoryGetBlockExpiration(
2829            self._handle,
2830        )
2831        response = await self._client.invoke(request)
2832        if isinstance(response, Response_Duration):
2833            return response.value
2834        if isinstance(response, Response_None):
2835            return None
2836        raise UnexpectedResponse()
async def get_credentials(self) -> bytes:
2838    async def get_credentials(
2839        self,
2840    ) -> bytes:
2841        """
2842        Gets the current credentials of this repository. Can be used to restore access after closing
2843        and reopening the repository.
2844        """
2845        request = Request_RepositoryGetCredentials(
2846            self._handle,
2847        )
2848        response = await self._client.invoke(request)
2849        if isinstance(response, Response_Bytes):
2850            return response.value
2851        raise UnexpectedResponse()

Gets the current credentials of this repository. Can be used to restore access after closing and reopening the repository.

async def get_entry_type(self, *, path: str) -> EntryType | None:
2853    async def get_entry_type(
2854        self,
2855        *,
2856        path: str,
2857    ) -> EntryType | None:
2858        """
2859        Returns the type of repository entry (file, directory, ...) or `None` if the entry doesn't
2860        exist.
2861        """
2862        request = Request_RepositoryGetEntryType(
2863            self._handle,
2864            path,
2865        )
2866        response = await self._client.invoke(request)
2867        if isinstance(response, Response_EntryType):
2868            return response.value
2869        if isinstance(response, Response_None):
2870            return None
2871        raise UnexpectedResponse()

Returns the type of repository entry (file, directory, ...) or None if the entry doesn't exist.

async def get_expiration(self) -> int | None:
2873    async def get_expiration(
2874        self,
2875    ) -> int | None:
2876        request = Request_RepositoryGetExpiration(
2877            self._handle,
2878        )
2879        response = await self._client.invoke(request)
2880        if isinstance(response, Response_Duration):
2881            return response.value
2882        if isinstance(response, Response_None):
2883            return None
2884        raise UnexpectedResponse()
async def get_info_hash(self) -> str:
2886    async def get_info_hash(
2887        self,
2888    ) -> str:
2889        """
2890        Return the info-hash of the repository formatted as hex string. This can be used as a
2891        globally unique, non-secret identifier of the repository.
2892        """
2893        request = Request_RepositoryGetInfoHash(
2894            self._handle,
2895        )
2896        response = await self._client.invoke(request)
2897        if isinstance(response, Response_String):
2898            return response.value
2899        raise UnexpectedResponse()

Return the info-hash of the repository formatted as hex string. This can be used as a globally unique, non-secret identifier of the repository.

async def get_joint_snapshot(self) -> JointSnapshot:
2901    async def get_joint_snapshot(
2902        self,
2903    ) -> JointSnapshot:
2904        """
2905        Returns the current joint snapshot of the repository: an opaque token identifying the latest
2906        snapshot of each branch. Pass it to [Self::repository_read_directory] and
2907        [Self::repository_open_file] to read from exactly those snapshots.
2908
2909        Equal tokens mean the content of the repository (its directories and files) hasn't changed,
2910        but not that nothing has changed: blocks of those snapshots can keep arriving without
2911        creating new snapshots. So a read at a token that failed because some data hadn't been
2912        downloaded yet can succeed later at the same token.
2913        """
2914        request = Request_RepositoryGetJointSnapshot(
2915            self._handle,
2916        )
2917        response = await self._client.invoke(request)
2918        if isinstance(response, Response_JointSnapshot):
2919            return response.value
2920        raise UnexpectedResponse()

Returns the current joint snapshot of the repository: an opaque token identifying the latest snapshot of each branch. Pass it to [Self::repository_read_directory] and [Self::repository_open_file] to read from exactly those snapshots.

Equal tokens mean the content of the repository (its directories and files) hasn't changed, but not that nothing has changed: blocks of those snapshots can keep arriving without creating new snapshots. So a read at a token that failed because some data hadn't been downloaded yet can succeed later at the same token.

async def get_metadata(self, *, key: str) -> str | None:
2922    async def get_metadata(
2923        self,
2924        *,
2925        key: str,
2926    ) -> str | None:
2927        request = Request_RepositoryGetMetadata(
2928            self._handle,
2929            key,
2930        )
2931        response = await self._client.invoke(request)
2932        if isinstance(response, Response_String):
2933            return response.value
2934        if isinstance(response, Response_None):
2935            return None
2936        raise UnexpectedResponse()
async def get_mount_point(self) -> str | None:
2938    async def get_mount_point(
2939        self,
2940    ) -> str | None:
2941        request = Request_RepositoryGetMountPoint(
2942            self._handle,
2943        )
2944        response = await self._client.invoke(request)
2945        if isinstance(response, Response_Path):
2946            return response.value
2947        if isinstance(response, Response_None):
2948            return None
2949        raise UnexpectedResponse()
async def get_path(self) -> str:
2951    async def get_path(
2952        self,
2953    ) -> str:
2954        request = Request_RepositoryGetPath(
2955            self._handle,
2956        )
2957        response = await self._client.invoke(request)
2958        if isinstance(response, Response_Path):
2959            return response.value
2960        raise UnexpectedResponse()
async def get_quota(self) -> QuotaInfo:
2962    async def get_quota(
2963        self,
2964    ) -> QuotaInfo:
2965        request = Request_RepositoryGetQuota(
2966            self._handle,
2967        )
2968        response = await self._client.invoke(request)
2969        if isinstance(response, Response_QuotaInfo):
2970            return response.value
2971        raise UnexpectedResponse()
async def get_short_name(self) -> str:
2973    async def get_short_name(
2974        self,
2975    ) -> str:
2976        request = Request_RepositoryGetShortName(
2977            self._handle,
2978        )
2979        response = await self._client.invoke(request)
2980        if isinstance(response, Response_String):
2981            return response.value
2982        raise UnexpectedResponse()
async def get_stats(self) -> Stats:
2984    async def get_stats(
2985        self,
2986    ) -> Stats:
2987        request = Request_RepositoryGetStats(
2988            self._handle,
2989        )
2990        response = await self._client.invoke(request)
2991        if isinstance(response, Response_Stats):
2992            return response.value
2993        raise UnexpectedResponse()
async def get_sync_progress(self) -> Progress:
2995    async def get_sync_progress(
2996        self,
2997    ) -> Progress:
2998        """
2999        Returns the synchronization progress of this repository as the number of bytes already
3000        synced ([Progress.value]) vs. the total size of the repository in bytes ([Progress.total]).
3001        """
3002        request = Request_RepositoryGetSyncProgress(
3003            self._handle,
3004        )
3005        response = await self._client.invoke(request)
3006        if isinstance(response, Response_Progress):
3007            return response.value
3008        raise UnexpectedResponse()

Returns the synchronization progress of this repository as the number of bytes already synced ([Progress.value]) vs. the total size of the repository in bytes ([Progress.total]).

async def is_dht_enabled(self) -> bool:
3010    async def is_dht_enabled(
3011        self,
3012    ) -> bool:
3013        """Is Bittorrent DHT enabled?"""
3014        request = Request_RepositoryIsDhtEnabled(
3015            self._handle,
3016        )
3017        response = await self._client.invoke(request)
3018        if isinstance(response, Response_Bool):
3019            return response.value
3020        raise UnexpectedResponse()

Is Bittorrent DHT enabled?

async def is_pex_enabled(self) -> bool:
3022    async def is_pex_enabled(
3023        self,
3024    ) -> bool:
3025        """Is Peer Exchange enabled?"""
3026        request = Request_RepositoryIsPexEnabled(
3027            self._handle,
3028        )
3029        response = await self._client.invoke(request)
3030        if isinstance(response, Response_Bool):
3031            return response.value
3032        raise UnexpectedResponse()

Is Peer Exchange enabled?

async def is_sync_enabled(self) -> bool:
3034    async def is_sync_enabled(
3035        self,
3036    ) -> bool:
3037        """Returns whether syncing with other replicas is enabled for this repository."""
3038        request = Request_RepositoryIsSyncEnabled(
3039            self._handle,
3040        )
3041        response = await self._client.invoke(request)
3042        if isinstance(response, Response_Bool):
3043            return response.value
3044        raise UnexpectedResponse()

Returns whether syncing with other replicas is enabled for this repository.

async def mirror_exists(self, *, host: str) -> bool:
3046    async def mirror_exists(
3047        self,
3048        *,
3049        host: str,
3050    ) -> bool:
3051        """Checks if this repository is mirrored on the given cache server host."""
3052        request = Request_RepositoryMirrorExists(
3053            self._handle,
3054            host,
3055        )
3056        response = await self._client.invoke(request)
3057        if isinstance(response, Response_Bool):
3058            return response.value
3059        raise UnexpectedResponse()

Checks if this repository is mirrored on the given cache server host.

async def mount(self) -> str:
3061    async def mount(
3062        self,
3063    ) -> str:
3064        request = Request_RepositoryMount(
3065            self._handle,
3066        )
3067        response = await self._client.invoke(request)
3068        if isinstance(response, Response_Path):
3069            return response.value
3070        raise UnexpectedResponse()
async def move(self, *, dst: str):
3072    async def move(
3073        self,
3074        *,
3075        dst: str,
3076    ):
3077        request = Request_RepositoryMove(
3078            self._handle,
3079            dst,
3080        )
3081        response = await self._client.invoke(request)
3082        if isinstance(response, Response_Unit):
3083            return
3084        raise UnexpectedResponse()
async def move_entry(self, *, src: str, dst: str):
3086    async def move_entry(
3087        self,
3088        *,
3089        src: str,
3090        dst: str,
3091    ):
3092        """Moves an entry (file or directory) from `src` to `dst`."""
3093        request = Request_RepositoryMoveEntry(
3094            self._handle,
3095            src,
3096            dst,
3097        )
3098        response = await self._client.invoke(request)
3099        if isinstance(response, Response_Unit):
3100            return
3101        raise UnexpectedResponse()

Moves an entry (file or directory) from src to dst.

async def open_file( self, *, path: str, joint_snapshot: JointSnapshot | None = None) -> File:
3103    async def open_file(
3104        self,
3105        *,
3106        path: str,
3107        joint_snapshot: JointSnapshot | None = None,
3108    ) -> File:
3109        """
3110        Opens an existing file at the given path in the repository.
3111
3112        - `joint_snapshot`: if given (see [Self::repository_get_joint_snapshot]), the file is opened
3113          and later read from exactly those snapshots, and it's read-only. Fails with
3114          `SnapshotNotFound` if any of the snapshots no longer exists.
3115        """
3116        request = Request_RepositoryOpenFile(
3117            self._handle,
3118            path,
3119            joint_snapshot,
3120        )
3121        response = await self._client.invoke(request)
3122        if isinstance(response, Response_File):
3123            return File(self._client, response.value)
3124        raise UnexpectedResponse()

Opens an existing file at the given path in the repository.

  • joint_snapshot: if given (see [Self::repository_get_joint_snapshot]), the file is opened and later read from exactly those snapshots, and it's read-only. Fails with SnapshotNotFound if any of the snapshots no longer exists.
async def read_directory( self, *, path: str, joint_snapshot: JointSnapshot | None = None) -> list[DirectoryEntry]:
3126    async def read_directory(
3127        self,
3128        *,
3129        path: str,
3130        joint_snapshot: JointSnapshot | None = None,
3131    ) -> list[DirectoryEntry]:
3132        """
3133        Returns the entries of the directory at the given path in the repository.
3134
3135        - `joint_snapshot`: if given (see [Self::repository_get_joint_snapshot]), the directory is
3136          read from exactly those snapshots. If some of its data hasn't been downloaded yet, this
3137          fails instead of falling back to an older version of the directory, and if any of the
3138          snapshots no longer exists, it fails with `SnapshotNotFound`.
3139        """
3140        request = Request_RepositoryReadDirectory(
3141            self._handle,
3142            path,
3143            joint_snapshot,
3144        )
3145        response = await self._client.invoke(request)
3146        if isinstance(response, Response_DirectoryEntries):
3147            return response.value
3148        raise UnexpectedResponse()

Returns the entries of the directory at the given path in the repository.

  • joint_snapshot: if given (see [Self::repository_get_joint_snapshot]), the directory is read from exactly those snapshots. If some of its data hasn't been downloaded yet, this fails instead of falling back to an older version of the directory, and if any of the snapshots no longer exists, it fails with SnapshotNotFound.
async def remove_directory(self, *, path: str, recursive: bool = False):
3150    async def remove_directory(
3151        self,
3152        *,
3153        path: str,
3154        recursive: bool = False,
3155    ):
3156        """
3157        Removes the directory at the given path from the repository. If `recursive` is true it removes
3158        also the contents, otherwise the directory must be empty.
3159        """
3160        request = Request_RepositoryRemoveDirectory(
3161            self._handle,
3162            path,
3163            recursive,
3164        )
3165        response = await self._client.invoke(request)
3166        if isinstance(response, Response_Unit):
3167            return
3168        raise UnexpectedResponse()

Removes the directory at the given path from the repository. If recursive is true it removes also the contents, otherwise the directory must be empty.

async def remove_file(self, *, path: str):
3170    async def remove_file(
3171        self,
3172        *,
3173        path: str,
3174    ):
3175        """Removes (deletes) the file at the given path from the repository."""
3176        request = Request_RepositoryRemoveFile(
3177            self._handle,
3178            path,
3179        )
3180        response = await self._client.invoke(request)
3181        if isinstance(response, Response_Unit):
3182            return
3183        raise UnexpectedResponse()

Removes (deletes) the file at the given path from the repository.

async def reset_access(self, *, token: str):
3185    async def reset_access(
3186        self,
3187        *,
3188        token: str,
3189    ):
3190        request = Request_RepositoryResetAccess(
3191            self._handle,
3192            token,
3193        )
3194        response = await self._client.invoke(request)
3195        if isinstance(response, Response_Unit):
3196            return
3197        raise UnexpectedResponse()
async def set_access( self, *, read: AccessChange | None = None, write: AccessChange | None = None):
3199    async def set_access(
3200        self,
3201        *,
3202        read: AccessChange | None = None,
3203        write: AccessChange | None = None,
3204    ):
3205        """
3206        Sets, unsets or changes local secrets for accessing the repository or disables the given
3207        access mode.
3208
3209        ## Examples
3210
3211        To protect both read and write access with the same password:
3212
3213        ```kotlin
3214        val password = Password("supersecret")
3215        repo.setAccess(read: AccessChange.Enable(password), write: AccessChange.Enable(password))
3216        ```
3217
3218        To require password only for writing:
3219
3220        ```kotlin
3221        repo.setAccess(read: AccessChange.Enable(null), write: AccessChange.Enable(password))
3222        ```
3223
3224        To competelly disable write access but leave read access as it was. Warning: this operation
3225        is currently irreversibe.
3226
3227        ```kotlin
3228        repo.setAccess(read: null, write: AccessChange.Disable)
3229        ```
3230        """
3231        request = Request_RepositorySetAccess(
3232            self._handle,
3233            read,
3234            write,
3235        )
3236        response = await self._client.invoke(request)
3237        if isinstance(response, Response_Unit):
3238            return
3239        raise UnexpectedResponse()

Sets, unsets or changes local secrets for accessing the repository or disables the given access mode.

Examples

To protect both read and write access with the same password:

val password = Password("supersecret")
repo.setAccess(read: AccessChange.Enable(password), write: AccessChange.Enable(password))

To require password only for writing:

repo.setAccess(read: AccessChange.Enable(null), write: AccessChange.Enable(password))

To competelly disable write access but leave read access as it was. Warning: this operation is currently irreversibe.

repo.setAccess(read: null, write: AccessChange.Disable)
async def set_access_mode( self, *, access_mode: AccessMode, local_secret: LocalSecret | None = None):
3241    async def set_access_mode(
3242        self,
3243        *,
3244        access_mode: AccessMode,
3245        local_secret: LocalSecret | None = None,
3246    ):
3247        """
3248        Switches the repository to the given access mode.
3249
3250        - `access_mode` is the desired access mode to switch to.
3251        - `local_secret` is the local secret protecting the desired access mode. Can be `None` if no
3252          local secret is used.
3253        """
3254        request = Request_RepositorySetAccessMode(
3255            self._handle,
3256            access_mode,
3257            local_secret,
3258        )
3259        response = await self._client.invoke(request)
3260        if isinstance(response, Response_Unit):
3261            return
3262        raise UnexpectedResponse()

Switches the repository to the given access mode.

  • access_mode is the desired access mode to switch to.
  • local_secret is the local secret protecting the desired access mode. Can be None if no local secret is used.
async def set_block_expiration(self, *, value: int | None = None):
3264    async def set_block_expiration(
3265        self,
3266        *,
3267        value: int | None = None,
3268    ):
3269        request = Request_RepositorySetBlockExpiration(
3270            self._handle,
3271            value,
3272        )
3273        response = await self._client.invoke(request)
3274        if isinstance(response, Response_Unit):
3275            return
3276        raise UnexpectedResponse()
async def set_credentials(self, *, credentials: bytes):
3278    async def set_credentials(
3279        self,
3280        *,
3281        credentials: bytes,
3282    ):
3283        """Sets the current credentials of the repository."""
3284        request = Request_RepositorySetCredentials(
3285            self._handle,
3286            credentials,
3287        )
3288        response = await self._client.invoke(request)
3289        if isinstance(response, Response_Unit):
3290            return
3291        raise UnexpectedResponse()

Sets the current credentials of the repository.

async def set_dht_enabled(self, *, enabled: bool = False):
3293    async def set_dht_enabled(
3294        self,
3295        *,
3296        enabled: bool = False,
3297    ):
3298        """Enables/disabled Bittorrent DHT (for peer discovery)."""
3299        request = Request_RepositorySetDhtEnabled(
3300            self._handle,
3301            enabled,
3302        )
3303        response = await self._client.invoke(request)
3304        if isinstance(response, Response_Unit):
3305            return
3306        raise UnexpectedResponse()

Enables/disabled Bittorrent DHT (for peer discovery).

async def set_expiration(self, *, value: int | None = None):
3308    async def set_expiration(
3309        self,
3310        *,
3311        value: int | None = None,
3312    ):
3313        request = Request_RepositorySetExpiration(
3314            self._handle,
3315            value,
3316        )
3317        response = await self._client.invoke(request)
3318        if isinstance(response, Response_Unit):
3319            return
3320        raise UnexpectedResponse()
async def set_metadata( self, *, edits: list[MetadataEdit]) -> bool:
3322    async def set_metadata(
3323        self,
3324        *,
3325        edits: list[MetadataEdit],
3326    ) -> bool:
3327        request = Request_RepositorySetMetadata(
3328            self._handle,
3329            edits,
3330        )
3331        response = await self._client.invoke(request)
3332        if isinstance(response, Response_Bool):
3333            return response.value
3334        raise UnexpectedResponse()
async def set_pex_enabled(self, *, enabled: bool = False):
3336    async def set_pex_enabled(
3337        self,
3338        *,
3339        enabled: bool = False,
3340    ):
3341        """Enables/disables Peer Exchange (for peer discovery)."""
3342        request = Request_RepositorySetPexEnabled(
3343            self._handle,
3344            enabled,
3345        )
3346        response = await self._client.invoke(request)
3347        if isinstance(response, Response_Unit):
3348            return
3349        raise UnexpectedResponse()

Enables/disables Peer Exchange (for peer discovery).

async def set_quota( self, *, value: StorageSize | None = None):
3351    async def set_quota(
3352        self,
3353        *,
3354        value: StorageSize | None = None,
3355    ):
3356        request = Request_RepositorySetQuota(
3357            self._handle,
3358            value,
3359        )
3360        response = await self._client.invoke(request)
3361        if isinstance(response, Response_Unit):
3362            return
3363        raise UnexpectedResponse()
async def set_sync_enabled(self, *, enabled: bool = False):
3365    async def set_sync_enabled(
3366        self,
3367        *,
3368        enabled: bool = False,
3369    ):
3370        """
3371        Enabled or disables syncing with other replicas.
3372
3373        Note syncing is initially disabled.
3374        """
3375        request = Request_RepositorySetSyncEnabled(
3376            self._handle,
3377            enabled,
3378        )
3379        response = await self._client.invoke(request)
3380        if isinstance(response, Response_Unit):
3381            return
3382        raise UnexpectedResponse()

Enabled or disables syncing with other replicas.

Note syncing is initially disabled.

async def share( self, *, access_mode: AccessMode, local_secret: LocalSecret | None = None) -> str:
3384    async def share(
3385        self,
3386        *,
3387        access_mode: AccessMode,
3388        local_secret: LocalSecret | None = None,
3389    ) -> str:
3390        """
3391        Creates a *share token* to share this repository with other devices.
3392
3393        By default the access mode of the token will be the same as the mode the repo is currently
3394        opened in but it can be escalated with the `local_secret` param or de-escalated with the
3395        `access_mode` param.
3396
3397        - `access_mode`: access mode of the token. Useful to de-escalate the access mode to below of
3398          what the repo is opened in.
3399        - `local_secret`: the local repo secret. If not `None`, the share token's access mode will
3400          be the same as what the secret provides. Useful to escalate the access mode to above of
3401          what the repo is opened in.
3402        """
3403        request = Request_RepositoryShare(
3404            self._handle,
3405            access_mode,
3406            local_secret,
3407        )
3408        response = await self._client.invoke(request)
3409        if isinstance(response, Response_ShareToken):
3410            return response.value
3411        raise UnexpectedResponse()

Creates a share token to share this repository with other devices.

By default the access mode of the token will be the same as the mode the repo is currently opened in but it can be escalated with the local_secret param or de-escalated with the access_mode param.

  • access_mode: access mode of the token. Useful to de-escalate the access mode to below of what the repo is opened in.
  • local_secret: the local repo secret. If not None, the share token's access mode will be the same as what the secret provides. Useful to escalate the access mode to above of what the repo is opened in.
async def unmount(self):
3413    async def unmount(
3414        self,
3415    ):
3416        request = Request_RepositoryUnmount(
3417            self._handle,
3418        )
3419        response = await self._client.invoke(request)
3420        if isinstance(response, Response_Unit):
3421            return
3422        raise UnexpectedResponse()
class Request:
594class Request:
595    _variants: ClassVar[dict[str, type]] = {}
@dataclass
class Request_Cancel(ouisync.session.Request):
597@dataclass
598class Request_Cancel(Request):
599    _tag: ClassVar[str] = "Cancel"
600    _shape: ClassVar[str] = "named"
601    id: MessageId
Request_Cancel(id: MessageId)
id: MessageId
@dataclass
class Request_FileClose(ouisync.session.Request):
603@dataclass
604class Request_FileClose(Request):
605    _tag: ClassVar[str] = "FileClose"
606    _shape: ClassVar[str] = "named"
607    file: FileHandle
Request_FileClose(file: ouisync.session._generated.api.FileHandle)
file: ouisync.session._generated.api.FileHandle
@dataclass
class Request_FileFlush(ouisync.session.Request):
609@dataclass
610class Request_FileFlush(Request):
611    _tag: ClassVar[str] = "FileFlush"
612    _shape: ClassVar[str] = "named"
613    file: FileHandle
Request_FileFlush(file: ouisync.session._generated.api.FileHandle)
file: ouisync.session._generated.api.FileHandle
@dataclass
class Request_FileGetLength(ouisync.session.Request):
615@dataclass
616class Request_FileGetLength(Request):
617    _tag: ClassVar[str] = "FileGetLength"
618    _shape: ClassVar[str] = "named"
619    file: FileHandle
Request_FileGetLength(file: ouisync.session._generated.api.FileHandle)
file: ouisync.session._generated.api.FileHandle
@dataclass
class Request_FileGetProgress(ouisync.session.Request):
621@dataclass
622class Request_FileGetProgress(Request):
623    _tag: ClassVar[str] = "FileGetProgress"
624    _shape: ClassVar[str] = "named"
625    file: FileHandle
Request_FileGetProgress(file: ouisync.session._generated.api.FileHandle)
file: ouisync.session._generated.api.FileHandle
@dataclass
class Request_FileRead(ouisync.session.Request):
627@dataclass
628class Request_FileRead(Request):
629    _tag: ClassVar[str] = "FileRead"
630    _shape: ClassVar[str] = "named"
631    file: FileHandle
632    offset: int
633    size: int
Request_FileRead( file: ouisync.session._generated.api.FileHandle, offset: int, size: int)
file: ouisync.session._generated.api.FileHandle
offset: int
size: int
@dataclass
class Request_FileTruncate(ouisync.session.Request):
635@dataclass
636class Request_FileTruncate(Request):
637    _tag: ClassVar[str] = "FileTruncate"
638    _shape: ClassVar[str] = "named"
639    file: FileHandle
640    len: int
Request_FileTruncate(file: ouisync.session._generated.api.FileHandle, len: int)
file: ouisync.session._generated.api.FileHandle
len: int
@dataclass
class Request_FileWrite(ouisync.session.Request):
642@dataclass
643class Request_FileWrite(Request):
644    _tag: ClassVar[str] = "FileWrite"
645    _shape: ClassVar[str] = "named"
646    file: FileHandle
647    offset: int
648    data: bytes
Request_FileWrite( file: ouisync.session._generated.api.FileHandle, offset: int, data: bytes)
file: ouisync.session._generated.api.FileHandle
offset: int
data: bytes
@dataclass
class Request_NetworkSocketClose(ouisync.session.Request):
650@dataclass
651class Request_NetworkSocketClose(Request):
652    _tag: ClassVar[str] = "NetworkSocketClose"
653    _shape: ClassVar[str] = "named"
654    socket: NetworkSocketHandle
Request_NetworkSocketClose(socket: ouisync.session._generated.api.NetworkSocketHandle)
socket: ouisync.session._generated.api.NetworkSocketHandle
@dataclass
class Request_NetworkSocketRecvFrom(ouisync.session.Request):
656@dataclass
657class Request_NetworkSocketRecvFrom(Request):
658    _tag: ClassVar[str] = "NetworkSocketRecvFrom"
659    _shape: ClassVar[str] = "named"
660    socket: NetworkSocketHandle
661    len: int
Request_NetworkSocketRecvFrom(socket: ouisync.session._generated.api.NetworkSocketHandle, len: int)
socket: ouisync.session._generated.api.NetworkSocketHandle
len: int
@dataclass
class Request_NetworkSocketSendTo(ouisync.session.Request):
663@dataclass
664class Request_NetworkSocketSendTo(Request):
665    _tag: ClassVar[str] = "NetworkSocketSendTo"
666    _shape: ClassVar[str] = "named"
667    socket: NetworkSocketHandle
668    data: bytes
669    addr: str
Request_NetworkSocketSendTo( socket: ouisync.session._generated.api.NetworkSocketHandle, data: bytes, addr: str)
socket: ouisync.session._generated.api.NetworkSocketHandle
data: bytes
addr: str
@dataclass
class Request_NetworkStreamClose(ouisync.session.Request):
671@dataclass
672class Request_NetworkStreamClose(Request):
673    _tag: ClassVar[str] = "NetworkStreamClose"
674    _shape: ClassVar[str] = "named"
675    stream: NetworkStreamHandle
Request_NetworkStreamClose(stream: ouisync.session._generated.api.NetworkStreamHandle)
stream: ouisync.session._generated.api.NetworkStreamHandle
@dataclass
class Request_NetworkStreamReadExact(ouisync.session.Request):
677@dataclass
678class Request_NetworkStreamReadExact(Request):
679    _tag: ClassVar[str] = "NetworkStreamReadExact"
680    _shape: ClassVar[str] = "named"
681    stream: NetworkStreamHandle
682    len: int
Request_NetworkStreamReadExact(stream: ouisync.session._generated.api.NetworkStreamHandle, len: int)
stream: ouisync.session._generated.api.NetworkStreamHandle
len: int
@dataclass
class Request_NetworkStreamWriteAll(ouisync.session.Request):
684@dataclass
685class Request_NetworkStreamWriteAll(Request):
686    _tag: ClassVar[str] = "NetworkStreamWriteAll"
687    _shape: ClassVar[str] = "named"
688    stream: NetworkStreamHandle
689    buf: bytes
Request_NetworkStreamWriteAll( stream: ouisync.session._generated.api.NetworkStreamHandle, buf: bytes)
stream: ouisync.session._generated.api.NetworkStreamHandle
buf: bytes
@dataclass
class Request_RepositoryClose(ouisync.session.Request):
691@dataclass
692class Request_RepositoryClose(Request):
693    _tag: ClassVar[str] = "RepositoryClose"
694    _shape: ClassVar[str] = "named"
695    repo: RepositoryHandle
Request_RepositoryClose(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryCreateDirectory(ouisync.session.Request):
697@dataclass
698class Request_RepositoryCreateDirectory(Request):
699    _tag: ClassVar[str] = "RepositoryCreateDirectory"
700    _shape: ClassVar[str] = "named"
701    repo: RepositoryHandle
702    path: str
Request_RepositoryCreateDirectory(repo: ouisync.session._generated.api.RepositoryHandle, path: str)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
@dataclass
class Request_RepositoryCreateFile(ouisync.session.Request):
704@dataclass
705class Request_RepositoryCreateFile(Request):
706    _tag: ClassVar[str] = "RepositoryCreateFile"
707    _shape: ClassVar[str] = "named"
708    repo: RepositoryHandle
709    path: str
Request_RepositoryCreateFile(repo: ouisync.session._generated.api.RepositoryHandle, path: str)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
@dataclass
class Request_RepositoryCreateMirror(ouisync.session.Request):
711@dataclass
712class Request_RepositoryCreateMirror(Request):
713    _tag: ClassVar[str] = "RepositoryCreateMirror"
714    _shape: ClassVar[str] = "named"
715    repo: RepositoryHandle
716    host: str
Request_RepositoryCreateMirror(repo: ouisync.session._generated.api.RepositoryHandle, host: str)
repo: ouisync.session._generated.api.RepositoryHandle
host: str
@dataclass
class Request_RepositoryDelete(ouisync.session.Request):
718@dataclass
719class Request_RepositoryDelete(Request):
720    _tag: ClassVar[str] = "RepositoryDelete"
721    _shape: ClassVar[str] = "named"
722    repo: RepositoryHandle
Request_RepositoryDelete(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryDeleteMirror(ouisync.session.Request):
724@dataclass
725class Request_RepositoryDeleteMirror(Request):
726    _tag: ClassVar[str] = "RepositoryDeleteMirror"
727    _shape: ClassVar[str] = "named"
728    repo: RepositoryHandle
729    host: str
Request_RepositoryDeleteMirror(repo: ouisync.session._generated.api.RepositoryHandle, host: str)
repo: ouisync.session._generated.api.RepositoryHandle
host: str
@dataclass
class Request_RepositoryExport(ouisync.session.Request):
731@dataclass
732class Request_RepositoryExport(Request):
733    _tag: ClassVar[str] = "RepositoryExport"
734    _shape: ClassVar[str] = "named"
735    repo: RepositoryHandle
736    output_path: str
Request_RepositoryExport( repo: ouisync.session._generated.api.RepositoryHandle, output_path: str)
repo: ouisync.session._generated.api.RepositoryHandle
output_path: str
@dataclass
class Request_RepositoryFileExists(ouisync.session.Request):
738@dataclass
739class Request_RepositoryFileExists(Request):
740    _tag: ClassVar[str] = "RepositoryFileExists"
741    _shape: ClassVar[str] = "named"
742    repo: RepositoryHandle
743    path: str
Request_RepositoryFileExists(repo: ouisync.session._generated.api.RepositoryHandle, path: str)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
@dataclass
class Request_RepositoryGetAccessMode(ouisync.session.Request):
745@dataclass
746class Request_RepositoryGetAccessMode(Request):
747    _tag: ClassVar[str] = "RepositoryGetAccessMode"
748    _shape: ClassVar[str] = "named"
749    repo: RepositoryHandle
Request_RepositoryGetAccessMode(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetBlockExpiration(ouisync.session.Request):
751@dataclass
752class Request_RepositoryGetBlockExpiration(Request):
753    _tag: ClassVar[str] = "RepositoryGetBlockExpiration"
754    _shape: ClassVar[str] = "named"
755    repo: RepositoryHandle
Request_RepositoryGetBlockExpiration(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetCredentials(ouisync.session.Request):
757@dataclass
758class Request_RepositoryGetCredentials(Request):
759    _tag: ClassVar[str] = "RepositoryGetCredentials"
760    _shape: ClassVar[str] = "named"
761    repo: RepositoryHandle
Request_RepositoryGetCredentials(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetEntryType(ouisync.session.Request):
763@dataclass
764class Request_RepositoryGetEntryType(Request):
765    _tag: ClassVar[str] = "RepositoryGetEntryType"
766    _shape: ClassVar[str] = "named"
767    repo: RepositoryHandle
768    path: str
Request_RepositoryGetEntryType(repo: ouisync.session._generated.api.RepositoryHandle, path: str)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
@dataclass
class Request_RepositoryGetExpiration(ouisync.session.Request):
770@dataclass
771class Request_RepositoryGetExpiration(Request):
772    _tag: ClassVar[str] = "RepositoryGetExpiration"
773    _shape: ClassVar[str] = "named"
774    repo: RepositoryHandle
Request_RepositoryGetExpiration(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetInfoHash(ouisync.session.Request):
776@dataclass
777class Request_RepositoryGetInfoHash(Request):
778    _tag: ClassVar[str] = "RepositoryGetInfoHash"
779    _shape: ClassVar[str] = "named"
780    repo: RepositoryHandle
Request_RepositoryGetInfoHash(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetJointSnapshot(ouisync.session.Request):
782@dataclass
783class Request_RepositoryGetJointSnapshot(Request):
784    _tag: ClassVar[str] = "RepositoryGetJointSnapshot"
785    _shape: ClassVar[str] = "named"
786    repo: RepositoryHandle
Request_RepositoryGetJointSnapshot(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetMetadata(ouisync.session.Request):
788@dataclass
789class Request_RepositoryGetMetadata(Request):
790    _tag: ClassVar[str] = "RepositoryGetMetadata"
791    _shape: ClassVar[str] = "named"
792    repo: RepositoryHandle
793    key: str
Request_RepositoryGetMetadata(repo: ouisync.session._generated.api.RepositoryHandle, key: str)
repo: ouisync.session._generated.api.RepositoryHandle
key: str
@dataclass
class Request_RepositoryGetMountPoint(ouisync.session.Request):
795@dataclass
796class Request_RepositoryGetMountPoint(Request):
797    _tag: ClassVar[str] = "RepositoryGetMountPoint"
798    _shape: ClassVar[str] = "named"
799    _repo: RepositoryHandle
Request_RepositoryGetMountPoint(_repo: ouisync.session._generated.api.RepositoryHandle)
@dataclass
class Request_RepositoryGetPath(ouisync.session.Request):
801@dataclass
802class Request_RepositoryGetPath(Request):
803    _tag: ClassVar[str] = "RepositoryGetPath"
804    _shape: ClassVar[str] = "named"
805    repo: RepositoryHandle
Request_RepositoryGetPath(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetQuota(ouisync.session.Request):
807@dataclass
808class Request_RepositoryGetQuota(Request):
809    _tag: ClassVar[str] = "RepositoryGetQuota"
810    _shape: ClassVar[str] = "named"
811    repo: RepositoryHandle
Request_RepositoryGetQuota(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetShortName(ouisync.session.Request):
813@dataclass
814class Request_RepositoryGetShortName(Request):
815    _tag: ClassVar[str] = "RepositoryGetShortName"
816    _shape: ClassVar[str] = "named"
817    repo: RepositoryHandle
Request_RepositoryGetShortName(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetStats(ouisync.session.Request):
819@dataclass
820class Request_RepositoryGetStats(Request):
821    _tag: ClassVar[str] = "RepositoryGetStats"
822    _shape: ClassVar[str] = "named"
823    repo: RepositoryHandle
Request_RepositoryGetStats(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryGetSyncProgress(ouisync.session.Request):
825@dataclass
826class Request_RepositoryGetSyncProgress(Request):
827    _tag: ClassVar[str] = "RepositoryGetSyncProgress"
828    _shape: ClassVar[str] = "named"
829    repo: RepositoryHandle
Request_RepositoryGetSyncProgress(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryIsDhtEnabled(ouisync.session.Request):
831@dataclass
832class Request_RepositoryIsDhtEnabled(Request):
833    _tag: ClassVar[str] = "RepositoryIsDhtEnabled"
834    _shape: ClassVar[str] = "named"
835    repo: RepositoryHandle
Request_RepositoryIsDhtEnabled(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryIsPexEnabled(ouisync.session.Request):
837@dataclass
838class Request_RepositoryIsPexEnabled(Request):
839    _tag: ClassVar[str] = "RepositoryIsPexEnabled"
840    _shape: ClassVar[str] = "named"
841    repo: RepositoryHandle
Request_RepositoryIsPexEnabled(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryIsSyncEnabled(ouisync.session.Request):
843@dataclass
844class Request_RepositoryIsSyncEnabled(Request):
845    _tag: ClassVar[str] = "RepositoryIsSyncEnabled"
846    _shape: ClassVar[str] = "named"
847    repo: RepositoryHandle
Request_RepositoryIsSyncEnabled(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryMirrorExists(ouisync.session.Request):
849@dataclass
850class Request_RepositoryMirrorExists(Request):
851    _tag: ClassVar[str] = "RepositoryMirrorExists"
852    _shape: ClassVar[str] = "named"
853    repo: RepositoryHandle
854    host: str
Request_RepositoryMirrorExists(repo: ouisync.session._generated.api.RepositoryHandle, host: str)
repo: ouisync.session._generated.api.RepositoryHandle
host: str
@dataclass
class Request_RepositoryMount(ouisync.session.Request):
856@dataclass
857class Request_RepositoryMount(Request):
858    _tag: ClassVar[str] = "RepositoryMount"
859    _shape: ClassVar[str] = "named"
860    repo: RepositoryHandle
Request_RepositoryMount(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryMove(ouisync.session.Request):
862@dataclass
863class Request_RepositoryMove(Request):
864    _tag: ClassVar[str] = "RepositoryMove"
865    _shape: ClassVar[str] = "named"
866    repo: RepositoryHandle
867    dst: str
Request_RepositoryMove(repo: ouisync.session._generated.api.RepositoryHandle, dst: str)
repo: ouisync.session._generated.api.RepositoryHandle
dst: str
@dataclass
class Request_RepositoryMoveEntry(ouisync.session.Request):
869@dataclass
870class Request_RepositoryMoveEntry(Request):
871    _tag: ClassVar[str] = "RepositoryMoveEntry"
872    _shape: ClassVar[str] = "named"
873    repo: RepositoryHandle
874    src: str
875    dst: str
Request_RepositoryMoveEntry( repo: ouisync.session._generated.api.RepositoryHandle, src: str, dst: str)
repo: ouisync.session._generated.api.RepositoryHandle
src: str
dst: str
@dataclass
class Request_RepositoryOpenFile(ouisync.session.Request):
877@dataclass
878class Request_RepositoryOpenFile(Request):
879    _tag: ClassVar[str] = "RepositoryOpenFile"
880    _shape: ClassVar[str] = "named"
881    repo: RepositoryHandle
882    path: str
883    joint_snapshot: JointSnapshot | None
Request_RepositoryOpenFile( repo: ouisync.session._generated.api.RepositoryHandle, path: str, joint_snapshot: JointSnapshot | None)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
joint_snapshot: JointSnapshot | None
@dataclass
class Request_RepositoryReadDirectory(ouisync.session.Request):
885@dataclass
886class Request_RepositoryReadDirectory(Request):
887    _tag: ClassVar[str] = "RepositoryReadDirectory"
888    _shape: ClassVar[str] = "named"
889    repo: RepositoryHandle
890    path: str
891    joint_snapshot: JointSnapshot | None
Request_RepositoryReadDirectory( repo: ouisync.session._generated.api.RepositoryHandle, path: str, joint_snapshot: JointSnapshot | None)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
joint_snapshot: JointSnapshot | None
@dataclass
class Request_RepositoryRemoveDirectory(ouisync.session.Request):
893@dataclass
894class Request_RepositoryRemoveDirectory(Request):
895    _tag: ClassVar[str] = "RepositoryRemoveDirectory"
896    _shape: ClassVar[str] = "named"
897    repo: RepositoryHandle
898    path: str
899    recursive: bool
Request_RepositoryRemoveDirectory( repo: ouisync.session._generated.api.RepositoryHandle, path: str, recursive: bool)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
recursive: bool
@dataclass
class Request_RepositoryRemoveFile(ouisync.session.Request):
901@dataclass
902class Request_RepositoryRemoveFile(Request):
903    _tag: ClassVar[str] = "RepositoryRemoveFile"
904    _shape: ClassVar[str] = "named"
905    repo: RepositoryHandle
906    path: str
Request_RepositoryRemoveFile(repo: ouisync.session._generated.api.RepositoryHandle, path: str)
repo: ouisync.session._generated.api.RepositoryHandle
path: str
@dataclass
class Request_RepositoryResetAccess(ouisync.session.Request):
908@dataclass
909class Request_RepositoryResetAccess(Request):
910    _tag: ClassVar[str] = "RepositoryResetAccess"
911    _shape: ClassVar[str] = "named"
912    repo: RepositoryHandle
913    token: str
Request_RepositoryResetAccess(repo: ouisync.session._generated.api.RepositoryHandle, token: str)
repo: ouisync.session._generated.api.RepositoryHandle
token: str
@dataclass
class Request_RepositorySetAccess(ouisync.session.Request):
915@dataclass
916class Request_RepositorySetAccess(Request):
917    _tag: ClassVar[str] = "RepositorySetAccess"
918    _shape: ClassVar[str] = "named"
919    repo: RepositoryHandle
920    read: AccessChange | None
921    write: AccessChange | None
Request_RepositorySetAccess( repo: ouisync.session._generated.api.RepositoryHandle, read: AccessChange | None, write: AccessChange | None)
repo: ouisync.session._generated.api.RepositoryHandle
read: AccessChange | None
write: AccessChange | None
@dataclass
class Request_RepositorySetAccessMode(ouisync.session.Request):
923@dataclass
924class Request_RepositorySetAccessMode(Request):
925    _tag: ClassVar[str] = "RepositorySetAccessMode"
926    _shape: ClassVar[str] = "named"
927    repo: RepositoryHandle
928    access_mode: AccessMode
929    local_secret: LocalSecret | None
Request_RepositorySetAccessMode( repo: ouisync.session._generated.api.RepositoryHandle, access_mode: AccessMode, local_secret: LocalSecret | None)
repo: ouisync.session._generated.api.RepositoryHandle
access_mode: AccessMode
local_secret: LocalSecret | None
@dataclass
class Request_RepositorySetBlockExpiration(ouisync.session.Request):
931@dataclass
932class Request_RepositorySetBlockExpiration(Request):
933    _tag: ClassVar[str] = "RepositorySetBlockExpiration"
934    _shape: ClassVar[str] = "named"
935    repo: RepositoryHandle
936    value: int | None
Request_RepositorySetBlockExpiration( repo: ouisync.session._generated.api.RepositoryHandle, value: int | None)
repo: ouisync.session._generated.api.RepositoryHandle
value: int | None
@dataclass
class Request_RepositorySetCredentials(ouisync.session.Request):
938@dataclass
939class Request_RepositorySetCredentials(Request):
940    _tag: ClassVar[str] = "RepositorySetCredentials"
941    _shape: ClassVar[str] = "named"
942    repo: RepositoryHandle
943    credentials: bytes
Request_RepositorySetCredentials( repo: ouisync.session._generated.api.RepositoryHandle, credentials: bytes)
repo: ouisync.session._generated.api.RepositoryHandle
credentials: bytes
@dataclass
class Request_RepositorySetDhtEnabled(ouisync.session.Request):
945@dataclass
946class Request_RepositorySetDhtEnabled(Request):
947    _tag: ClassVar[str] = "RepositorySetDhtEnabled"
948    _shape: ClassVar[str] = "named"
949    repo: RepositoryHandle
950    enabled: bool
Request_RepositorySetDhtEnabled(repo: ouisync.session._generated.api.RepositoryHandle, enabled: bool)
repo: ouisync.session._generated.api.RepositoryHandle
enabled: bool
@dataclass
class Request_RepositorySetExpiration(ouisync.session.Request):
952@dataclass
953class Request_RepositorySetExpiration(Request):
954    _tag: ClassVar[str] = "RepositorySetExpiration"
955    _shape: ClassVar[str] = "named"
956    repo: RepositoryHandle
957    value: int | None
Request_RepositorySetExpiration( repo: ouisync.session._generated.api.RepositoryHandle, value: int | None)
repo: ouisync.session._generated.api.RepositoryHandle
value: int | None
@dataclass
class Request_RepositorySetMetadata(ouisync.session.Request):
959@dataclass
960class Request_RepositorySetMetadata(Request):
961    _tag: ClassVar[str] = "RepositorySetMetadata"
962    _shape: ClassVar[str] = "named"
963    repo: RepositoryHandle
964    edits: list[MetadataEdit]
Request_RepositorySetMetadata( repo: ouisync.session._generated.api.RepositoryHandle, edits: list[MetadataEdit])
repo: ouisync.session._generated.api.RepositoryHandle
edits: list[MetadataEdit]
@dataclass
class Request_RepositorySetPexEnabled(ouisync.session.Request):
966@dataclass
967class Request_RepositorySetPexEnabled(Request):
968    _tag: ClassVar[str] = "RepositorySetPexEnabled"
969    _shape: ClassVar[str] = "named"
970    repo: RepositoryHandle
971    enabled: bool
Request_RepositorySetPexEnabled(repo: ouisync.session._generated.api.RepositoryHandle, enabled: bool)
repo: ouisync.session._generated.api.RepositoryHandle
enabled: bool
@dataclass
class Request_RepositorySetQuota(ouisync.session.Request):
973@dataclass
974class Request_RepositorySetQuota(Request):
975    _tag: ClassVar[str] = "RepositorySetQuota"
976    _shape: ClassVar[str] = "named"
977    repo: RepositoryHandle
978    value: StorageSize | None
Request_RepositorySetQuota( repo: ouisync.session._generated.api.RepositoryHandle, value: StorageSize | None)
repo: ouisync.session._generated.api.RepositoryHandle
value: StorageSize | None
@dataclass
class Request_RepositorySetSyncEnabled(ouisync.session.Request):
980@dataclass
981class Request_RepositorySetSyncEnabled(Request):
982    _tag: ClassVar[str] = "RepositorySetSyncEnabled"
983    _shape: ClassVar[str] = "named"
984    repo: RepositoryHandle
985    enabled: bool
Request_RepositorySetSyncEnabled(repo: ouisync.session._generated.api.RepositoryHandle, enabled: bool)
repo: ouisync.session._generated.api.RepositoryHandle
enabled: bool
@dataclass
class Request_RepositoryShare(ouisync.session.Request):
987@dataclass
988class Request_RepositoryShare(Request):
989    _tag: ClassVar[str] = "RepositoryShare"
990    _shape: ClassVar[str] = "named"
991    repo: RepositoryHandle
992    access_mode: AccessMode
993    local_secret: LocalSecret | None
Request_RepositoryShare( repo: ouisync.session._generated.api.RepositoryHandle, access_mode: AccessMode, local_secret: LocalSecret | None)
repo: ouisync.session._generated.api.RepositoryHandle
access_mode: AccessMode
local_secret: LocalSecret | None
@dataclass
class Request_RepositorySubscribe(ouisync.session.Request):
995@dataclass
996class Request_RepositorySubscribe(Request):
997    _tag: ClassVar[str] = "RepositorySubscribe"
998    _shape: ClassVar[str] = "named"
999    repo: RepositoryHandle
Request_RepositorySubscribe(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_RepositoryUnmount(ouisync.session.Request):
1001@dataclass
1002class Request_RepositoryUnmount(Request):
1003    _tag: ClassVar[str] = "RepositoryUnmount"
1004    _shape: ClassVar[str] = "named"
1005    repo: RepositoryHandle
Request_RepositoryUnmount(repo: ouisync.session._generated.api.RepositoryHandle)
repo: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Request_SessionAddUserProvidedPeers(ouisync.session.Request):
1007@dataclass
1008class Request_SessionAddUserProvidedPeers(Request):
1009    _tag: ClassVar[str] = "SessionAddUserProvidedPeers"
1010    _shape: ClassVar[str] = "named"
1011    addrs: list[str]
Request_SessionAddUserProvidedPeers(addrs: list[str])
addrs: list[str]
@dataclass
class Request_SessionBindMetrics(ouisync.session.Request):
1013@dataclass
1014class Request_SessionBindMetrics(Request):
1015    _tag: ClassVar[str] = "SessionBindMetrics"
1016    _shape: ClassVar[str] = "named"
1017    addr: str | None
Request_SessionBindMetrics(addr: str | None)
addr: str | None
@dataclass
class Request_SessionBindNetwork(ouisync.session.Request):
1019@dataclass
1020class Request_SessionBindNetwork(Request):
1021    _tag: ClassVar[str] = "SessionBindNetwork"
1022    _shape: ClassVar[str] = "named"
1023    addrs: list[str]
Request_SessionBindNetwork(addrs: list[str])
addrs: list[str]
@dataclass
class Request_SessionBindRemoteControl(ouisync.session.Request):
1025@dataclass
1026class Request_SessionBindRemoteControl(Request):
1027    _tag: ClassVar[str] = "SessionBindRemoteControl"
1028    _shape: ClassVar[str] = "named"
1029    addr: str | None
Request_SessionBindRemoteControl(addr: str | None)
addr: str | None
@dataclass
class Request_SessionCopy(ouisync.session.Request):
1031@dataclass
1032class Request_SessionCopy(Request):
1033    _tag: ClassVar[str] = "SessionCopy"
1034    _shape: ClassVar[str] = "named"
1035    src_repo: str | None
1036    src_path: str
1037    dst_repo: str | None
1038    dst_path: str
Request_SessionCopy( src_repo: str | None, src_path: str, dst_repo: str | None, dst_path: str)
src_repo: str | None
src_path: str
dst_repo: str | None
dst_path: str
@dataclass
class Request_SessionCreateRepository(ouisync.session.Request):
1040@dataclass
1041class Request_SessionCreateRepository(Request):
1042    _tag: ClassVar[str] = "SessionCreateRepository"
1043    _shape: ClassVar[str] = "named"
1044    path: str
1045    read_secret: SetLocalSecret | None
1046    write_secret: SetLocalSecret | None
1047    token: str | None
1048    sync_enabled: bool
1049    dht_enabled: bool
1050    pex_enabled: bool
Request_SessionCreateRepository( path: str, read_secret: SetLocalSecret | None, write_secret: SetLocalSecret | None, token: str | None, sync_enabled: bool, dht_enabled: bool, pex_enabled: bool)
path: str
read_secret: SetLocalSecret | None
write_secret: SetLocalSecret | None
token: str | None
sync_enabled: bool
dht_enabled: bool
pex_enabled: bool
@dataclass
class Request_SessionDeleteRepositoryByName(ouisync.session.Request):
1052@dataclass
1053class Request_SessionDeleteRepositoryByName(Request):
1054    _tag: ClassVar[str] = "SessionDeleteRepositoryByName"
1055    _shape: ClassVar[str] = "named"
1056    name: str
Request_SessionDeleteRepositoryByName(name: str)
name: str
@dataclass
class Request_SessionDeriveSecretKey(ouisync.session.Request):
1058@dataclass
1059class Request_SessionDeriveSecretKey(Request):
1060    _tag: ClassVar[str] = "SessionDeriveSecretKey"
1061    _shape: ClassVar[str] = "named"
1062    password: Password
1063    salt: PasswordSalt
Request_SessionDeriveSecretKey( password: Password, salt: PasswordSalt)
password: Password
salt: PasswordSalt
@dataclass
class Request_SessionDhtLookup(ouisync.session.Request):
1065@dataclass
1066class Request_SessionDhtLookup(Request):
1067    _tag: ClassVar[str] = "SessionDhtLookup"
1068    _shape: ClassVar[str] = "named"
1069    info_hash: str
1070    announce: bool
Request_SessionDhtLookup(info_hash: str, announce: bool)
info_hash: str
announce: bool
@dataclass
class Request_SessionFindRepository(ouisync.session.Request):
1072@dataclass
1073class Request_SessionFindRepository(Request):
1074    _tag: ClassVar[str] = "SessionFindRepository"
1075    _shape: ClassVar[str] = "named"
1076    name: str
Request_SessionFindRepository(name: str)
name: str
@dataclass
class Request_SessionGeneratePasswordSalt(ouisync.session.Request):
1078@dataclass
1079class Request_SessionGeneratePasswordSalt(Request):
1080    _tag: ClassVar[str] = "SessionGeneratePasswordSalt"
1081    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGenerateSecretKey(ouisync.session.Request):
1083@dataclass
1084class Request_SessionGenerateSecretKey(Request):
1085    _tag: ClassVar[str] = "SessionGenerateSecretKey"
1086    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetCurrentProtocolVersion(ouisync.session.Request):
1088@dataclass
1089class Request_SessionGetCurrentProtocolVersion(Request):
1090    _tag: ClassVar[str] = "SessionGetCurrentProtocolVersion"
1091    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetDefaultBlockExpiration(ouisync.session.Request):
1093@dataclass
1094class Request_SessionGetDefaultBlockExpiration(Request):
1095    _tag: ClassVar[str] = "SessionGetDefaultBlockExpiration"
1096    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetDefaultQuota(ouisync.session.Request):
1098@dataclass
1099class Request_SessionGetDefaultQuota(Request):
1100    _tag: ClassVar[str] = "SessionGetDefaultQuota"
1101    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetDefaultRepositoryExpiration(ouisync.session.Request):
1103@dataclass
1104class Request_SessionGetDefaultRepositoryExpiration(Request):
1105    _tag: ClassVar[str] = "SessionGetDefaultRepositoryExpiration"
1106    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetDhtRouters(ouisync.session.Request):
1108@dataclass
1109class Request_SessionGetDhtRouters(Request):
1110    _tag: ClassVar[str] = "SessionGetDhtRouters"
1111    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetExternalAddrV4(ouisync.session.Request):
1113@dataclass
1114class Request_SessionGetExternalAddrV4(Request):
1115    _tag: ClassVar[str] = "SessionGetExternalAddrV4"
1116    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetExternalAddrV6(ouisync.session.Request):
1118@dataclass
1119class Request_SessionGetExternalAddrV6(Request):
1120    _tag: ClassVar[str] = "SessionGetExternalAddrV6"
1121    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetHighestSeenProtocolVersion(ouisync.session.Request):
1123@dataclass
1124class Request_SessionGetHighestSeenProtocolVersion(Request):
1125    _tag: ClassVar[str] = "SessionGetHighestSeenProtocolVersion"
1126    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetLocalListenerAddrs(ouisync.session.Request):
1128@dataclass
1129class Request_SessionGetLocalListenerAddrs(Request):
1130    _tag: ClassVar[str] = "SessionGetLocalListenerAddrs"
1131    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetMetricsListenerAddr(ouisync.session.Request):
1133@dataclass
1134class Request_SessionGetMetricsListenerAddr(Request):
1135    _tag: ClassVar[str] = "SessionGetMetricsListenerAddr"
1136    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetMountRoot(ouisync.session.Request):
1138@dataclass
1139class Request_SessionGetMountRoot(Request):
1140    _tag: ClassVar[str] = "SessionGetMountRoot"
1141    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetNatBehavior(ouisync.session.Request):
1143@dataclass
1144class Request_SessionGetNatBehavior(Request):
1145    _tag: ClassVar[str] = "SessionGetNatBehavior"
1146    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetNetworkStats(ouisync.session.Request):
1148@dataclass
1149class Request_SessionGetNetworkStats(Request):
1150    _tag: ClassVar[str] = "SessionGetNetworkStats"
1151    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetPeers(ouisync.session.Request):
1153@dataclass
1154class Request_SessionGetPeers(Request):
1155    _tag: ClassVar[str] = "SessionGetPeers"
1156    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetRemoteControlListenerAddr(ouisync.session.Request):
1158@dataclass
1159class Request_SessionGetRemoteControlListenerAddr(Request):
1160    _tag: ClassVar[str] = "SessionGetRemoteControlListenerAddr"
1161    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetRemoteListenerAddrs(ouisync.session.Request):
1163@dataclass
1164class Request_SessionGetRemoteListenerAddrs(Request):
1165    _tag: ClassVar[str] = "SessionGetRemoteListenerAddrs"
1166    _shape: ClassVar[str] = "named"
1167    host: str
Request_SessionGetRemoteListenerAddrs(host: str)
host: str
@dataclass
class Request_SessionGetRuntimeId(ouisync.session.Request):
1169@dataclass
1170class Request_SessionGetRuntimeId(Request):
1171    _tag: ClassVar[str] = "SessionGetRuntimeId"
1172    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetShareTokenAccessMode(ouisync.session.Request):
1174@dataclass
1175class Request_SessionGetShareTokenAccessMode(Request):
1176    _tag: ClassVar[str] = "SessionGetShareTokenAccessMode"
1177    _shape: ClassVar[str] = "named"
1178    token: str
Request_SessionGetShareTokenAccessMode(token: str)
token: str
@dataclass
class Request_SessionGetShareTokenInfoHash(ouisync.session.Request):
1180@dataclass
1181class Request_SessionGetShareTokenInfoHash(Request):
1182    _tag: ClassVar[str] = "SessionGetShareTokenInfoHash"
1183    _shape: ClassVar[str] = "named"
1184    token: str
Request_SessionGetShareTokenInfoHash(token: str)
token: str
@dataclass
class Request_SessionGetShareTokenSuggestedName(ouisync.session.Request):
1186@dataclass
1187class Request_SessionGetShareTokenSuggestedName(Request):
1188    _tag: ClassVar[str] = "SessionGetShareTokenSuggestedName"
1189    _shape: ClassVar[str] = "named"
1190    token: str
Request_SessionGetShareTokenSuggestedName(token: str)
token: str
@dataclass
class Request_SessionGetStateMonitor(ouisync.session.Request):
1192@dataclass
1193class Request_SessionGetStateMonitor(Request):
1194    _tag: ClassVar[str] = "SessionGetStateMonitor"
1195    _shape: ClassVar[str] = "named"
1196    path: list[MonitorId]
Request_SessionGetStateMonitor(path: list[MonitorId])
path: list[MonitorId]
@dataclass
class Request_SessionGetStoreDirs(ouisync.session.Request):
1198@dataclass
1199class Request_SessionGetStoreDirs(Request):
1200    _tag: ClassVar[str] = "SessionGetStoreDirs"
1201    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionGetUserProvidedPeers(ouisync.session.Request):
1203@dataclass
1204class Request_SessionGetUserProvidedPeers(Request):
1205    _tag: ClassVar[str] = "SessionGetUserProvidedPeers"
1206    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionInitNetwork(ouisync.session.Request):
1208@dataclass
1209class Request_SessionInitNetwork(Request):
1210    _tag: ClassVar[str] = "SessionInitNetwork"
1211    _shape: ClassVar[str] = "named"
1212    defaults: NetworkDefaults
Request_SessionInitNetwork(defaults: NetworkDefaults)
defaults: NetworkDefaults
@dataclass
class Request_SessionInsertStoreDirs(ouisync.session.Request):
1214@dataclass
1215class Request_SessionInsertStoreDirs(Request):
1216    _tag: ClassVar[str] = "SessionInsertStoreDirs"
1217    _shape: ClassVar[str] = "named"
1218    paths: list[str]
Request_SessionInsertStoreDirs(paths: list[str])
paths: list[str]
@dataclass
class Request_SessionIsLocalDhtEnabled(ouisync.session.Request):
1220@dataclass
1221class Request_SessionIsLocalDhtEnabled(Request):
1222    _tag: ClassVar[str] = "SessionIsLocalDhtEnabled"
1223    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionIsLocalDiscoveryEnabled(ouisync.session.Request):
1225@dataclass
1226class Request_SessionIsLocalDiscoveryEnabled(Request):
1227    _tag: ClassVar[str] = "SessionIsLocalDiscoveryEnabled"
1228    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionIsPexRecvEnabled(ouisync.session.Request):
1230@dataclass
1231class Request_SessionIsPexRecvEnabled(Request):
1232    _tag: ClassVar[str] = "SessionIsPexRecvEnabled"
1233    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionIsPexSendEnabled(ouisync.session.Request):
1235@dataclass
1236class Request_SessionIsPexSendEnabled(Request):
1237    _tag: ClassVar[str] = "SessionIsPexSendEnabled"
1238    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionIsPortForwardingEnabled(ouisync.session.Request):
1240@dataclass
1241class Request_SessionIsPortForwardingEnabled(Request):
1242    _tag: ClassVar[str] = "SessionIsPortForwardingEnabled"
1243    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionListRepositories(ouisync.session.Request):
1245@dataclass
1246class Request_SessionListRepositories(Request):
1247    _tag: ClassVar[str] = "SessionListRepositories"
1248    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionMirrorExists(ouisync.session.Request):
1250@dataclass
1251class Request_SessionMirrorExists(Request):
1252    _tag: ClassVar[str] = "SessionMirrorExists"
1253    _shape: ClassVar[str] = "named"
1254    token: str
1255    host: str
Request_SessionMirrorExists(token: str, host: str)
token: str
host: str
@dataclass
class Request_SessionOpenNetworkSocketV4(ouisync.session.Request):
1257@dataclass
1258class Request_SessionOpenNetworkSocketV4(Request):
1259    _tag: ClassVar[str] = "SessionOpenNetworkSocketV4"
1260    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionOpenNetworkSocketV6(ouisync.session.Request):
1262@dataclass
1263class Request_SessionOpenNetworkSocketV6(Request):
1264    _tag: ClassVar[str] = "SessionOpenNetworkSocketV6"
1265    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionOpenNetworkStream(ouisync.session.Request):
1267@dataclass
1268class Request_SessionOpenNetworkStream(Request):
1269    _tag: ClassVar[str] = "SessionOpenNetworkStream"
1270    _shape: ClassVar[str] = "named"
1271    addr: str
1272    topic_id: TopicId
Request_SessionOpenNetworkStream(addr: str, topic_id: TopicId)
addr: str
topic_id: TopicId
@dataclass
class Request_SessionOpenRepository(ouisync.session.Request):
1274@dataclass
1275class Request_SessionOpenRepository(Request):
1276    _tag: ClassVar[str] = "SessionOpenRepository"
1277    _shape: ClassVar[str] = "named"
1278    path: str
1279    local_secret: LocalSecret | None
Request_SessionOpenRepository( path: str, local_secret: LocalSecret | None)
path: str
local_secret: LocalSecret | None
@dataclass
class Request_SessionPinDht(ouisync.session.Request):
1281@dataclass
1282class Request_SessionPinDht(Request):
1283    _tag: ClassVar[str] = "SessionPinDht"
1284    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionRemoveStoreDirs(ouisync.session.Request):
1286@dataclass
1287class Request_SessionRemoveStoreDirs(Request):
1288    _tag: ClassVar[str] = "SessionRemoveStoreDirs"
1289    _shape: ClassVar[str] = "named"
1290    paths: list[str]
Request_SessionRemoveStoreDirs(paths: list[str])
paths: list[str]
@dataclass
class Request_SessionRemoveUserProvidedPeers(ouisync.session.Request):
1292@dataclass
1293class Request_SessionRemoveUserProvidedPeers(Request):
1294    _tag: ClassVar[str] = "SessionRemoveUserProvidedPeers"
1295    _shape: ClassVar[str] = "named"
1296    addrs: list[str]
Request_SessionRemoveUserProvidedPeers(addrs: list[str])
addrs: list[str]
@dataclass
class Request_SessionSetDefaultBlockExpiration(ouisync.session.Request):
1298@dataclass
1299class Request_SessionSetDefaultBlockExpiration(Request):
1300    _tag: ClassVar[str] = "SessionSetDefaultBlockExpiration"
1301    _shape: ClassVar[str] = "named"
1302    value: int | None
Request_SessionSetDefaultBlockExpiration(value: int | None)
value: int | None
@dataclass
class Request_SessionSetDefaultQuota(ouisync.session.Request):
1304@dataclass
1305class Request_SessionSetDefaultQuota(Request):
1306    _tag: ClassVar[str] = "SessionSetDefaultQuota"
1307    _shape: ClassVar[str] = "named"
1308    value: StorageSize | None
Request_SessionSetDefaultQuota(value: StorageSize | None)
value: StorageSize | None
@dataclass
class Request_SessionSetDefaultRepositoryExpiration(ouisync.session.Request):
1310@dataclass
1311class Request_SessionSetDefaultRepositoryExpiration(Request):
1312    _tag: ClassVar[str] = "SessionSetDefaultRepositoryExpiration"
1313    _shape: ClassVar[str] = "named"
1314    value: int | None
Request_SessionSetDefaultRepositoryExpiration(value: int | None)
value: int | None
@dataclass
class Request_SessionSetDhtRouters(ouisync.session.Request):
1316@dataclass
1317class Request_SessionSetDhtRouters(Request):
1318    _tag: ClassVar[str] = "SessionSetDhtRouters"
1319    _shape: ClassVar[str] = "named"
1320    routers: list[str]
Request_SessionSetDhtRouters(routers: list[str])
routers: list[str]
@dataclass
class Request_SessionSetLocalDhtEnabled(ouisync.session.Request):
1322@dataclass
1323class Request_SessionSetLocalDhtEnabled(Request):
1324    _tag: ClassVar[str] = "SessionSetLocalDhtEnabled"
1325    _shape: ClassVar[str] = "named"
1326    enabled: bool
Request_SessionSetLocalDhtEnabled(enabled: bool)
enabled: bool
@dataclass
class Request_SessionSetLocalDiscoveryEnabled(ouisync.session.Request):
1328@dataclass
1329class Request_SessionSetLocalDiscoveryEnabled(Request):
1330    _tag: ClassVar[str] = "SessionSetLocalDiscoveryEnabled"
1331    _shape: ClassVar[str] = "named"
1332    enabled: bool
Request_SessionSetLocalDiscoveryEnabled(enabled: bool)
enabled: bool
@dataclass
class Request_SessionSetMountRoot(ouisync.session.Request):
1334@dataclass
1335class Request_SessionSetMountRoot(Request):
1336    _tag: ClassVar[str] = "SessionSetMountRoot"
1337    _shape: ClassVar[str] = "named"
1338    path: str | None
Request_SessionSetMountRoot(path: str | None)
path: str | None
@dataclass
class Request_SessionSetPexRecvEnabled(ouisync.session.Request):
1340@dataclass
1341class Request_SessionSetPexRecvEnabled(Request):
1342    _tag: ClassVar[str] = "SessionSetPexRecvEnabled"
1343    _shape: ClassVar[str] = "named"
1344    enabled: bool
Request_SessionSetPexRecvEnabled(enabled: bool)
enabled: bool
@dataclass
class Request_SessionSetPexSendEnabled(ouisync.session.Request):
1346@dataclass
1347class Request_SessionSetPexSendEnabled(Request):
1348    _tag: ClassVar[str] = "SessionSetPexSendEnabled"
1349    _shape: ClassVar[str] = "named"
1350    enabled: bool
Request_SessionSetPexSendEnabled(enabled: bool)
enabled: bool
@dataclass
class Request_SessionSetPortForwardingEnabled(ouisync.session.Request):
1352@dataclass
1353class Request_SessionSetPortForwardingEnabled(Request):
1354    _tag: ClassVar[str] = "SessionSetPortForwardingEnabled"
1355    _shape: ClassVar[str] = "named"
1356    enabled: bool
Request_SessionSetPortForwardingEnabled(enabled: bool)
enabled: bool
@dataclass
class Request_SessionSetStoreDirs(ouisync.session.Request):
1358@dataclass
1359class Request_SessionSetStoreDirs(Request):
1360    _tag: ClassVar[str] = "SessionSetStoreDirs"
1361    _shape: ClassVar[str] = "named"
1362    paths: list[str]
Request_SessionSetStoreDirs(paths: list[str])
paths: list[str]
@dataclass
class Request_SessionSubscribeToNetwork(ouisync.session.Request):
1364@dataclass
1365class Request_SessionSubscribeToNetwork(Request):
1366    _tag: ClassVar[str] = "SessionSubscribeToNetwork"
1367    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionSubscribeToStateMonitor(ouisync.session.Request):
1369@dataclass
1370class Request_SessionSubscribeToStateMonitor(Request):
1371    _tag: ClassVar[str] = "SessionSubscribeToStateMonitor"
1372    _shape: ClassVar[str] = "named"
1373    path: list[MonitorId]
Request_SessionSubscribeToStateMonitor(path: list[MonitorId])
path: list[MonitorId]
@dataclass
class Request_SessionUnpinDht(ouisync.session.Request):
1375@dataclass
1376class Request_SessionUnpinDht(Request):
1377    _tag: ClassVar[str] = "SessionUnpinDht"
1378    _shape: ClassVar[str] = "unit"
@dataclass
class Request_SessionValidateShareToken(ouisync.session.Request):
1380@dataclass
1381class Request_SessionValidateShareToken(Request):
1382    _tag: ClassVar[str] = "SessionValidateShareToken"
1383    _shape: ClassVar[str] = "named"
1384    token: str
Request_SessionValidateShareToken(token: str)
token: str
class Response:
1516class Response:
1517    _variants: ClassVar[dict[str, type]] = {}
@dataclass
class Response_AccessMode(ouisync.session.Response):
1519@dataclass
1520class Response_AccessMode(Response):
1521    _tag: ClassVar[str] = "AccessMode"
1522    _shape: ClassVar[str] = "unnamed"
1523    value: AccessMode
Response_AccessMode(value: AccessMode)
value: AccessMode
@dataclass
class Response_Bool(ouisync.session.Response):
1525@dataclass
1526class Response_Bool(Response):
1527    _tag: ClassVar[str] = "Bool"
1528    _shape: ClassVar[str] = "unnamed"
1529    value: bool
Response_Bool(value: bool)
value: bool
@dataclass
class Response_Bytes(ouisync.session.Response):
1531@dataclass
1532class Response_Bytes(Response):
1533    _tag: ClassVar[str] = "Bytes"
1534    _shape: ClassVar[str] = "unnamed"
1535    value: bytes
Response_Bytes(value: bytes)
value: bytes
@dataclass
class Response_Datagram(ouisync.session.Response):
1537@dataclass
1538class Response_Datagram(Response):
1539    _tag: ClassVar[str] = "Datagram"
1540    _shape: ClassVar[str] = "unnamed"
1541    value: Datagram
Response_Datagram(value: Datagram)
value: Datagram
@dataclass
class Response_DirectoryEntries(ouisync.session.Response):
1543@dataclass
1544class Response_DirectoryEntries(Response):
1545    _tag: ClassVar[str] = "DirectoryEntries"
1546    _shape: ClassVar[str] = "unnamed"
1547    value: list[DirectoryEntry]
Response_DirectoryEntries(value: list[DirectoryEntry])
value: list[DirectoryEntry]
@dataclass
class Response_Duration(ouisync.session.Response):
1549@dataclass
1550class Response_Duration(Response):
1551    _tag: ClassVar[str] = "Duration"
1552    _shape: ClassVar[str] = "unnamed"
1553    value: int
Response_Duration(value: int)
value: int
@dataclass
class Response_EntryType(ouisync.session.Response):
1555@dataclass
1556class Response_EntryType(Response):
1557    _tag: ClassVar[str] = "EntryType"
1558    _shape: ClassVar[str] = "unnamed"
1559    value: EntryType
Response_EntryType(value: EntryType)
value: EntryType
@dataclass
class Response_File(ouisync.session.Response):
1561@dataclass
1562class Response_File(Response):
1563    _tag: ClassVar[str] = "File"
1564    _shape: ClassVar[str] = "unnamed"
1565    value: FileHandle
Response_File(value: ouisync.session._generated.api.FileHandle)
value: ouisync.session._generated.api.FileHandle
@dataclass
class Response_JointSnapshot(ouisync.session.Response):
1567@dataclass
1568class Response_JointSnapshot(Response):
1569    _tag: ClassVar[str] = "JointSnapshot"
1570    _shape: ClassVar[str] = "unnamed"
1571    value: JointSnapshot
Response_JointSnapshot(value: JointSnapshot)
value: JointSnapshot
@dataclass
class Response_NatBehavior(ouisync.session.Response):
1573@dataclass
1574class Response_NatBehavior(Response):
1575    _tag: ClassVar[str] = "NatBehavior"
1576    _shape: ClassVar[str] = "unnamed"
1577    value: NatBehavior
Response_NatBehavior(value: NatBehavior)
value: NatBehavior
@dataclass
class Response_NetworkEvent(ouisync.session.Response):
1579@dataclass
1580class Response_NetworkEvent(Response):
1581    _tag: ClassVar[str] = "NetworkEvent"
1582    _shape: ClassVar[str] = "unnamed"
1583    value: NetworkEvent
Response_NetworkEvent(value: NetworkEvent)
value: NetworkEvent
@dataclass
class Response_NetworkSocket(ouisync.session.Response):
1585@dataclass
1586class Response_NetworkSocket(Response):
1587    _tag: ClassVar[str] = "NetworkSocket"
1588    _shape: ClassVar[str] = "unnamed"
1589    value: NetworkSocketHandle
Response_NetworkSocket(value: ouisync.session._generated.api.NetworkSocketHandle)
value: ouisync.session._generated.api.NetworkSocketHandle
@dataclass
class Response_NetworkStream(ouisync.session.Response):
1591@dataclass
1592class Response_NetworkStream(Response):
1593    _tag: ClassVar[str] = "NetworkStream"
1594    _shape: ClassVar[str] = "unnamed"
1595    value: NetworkStreamHandle
Response_NetworkStream(value: ouisync.session._generated.api.NetworkStreamHandle)
value: ouisync.session._generated.api.NetworkStreamHandle
@dataclass
class Response_None(ouisync.session.Response):
1597@dataclass
1598class Response_None(Response):
1599    _tag: ClassVar[str] = "None"
1600    _shape: ClassVar[str] = "unit"
@dataclass
class Response_PasswordSalt(ouisync.session.Response):
1602@dataclass
1603class Response_PasswordSalt(Response):
1604    _tag: ClassVar[str] = "PasswordSalt"
1605    _shape: ClassVar[str] = "unnamed"
1606    value: PasswordSalt
Response_PasswordSalt(value: PasswordSalt)
value: PasswordSalt
@dataclass
class Response_Path(ouisync.session.Response):
1608@dataclass
1609class Response_Path(Response):
1610    _tag: ClassVar[str] = "Path"
1611    _shape: ClassVar[str] = "unnamed"
1612    value: str
Response_Path(value: str)
value: str
@dataclass
class Response_Paths(ouisync.session.Response):
1614@dataclass
1615class Response_Paths(Response):
1616    _tag: ClassVar[str] = "Paths"
1617    _shape: ClassVar[str] = "unnamed"
1618    value: list[str]
Response_Paths(value: list[str])
value: list[str]
@dataclass
class Response_PeerAddr(ouisync.session.Response):
1620@dataclass
1621class Response_PeerAddr(Response):
1622    _tag: ClassVar[str] = "PeerAddr"
1623    _shape: ClassVar[str] = "unnamed"
1624    value: str
Response_PeerAddr(value: str)
value: str
@dataclass
class Response_PeerAddrs(ouisync.session.Response):
1626@dataclass
1627class Response_PeerAddrs(Response):
1628    _tag: ClassVar[str] = "PeerAddrs"
1629    _shape: ClassVar[str] = "unnamed"
1630    value: list[str]
Response_PeerAddrs(value: list[str])
value: list[str]
@dataclass
class Response_PeerInfos(ouisync.session.Response):
1632@dataclass
1633class Response_PeerInfos(Response):
1634    _tag: ClassVar[str] = "PeerInfos"
1635    _shape: ClassVar[str] = "unnamed"
1636    value: list[PeerInfo]
Response_PeerInfos(value: list[PeerInfo])
value: list[PeerInfo]
@dataclass
class Response_Progress(ouisync.session.Response):
1638@dataclass
1639class Response_Progress(Response):
1640    _tag: ClassVar[str] = "Progress"
1641    _shape: ClassVar[str] = "unnamed"
1642    value: Progress
Response_Progress(value: Progress)
value: Progress
@dataclass
class Response_PublicRuntimeId(ouisync.session.Response):
1644@dataclass
1645class Response_PublicRuntimeId(Response):
1646    _tag: ClassVar[str] = "PublicRuntimeId"
1647    _shape: ClassVar[str] = "unnamed"
1648    value: PublicRuntimeId
Response_PublicRuntimeId(value: PublicRuntimeId)
@dataclass
class Response_QuotaInfo(ouisync.session.Response):
1650@dataclass
1651class Response_QuotaInfo(Response):
1652    _tag: ClassVar[str] = "QuotaInfo"
1653    _shape: ClassVar[str] = "unnamed"
1654    value: QuotaInfo
Response_QuotaInfo(value: QuotaInfo)
value: QuotaInfo
@dataclass
class Response_Repositories(ouisync.session.Response):
1656@dataclass
1657class Response_Repositories(Response):
1658    _tag: ClassVar[str] = "Repositories"
1659    _shape: ClassVar[str] = "unnamed"
1660    value: dict[str, RepositoryHandle]
Response_Repositories(value: dict[str, ouisync.session._generated.api.RepositoryHandle])
value: dict[str, ouisync.session._generated.api.RepositoryHandle]
@dataclass
class Response_Repository(ouisync.session.Response):
1662@dataclass
1663class Response_Repository(Response):
1664    _tag: ClassVar[str] = "Repository"
1665    _shape: ClassVar[str] = "unnamed"
1666    value: RepositoryHandle
Response_Repository(value: ouisync.session._generated.api.RepositoryHandle)
value: ouisync.session._generated.api.RepositoryHandle
@dataclass
class Response_SecretKey(ouisync.session.Response):
1668@dataclass
1669class Response_SecretKey(Response):
1670    _tag: ClassVar[str] = "SecretKey"
1671    _shape: ClassVar[str] = "unnamed"
1672    value: SecretKey
Response_SecretKey(value: SecretKey)
value: SecretKey
@dataclass
class Response_ShareToken(ouisync.session.Response):
1674@dataclass
1675class Response_ShareToken(Response):
1676    _tag: ClassVar[str] = "ShareToken"
1677    _shape: ClassVar[str] = "unnamed"
1678    value: str
Response_ShareToken(value: str)
value: str
@dataclass
class Response_SocketAddr(ouisync.session.Response):
1680@dataclass
1681class Response_SocketAddr(Response):
1682    _tag: ClassVar[str] = "SocketAddr"
1683    _shape: ClassVar[str] = "unnamed"
1684    value: str
Response_SocketAddr(value: str)
value: str
@dataclass
class Response_StateMonitor(ouisync.session.Response):
1686@dataclass
1687class Response_StateMonitor(Response):
1688    _tag: ClassVar[str] = "StateMonitor"
1689    _shape: ClassVar[str] = "unnamed"
1690    value: typing.Any
Response_StateMonitor(value: Any)
value: Any
@dataclass
class Response_Stats(ouisync.session.Response):
1692@dataclass
1693class Response_Stats(Response):
1694    _tag: ClassVar[str] = "Stats"
1695    _shape: ClassVar[str] = "unnamed"
1696    value: Stats
Response_Stats(value: Stats)
value: Stats
@dataclass
class Response_StorageSize(ouisync.session.Response):
1698@dataclass
1699class Response_StorageSize(Response):
1700    _tag: ClassVar[str] = "StorageSize"
1701    _shape: ClassVar[str] = "unnamed"
1702    value: StorageSize
Response_StorageSize(value: StorageSize)
value: StorageSize
@dataclass
class Response_String(ouisync.session.Response):
1704@dataclass
1705class Response_String(Response):
1706    _tag: ClassVar[str] = "String"
1707    _shape: ClassVar[str] = "unnamed"
1708    value: str
Response_String(value: str)
value: str
@dataclass
class Response_Strings(ouisync.session.Response):
1710@dataclass
1711class Response_Strings(Response):
1712    _tag: ClassVar[str] = "Strings"
1713    _shape: ClassVar[str] = "unnamed"
1714    value: list[str]
Response_Strings(value: list[str])
value: list[str]
@dataclass
class Response_U16(ouisync.session.Response):
1716@dataclass
1717class Response_U16(Response):
1718    _tag: ClassVar[str] = "U16"
1719    _shape: ClassVar[str] = "unnamed"
1720    value: int
Response_U16(value: int)
value: int
@dataclass
class Response_U64(ouisync.session.Response):
1722@dataclass
1723class Response_U64(Response):
1724    _tag: ClassVar[str] = "U64"
1725    _shape: ClassVar[str] = "unnamed"
1726    value: int
Response_U64(value: int)
value: int
@dataclass
class Response_Unit(ouisync.session.Response):
1728@dataclass
1729class Response_Unit(Response):
1730    _tag: ClassVar[str] = "Unit"
1731    _shape: ClassVar[str] = "unit"
@dataclass
class SecretKey:
14@dataclass
15class SecretKey:
16    """
17    Symmetric encryption/decryption secret key.
18
19    Note: this implementation tries to prevent certain types of attacks by making sure the
20    underlying sensitive key material is always stored at most in one place. This is achieved by
21    putting it on the heap which means it is not moved when the key itself is moved which could
22    otherwise leave a copy of the data in memory. Additionally, the data is behind a `Arc` which
23    means the key can be cheaply cloned without actually cloning the data. Finally, the data is
24    scrambled (overwritten with zeros) when the key is dropped to make sure it does not stay in
25    the memory past its lifetime.
26    """
27    _shape: ClassVar[str] = "unnamed"
28    value: bytes
29    def __repr__(self) -> str:
30        return f"{type(self).__name__}(******)"

Symmetric encryption/decryption secret key.

Note: this implementation tries to prevent certain types of attacks by making sure the underlying sensitive key material is always stored at most in one place. This is achieved by putting it on the heap which means it is not moved when the key itself is moved which could otherwise leave a copy of the data in memory. Additionally, the data is behind a Arc which means the key can be cheaply cloned without actually cloning the data. Finally, the data is scrambled (overwritten with zeros) when the key is dropped to make sure it does not stay in the memory past its lifetime.

SecretKey(value: bytes)
value: bytes
class Session:
1772class Session:
1773    def __init__(self, client: Client):
1774        """@private"""
1775        self._client = client
1776
1777    async def add_user_provided_peers(
1778        self,
1779        *,
1780        addrs: list[str],
1781    ):
1782        """
1783        Adds peers to connect to.
1784
1785        Normally peers are discovered automatically (using Bittorrent DHT, Peer exchange or Local
1786        discovery) but this function is useful in case when the discovery is not available for any
1787        reason (e.g. in an isolated network).
1788
1789        Note that peers added with this function are remembered across restarts. To forget peers,
1790        use [Self::session_remove_user_provided_peers].
1791        """
1792        request = Request_SessionAddUserProvidedPeers(
1793            addrs,
1794        )
1795        response = await self._client.invoke(request)
1796        if isinstance(response, Response_Unit):
1797            return
1798        raise UnexpectedResponse()
1799
1800    async def bind_metrics(
1801        self,
1802        *,
1803        addr: str | None = None,
1804    ):
1805        request = Request_SessionBindMetrics(
1806            addr,
1807        )
1808        response = await self._client.invoke(request)
1809        if isinstance(response, Response_Unit):
1810            return
1811        raise UnexpectedResponse()
1812
1813    async def bind_network(
1814        self,
1815        *,
1816        addrs: list[str],
1817    ):
1818        """
1819        Binds the network listeners to the specified interfaces.
1820
1821        Up to four listeners can be bound, one for each combination of protocol (TCP or QUIC) and IP
1822        family (IPv4 or IPv6). The format of the interfaces is "PROTO/IP:PORT" where PROTO is "tcp"
1823        or "quic". If IP is IPv6, it needs to be enclosed in square brackets.
1824
1825        If port is `0`, binds to a random port initially but on subsequent starts tries to use the
1826        same port (unless it's already taken). This can be useful to configuring port forwarding.
1827        """
1828        request = Request_SessionBindNetwork(
1829            addrs,
1830        )
1831        response = await self._client.invoke(request)
1832        if isinstance(response, Response_Unit):
1833            return
1834        raise UnexpectedResponse()
1835
1836    async def bind_remote_control(
1837        self,
1838        *,
1839        addr: str | None = None,
1840    ) -> int:
1841        request = Request_SessionBindRemoteControl(
1842            addr,
1843        )
1844        response = await self._client.invoke(request)
1845        if isinstance(response, Response_U16):
1846            return response.value
1847        raise UnexpectedResponse()
1848
1849    async def copy(
1850        self,
1851        *,
1852        src_repo: str | None = None,
1853        src_path: str,
1854        dst_repo: str | None = None,
1855        dst_path: str,
1856    ):
1857        """
1858        Copy file or directory into, from or between repositories
1859
1860        - `src_repo`: Name of the repository from which file will be copied.
1861        - `src_path`: Path of to the entry to be copied. If `src_repo` is set, the `src_path` is
1862          relative to the corresponding repository root. If `src_repo` is null, `src_path` is
1863          interpreted as path on the local file system.
1864        - `dst_repo`: Name of the repository into which the entry will be copied.
1865        - `dst_path`: Destination entry
1866        """
1867        request = Request_SessionCopy(
1868            src_repo,
1869            src_path,
1870            dst_repo,
1871            dst_path,
1872        )
1873        response = await self._client.invoke(request)
1874        if isinstance(response, Response_Unit):
1875            return
1876        raise UnexpectedResponse()
1877
1878    async def create_repository(
1879        self,
1880        *,
1881        path: str,
1882        read_secret: SetLocalSecret | None = None,
1883        write_secret: SetLocalSecret | None = None,
1884        token: str | None = None,
1885        sync_enabled: bool = False,
1886        dht_enabled: bool = False,
1887        pex_enabled: bool = False,
1888    ) -> Repository:
1889        """
1890        Creates a new repository.
1891
1892        - `path`: path to the repository file or name of the repository.
1893        - `read_secret`: local secret for reading the repository on this device only. Do not share
1894          with peers!. If null, the repo won't be protected and anyone with physical access to the
1895          device will be able to read it.
1896        - `write_secret`: local secret for writing to the repository on this device only. Do not
1897          share with peers! Can be the same as `read_secret` if one wants to use only one secret
1898          for both reading and writing.  Separate secrets are useful for plausible deniability. If
1899          both `read_secret` and `write_secret` are `None`, the repo won't be protected and anyone
1900          with physical access to the device will be able to read and write to it. If `read_secret`
1901          is not `None` but `write_secret` is `None`, the repo won't be writable from this device.
1902        - `token`: used to share repositories between devices. If not `None`, this repo will be
1903          linked with the repos with the same token on other devices. See also
1904          [Self::repository_share]. This also determines the maximal access mode the repo can be
1905          opened in. If `None`, it's *write* mode.
1906        """
1907        request = Request_SessionCreateRepository(
1908            path,
1909            read_secret,
1910            write_secret,
1911            token,
1912            sync_enabled,
1913            dht_enabled,
1914            pex_enabled,
1915        )
1916        response = await self._client.invoke(request)
1917        if isinstance(response, Response_Repository):
1918            return Repository(self._client, response.value)
1919        raise UnexpectedResponse()
1920
1921    async def delete_repository_by_name(
1922        self,
1923        *,
1924        name: str,
1925    ):
1926        """Delete a repository with the given name."""
1927        request = Request_SessionDeleteRepositoryByName(
1928            name,
1929        )
1930        response = await self._client.invoke(request)
1931        if isinstance(response, Response_Unit):
1932            return
1933        raise UnexpectedResponse()
1934
1935    async def derive_secret_key(
1936        self,
1937        *,
1938        password: Password,
1939        salt: PasswordSalt,
1940    ) -> SecretKey:
1941        request = Request_SessionDeriveSecretKey(
1942            password,
1943            salt,
1944        )
1945        response = await self._client.invoke(request)
1946        if isinstance(response, Response_SecretKey):
1947            return response.value
1948        raise UnexpectedResponse()
1949
1950    async def find_repository(
1951        self,
1952        *,
1953        name: str,
1954    ) -> Repository:
1955        request = Request_SessionFindRepository(
1956            name,
1957        )
1958        response = await self._client.invoke(request)
1959        if isinstance(response, Response_Repository):
1960            return Repository(self._client, response.value)
1961        raise UnexpectedResponse()
1962
1963    async def generate_password_salt(
1964        self,
1965    ) -> PasswordSalt:
1966        request = Request_SessionGeneratePasswordSalt()
1967        response = await self._client.invoke(request)
1968        if isinstance(response, Response_PasswordSalt):
1969            return response.value
1970        raise UnexpectedResponse()
1971
1972    async def generate_secret_key(
1973        self,
1974    ) -> SecretKey:
1975        request = Request_SessionGenerateSecretKey()
1976        response = await self._client.invoke(request)
1977        if isinstance(response, Response_SecretKey):
1978            return response.value
1979        raise UnexpectedResponse()
1980
1981    async def get_current_protocol_version(
1982        self,
1983    ) -> int:
1984        """
1985        Returns our Ouisync protocol version.
1986
1987        In order to establish connections with peers, they must use the same protocol version as
1988        us.
1989
1990        See also [Self::session_get_highest_seen_protocol_version]
1991        """
1992        request = Request_SessionGetCurrentProtocolVersion()
1993        response = await self._client.invoke(request)
1994        if isinstance(response, Response_U64):
1995            return response.value
1996        raise UnexpectedResponse()
1997
1998    async def get_default_block_expiration(
1999        self,
2000    ) -> int | None:
2001        request = Request_SessionGetDefaultBlockExpiration()
2002        response = await self._client.invoke(request)
2003        if isinstance(response, Response_Duration):
2004            return response.value
2005        if isinstance(response, Response_None):
2006            return None
2007        raise UnexpectedResponse()
2008
2009    async def get_default_quota(
2010        self,
2011    ) -> StorageSize | None:
2012        request = Request_SessionGetDefaultQuota()
2013        response = await self._client.invoke(request)
2014        if isinstance(response, Response_StorageSize):
2015            return response.value
2016        if isinstance(response, Response_None):
2017            return None
2018        raise UnexpectedResponse()
2019
2020    async def get_default_repository_expiration(
2021        self,
2022    ) -> int | None:
2023        request = Request_SessionGetDefaultRepositoryExpiration()
2024        response = await self._client.invoke(request)
2025        if isinstance(response, Response_Duration):
2026            return response.value
2027        if isinstance(response, Response_None):
2028            return None
2029        raise UnexpectedResponse()
2030
2031    async def get_dht_routers(
2032        self,
2033    ) -> list[str]:
2034        """
2035        Returns the current DHT routers (bootstrap nodes). If the routers haven't been changed by
2036        the user yet, returns the default routers.
2037        """
2038        request = Request_SessionGetDhtRouters()
2039        response = await self._client.invoke(request)
2040        if isinstance(response, Response_Strings):
2041            return response.value
2042        raise UnexpectedResponse()
2043
2044    async def get_external_addr_v4(
2045        self,
2046    ) -> str | None:
2047        request = Request_SessionGetExternalAddrV4()
2048        response = await self._client.invoke(request)
2049        if isinstance(response, Response_SocketAddr):
2050            return response.value
2051        if isinstance(response, Response_None):
2052            return None
2053        raise UnexpectedResponse()
2054
2055    async def get_external_addr_v6(
2056        self,
2057    ) -> str | None:
2058        request = Request_SessionGetExternalAddrV6()
2059        response = await self._client.invoke(request)
2060        if isinstance(response, Response_SocketAddr):
2061            return response.value
2062        if isinstance(response, Response_None):
2063            return None
2064        raise UnexpectedResponse()
2065
2066    async def get_highest_seen_protocol_version(
2067        self,
2068    ) -> int:
2069        """
2070        Returns the highest protocol version of all known peers.
2071
2072        If this is higher than [our version](Self::session_get_current_protocol_version) it likely
2073        means we are using an outdated version of Ouisync. When a peer with higher protocol version
2074        is found, a [NetworkEvent::ProtocolVersionMismatch] is emitted.
2075        """
2076        request = Request_SessionGetHighestSeenProtocolVersion()
2077        response = await self._client.invoke(request)
2078        if isinstance(response, Response_U64):
2079            return response.value
2080        raise UnexpectedResponse()
2081
2082    async def get_local_listener_addrs(
2083        self,
2084    ) -> list[str]:
2085        """Returns the listener addresses of this Ouisync instance."""
2086        request = Request_SessionGetLocalListenerAddrs()
2087        response = await self._client.invoke(request)
2088        if isinstance(response, Response_PeerAddrs):
2089            return response.value
2090        raise UnexpectedResponse()
2091
2092    async def get_metrics_listener_addr(
2093        self,
2094    ) -> str | None:
2095        request = Request_SessionGetMetricsListenerAddr()
2096        response = await self._client.invoke(request)
2097        if isinstance(response, Response_SocketAddr):
2098            return response.value
2099        if isinstance(response, Response_None):
2100            return None
2101        raise UnexpectedResponse()
2102
2103    async def get_mount_root(
2104        self,
2105    ) -> str | None:
2106        request = Request_SessionGetMountRoot()
2107        response = await self._client.invoke(request)
2108        if isinstance(response, Response_Path):
2109            return response.value
2110        if isinstance(response, Response_None):
2111            return None
2112        raise UnexpectedResponse()
2113
2114    async def get_nat_behavior(
2115        self,
2116    ) -> NatBehavior | None:
2117        request = Request_SessionGetNatBehavior()
2118        response = await self._client.invoke(request)
2119        if isinstance(response, Response_NatBehavior):
2120            return response.value
2121        if isinstance(response, Response_None):
2122            return None
2123        raise UnexpectedResponse()
2124
2125    async def get_network_stats(
2126        self,
2127    ) -> Stats:
2128        request = Request_SessionGetNetworkStats()
2129        response = await self._client.invoke(request)
2130        if isinstance(response, Response_Stats):
2131            return response.value
2132        raise UnexpectedResponse()
2133
2134    async def get_peers(
2135        self,
2136    ) -> list[PeerInfo]:
2137        """
2138        Returns info about all known peers (both discovered and explicitly added).
2139
2140        When the set of known peers changes, a [NetworkEvent::PeerSetChange] is emitted. Calling
2141        this function afterwards returns the new peer info.
2142        """
2143        request = Request_SessionGetPeers()
2144        response = await self._client.invoke(request)
2145        if isinstance(response, Response_PeerInfos):
2146            return response.value
2147        raise UnexpectedResponse()
2148
2149    async def get_remote_control_listener_addr(
2150        self,
2151    ) -> str | None:
2152        request = Request_SessionGetRemoteControlListenerAddr()
2153        response = await self._client.invoke(request)
2154        if isinstance(response, Response_SocketAddr):
2155            return response.value
2156        if isinstance(response, Response_None):
2157            return None
2158        raise UnexpectedResponse()
2159
2160    async def get_remote_listener_addrs(
2161        self,
2162        *,
2163        host: str,
2164    ) -> list[str]:
2165        """
2166        Returns the listener addresses of the specified remote Ouisync instance. Works only if the
2167        remote control API is enabled on the remote instance. Typically used with cache servers.
2168        """
2169        request = Request_SessionGetRemoteListenerAddrs(
2170            host,
2171        )
2172        response = await self._client.invoke(request)
2173        if isinstance(response, Response_PeerAddrs):
2174            return response.value
2175        raise UnexpectedResponse()
2176
2177    async def get_runtime_id(
2178        self,
2179    ) -> PublicRuntimeId:
2180        """
2181        Returns the runtime id of this Ouisync instance.
2182
2183        The runtime id is a unique identifier of this instance which is randomly generated every
2184        time Ouisync starts.
2185        """
2186        request = Request_SessionGetRuntimeId()
2187        response = await self._client.invoke(request)
2188        if isinstance(response, Response_PublicRuntimeId):
2189            return response.value
2190        raise UnexpectedResponse()
2191
2192    async def get_share_token_access_mode(
2193        self,
2194        *,
2195        token: str,
2196    ) -> AccessMode:
2197        """Returns the access mode that the given token grants."""
2198        request = Request_SessionGetShareTokenAccessMode(
2199            token,
2200        )
2201        response = await self._client.invoke(request)
2202        if isinstance(response, Response_AccessMode):
2203            return response.value
2204        raise UnexpectedResponse()
2205
2206    async def get_share_token_info_hash(
2207        self,
2208        *,
2209        token: str,
2210    ) -> str:
2211        """
2212        Return the info-hash of the repository corresponding to the given token, formatted as hex
2213        string.
2214
2215        See also: [repository_get_info_hash]
2216        """
2217        request = Request_SessionGetShareTokenInfoHash(
2218            token,
2219        )
2220        response = await self._client.invoke(request)
2221        if isinstance(response, Response_String):
2222            return response.value
2223        raise UnexpectedResponse()
2224
2225    async def get_share_token_suggested_name(
2226        self,
2227        *,
2228        token: str,
2229    ) -> str:
2230        """Returns the suggested name for the repository corresponding to the given token."""
2231        request = Request_SessionGetShareTokenSuggestedName(
2232            token,
2233        )
2234        response = await self._client.invoke(request)
2235        if isinstance(response, Response_String):
2236            return response.value
2237        raise UnexpectedResponse()
2238
2239    async def get_state_monitor(
2240        self,
2241        *,
2242        path: list[MonitorId],
2243    ) -> typing.Any | None:
2244        request = Request_SessionGetStateMonitor(
2245            path,
2246        )
2247        response = await self._client.invoke(request)
2248        if isinstance(response, Response_StateMonitor):
2249            return response.value
2250        if isinstance(response, Response_None):
2251            return None
2252        raise UnexpectedResponse()
2253
2254    async def get_store_dirs(
2255        self,
2256    ) -> list[str]:
2257        request = Request_SessionGetStoreDirs()
2258        response = await self._client.invoke(request)
2259        if isinstance(response, Response_Paths):
2260            return response.value
2261        raise UnexpectedResponse()
2262
2263    async def get_user_provided_peers(
2264        self,
2265    ) -> list[str]:
2266        request = Request_SessionGetUserProvidedPeers()
2267        response = await self._client.invoke(request)
2268        if isinstance(response, Response_PeerAddrs):
2269            return response.value
2270        raise UnexpectedResponse()
2271
2272    async def init_network(
2273        self,
2274        *,
2275        defaults: NetworkDefaults,
2276    ):
2277        """
2278        Initializes the network according to the stored configuration. If a particular network
2279        parameter is not yet configured, falls back to the given defaults.
2280        """
2281        request = Request_SessionInitNetwork(
2282            defaults,
2283        )
2284        response = await self._client.invoke(request)
2285        if isinstance(response, Response_Unit):
2286            return
2287        raise UnexpectedResponse()
2288
2289    async def insert_store_dirs(
2290        self,
2291        *,
2292        paths: list[str],
2293    ):
2294        request = Request_SessionInsertStoreDirs(
2295            paths,
2296        )
2297        response = await self._client.invoke(request)
2298        if isinstance(response, Response_Unit):
2299            return
2300        raise UnexpectedResponse()
2301
2302    async def is_local_dht_enabled(
2303        self,
2304    ) -> bool:
2305        """Checks whether local DHT is enabled."""
2306        request = Request_SessionIsLocalDhtEnabled()
2307        response = await self._client.invoke(request)
2308        if isinstance(response, Response_Bool):
2309            return response.value
2310        raise UnexpectedResponse()
2311
2312    async def is_local_discovery_enabled(
2313        self,
2314    ) -> bool:
2315        """Is local discovery enabled?"""
2316        request = Request_SessionIsLocalDiscoveryEnabled()
2317        response = await self._client.invoke(request)
2318        if isinstance(response, Response_Bool):
2319            return response.value
2320        raise UnexpectedResponse()
2321
2322    async def is_pex_recv_enabled(
2323        self,
2324    ) -> bool:
2325        """Checks whether accepting peers discovered on the peer exchange is enabled."""
2326        request = Request_SessionIsPexRecvEnabled()
2327        response = await self._client.invoke(request)
2328        if isinstance(response, Response_Bool):
2329            return response.value
2330        raise UnexpectedResponse()
2331
2332    async def is_pex_send_enabled(
2333        self,
2334    ) -> bool:
2335        request = Request_SessionIsPexSendEnabled()
2336        response = await self._client.invoke(request)
2337        if isinstance(response, Response_Bool):
2338            return response.value
2339        raise UnexpectedResponse()
2340
2341    async def is_port_forwarding_enabled(
2342        self,
2343    ) -> bool:
2344        """Is port forwarding (UPnP) enabled?"""
2345        request = Request_SessionIsPortForwardingEnabled()
2346        response = await self._client.invoke(request)
2347        if isinstance(response, Response_Bool):
2348            return response.value
2349        raise UnexpectedResponse()
2350
2351    async def list_repositories(
2352        self,
2353    ) -> dict[str, Repository]:
2354        request = Request_SessionListRepositories()
2355        response = await self._client.invoke(request)
2356        if isinstance(response, Response_Repositories):
2357            return {k: Repository(self._client, v) for k, v in response.value.items()}
2358        raise UnexpectedResponse()
2359
2360    async def mirror_exists(
2361        self,
2362        *,
2363        token: str,
2364        host: str,
2365    ) -> bool:
2366        request = Request_SessionMirrorExists(
2367            token,
2368            host,
2369        )
2370        response = await self._client.invoke(request)
2371        if isinstance(response, Response_Bool):
2372            return response.value
2373        raise UnexpectedResponse()
2374
2375    async def open_network_socket_v4(
2376        self,
2377    ) -> NetworkSocket | None:
2378        """
2379        Opens a side channel to the underlying IPv4 UDP socket. The side channel is used to
2380        send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is
2381        useful to share the socket between different protocols for hole punching.
2382
2383        Returns `None` if QUIC IPv4 endpoint isn't bound (see [Self::session_bind_network]).
2384        """
2385        request = Request_SessionOpenNetworkSocketV4()
2386        response = await self._client.invoke(request)
2387        if isinstance(response, Response_NetworkSocket):
2388            return NetworkSocket(self._client, response.value)
2389        if isinstance(response, Response_None):
2390            return None
2391        raise UnexpectedResponse()
2392
2393    async def open_network_socket_v6(
2394        self,
2395    ) -> NetworkSocket | None:
2396        """
2397        Opens a side channel to the underlying IPv6 UDP socket. The side channel is used to
2398        send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is
2399        useful to share the socket between different protocols for hole punching.
2400
2401        Returns `None` if QUIC IPv6 endpoint isn't bound (see [Self::session_bind_network]).
2402        """
2403        request = Request_SessionOpenNetworkSocketV6()
2404        response = await self._client.invoke(request)
2405        if isinstance(response, Response_NetworkSocket):
2406            return NetworkSocket(self._client, response.value)
2407        if isinstance(response, Response_None):
2408            return None
2409        raise UnexpectedResponse()
2410
2411    async def open_network_stream(
2412        self,
2413        *,
2414        addr: str,
2415        topic_id: TopicId,
2416    ) -> NetworkStream:
2417        """Opens a raw byte streams to the given peer, bound to the given topic."""
2418        request = Request_SessionOpenNetworkStream(
2419            addr,
2420            topic_id,
2421        )
2422        response = await self._client.invoke(request)
2423        if isinstance(response, Response_NetworkStream):
2424            return NetworkStream(self._client, response.value)
2425        raise UnexpectedResponse()
2426
2427    async def open_repository(
2428        self,
2429        *,
2430        path: str,
2431        local_secret: LocalSecret | None = None,
2432    ) -> Repository:
2433        """
2434        Opens an existing repository.
2435
2436        - `path`: path to the local file the repo is stored in.
2437        - `local_secret`: a local secret. See the `read_secret` and `write_secret` params in
2438          [Self::session_create_repository] for more details. If this repo uses local secret
2439          (s), this determines the access mode the repo is opened in: `read_secret` opens it
2440          in *read* mode, `write_secret` opens it in *write* mode and no secret or wrong secret
2441          opens it in *blind* mode. If this repo doesn't use local secret(s), the repo is opened in
2442          the maximal mode specified when the repo was created.
2443        """
2444        request = Request_SessionOpenRepository(
2445            path,
2446            local_secret,
2447        )
2448        response = await self._client.invoke(request)
2449        if isinstance(response, Response_Repository):
2450            return Repository(self._client, response.value)
2451        raise UnexpectedResponse()
2452
2453    async def pin_dht(
2454        self,
2455    ):
2456        """
2457        Pin the DHT to ensure it starts and remains running even when there are no active DHT
2458        lookups and no DHT-enabled repositories. This is useful to prevent the DHT restarting
2459        between the lookups (which could be slow).
2460        """
2461        request = Request_SessionPinDht()
2462        response = await self._client.invoke(request)
2463        if isinstance(response, Response_Unit):
2464            return
2465        raise UnexpectedResponse()
2466
2467    async def remove_store_dirs(
2468        self,
2469        *,
2470        paths: list[str],
2471    ):
2472        request = Request_SessionRemoveStoreDirs(
2473            paths,
2474        )
2475        response = await self._client.invoke(request)
2476        if isinstance(response, Response_Unit):
2477            return
2478        raise UnexpectedResponse()
2479
2480    async def remove_user_provided_peers(
2481        self,
2482        *,
2483        addrs: list[str],
2484    ):
2485        """Removes peers previously added with [Self::session_add_user_provided_peers]."""
2486        request = Request_SessionRemoveUserProvidedPeers(
2487            addrs,
2488        )
2489        response = await self._client.invoke(request)
2490        if isinstance(response, Response_Unit):
2491            return
2492        raise UnexpectedResponse()
2493
2494    async def set_default_block_expiration(
2495        self,
2496        *,
2497        value: int | None = None,
2498    ):
2499        request = Request_SessionSetDefaultBlockExpiration(
2500            value,
2501        )
2502        response = await self._client.invoke(request)
2503        if isinstance(response, Response_Unit):
2504            return
2505        raise UnexpectedResponse()
2506
2507    async def set_default_quota(
2508        self,
2509        *,
2510        value: StorageSize | None = None,
2511    ):
2512        request = Request_SessionSetDefaultQuota(
2513            value,
2514        )
2515        response = await self._client.invoke(request)
2516        if isinstance(response, Response_Unit):
2517            return
2518        raise UnexpectedResponse()
2519
2520    async def set_default_repository_expiration(
2521        self,
2522        *,
2523        value: int | None = None,
2524    ):
2525        request = Request_SessionSetDefaultRepositoryExpiration(
2526            value,
2527        )
2528        response = await self._client.invoke(request)
2529        if isinstance(response, Response_Unit):
2530            return
2531        raise UnexpectedResponse()
2532
2533    async def set_dht_routers(
2534        self,
2535        *,
2536        routers: list[str],
2537    ):
2538        """
2539        Changes the DHT routers (bootstrap nodes), rebootstraps the DHTs and restart any ongoing
2540        lookups. If this is not called, a default set of routers is used. Each router is specified
2541        as hostname + port or ip address + port.
2542        """
2543        request = Request_SessionSetDhtRouters(
2544            routers,
2545        )
2546        response = await self._client.invoke(request)
2547        if isinstance(response, Response_Unit):
2548            return
2549        raise UnexpectedResponse()
2550
2551    async def set_local_dht_enabled(
2552        self,
2553        *,
2554        enabled: bool = False,
2555    ):
2556        """
2557        Set whether DHT on the local network or localhost is allowed. By default this is `false`
2558        because DHT is a global discovery mechanism and finding a local peer on it is unexpected
2559        (and could indicate malice). However, is some situations it's still useful to enable it
2560        (typically for testing).
2561
2562        Note: this option is currently experimental and unstable (semver extempt). It's possible it
2563        will be removed in the future.
2564        """
2565        request = Request_SessionSetLocalDhtEnabled(
2566            enabled,
2567        )
2568        response = await self._client.invoke(request)
2569        if isinstance(response, Response_Unit):
2570            return
2571        raise UnexpectedResponse()
2572
2573    async def set_local_discovery_enabled(
2574        self,
2575        *,
2576        enabled: bool = False,
2577    ):
2578        """Enables/disables local discovery."""
2579        request = Request_SessionSetLocalDiscoveryEnabled(
2580            enabled,
2581        )
2582        response = await self._client.invoke(request)
2583        if isinstance(response, Response_Unit):
2584            return
2585        raise UnexpectedResponse()
2586
2587    async def set_mount_root(
2588        self,
2589        *,
2590        path: str | None = None,
2591    ):
2592        request = Request_SessionSetMountRoot(
2593            path,
2594        )
2595        response = await self._client.invoke(request)
2596        if isinstance(response, Response_Unit):
2597            return
2598        raise UnexpectedResponse()
2599
2600    async def set_pex_recv_enabled(
2601        self,
2602        *,
2603        enabled: bool = False,
2604    ):
2605        request = Request_SessionSetPexRecvEnabled(
2606            enabled,
2607        )
2608        response = await self._client.invoke(request)
2609        if isinstance(response, Response_Unit):
2610            return
2611        raise UnexpectedResponse()
2612
2613    async def set_pex_send_enabled(
2614        self,
2615        *,
2616        enabled: bool = False,
2617    ):
2618        request = Request_SessionSetPexSendEnabled(
2619            enabled,
2620        )
2621        response = await self._client.invoke(request)
2622        if isinstance(response, Response_Unit):
2623            return
2624        raise UnexpectedResponse()
2625
2626    async def set_port_forwarding_enabled(
2627        self,
2628        *,
2629        enabled: bool = False,
2630    ):
2631        """Enables/disables port forwarding (UPnP)."""
2632        request = Request_SessionSetPortForwardingEnabled(
2633            enabled,
2634        )
2635        response = await self._client.invoke(request)
2636        if isinstance(response, Response_Unit):
2637            return
2638        raise UnexpectedResponse()
2639
2640    async def set_store_dirs(
2641        self,
2642        *,
2643        paths: list[str],
2644    ):
2645        request = Request_SessionSetStoreDirs(
2646            paths,
2647        )
2648        response = await self._client.invoke(request)
2649        if isinstance(response, Response_Unit):
2650            return
2651        raise UnexpectedResponse()
2652
2653    async def unpin_dht(
2654        self,
2655    ):
2656        """
2657        Unpin the DHT. If the DHT is not pinned and there are no more active DHT lookups and no
2658        DHT-enabled repositories, the DHT shuts down.
2659        """
2660        request = Request_SessionUnpinDht()
2661        response = await self._client.invoke(request)
2662        if isinstance(response, Response_Unit):
2663            return
2664        raise UnexpectedResponse()
2665
2666    async def validate_share_token(
2667        self,
2668        *,
2669        token: str,
2670    ) -> str:
2671        """Checks whether the given string is a valid share token."""
2672        request = Request_SessionValidateShareToken(
2673            token,
2674        )
2675        response = await self._client.invoke(request)
2676        if isinstance(response, Response_ShareToken):
2677            return response.value
2678        raise UnexpectedResponse()
async def add_user_provided_peers(self, *, addrs: list[str]):
1777    async def add_user_provided_peers(
1778        self,
1779        *,
1780        addrs: list[str],
1781    ):
1782        """
1783        Adds peers to connect to.
1784
1785        Normally peers are discovered automatically (using Bittorrent DHT, Peer exchange or Local
1786        discovery) but this function is useful in case when the discovery is not available for any
1787        reason (e.g. in an isolated network).
1788
1789        Note that peers added with this function are remembered across restarts. To forget peers,
1790        use [Self::session_remove_user_provided_peers].
1791        """
1792        request = Request_SessionAddUserProvidedPeers(
1793            addrs,
1794        )
1795        response = await self._client.invoke(request)
1796        if isinstance(response, Response_Unit):
1797            return
1798        raise UnexpectedResponse()

Adds peers to connect to.

Normally peers are discovered automatically (using Bittorrent DHT, Peer exchange or Local discovery) but this function is useful in case when the discovery is not available for any reason (e.g. in an isolated network).

Note that peers added with this function are remembered across restarts. To forget peers, use [Self::session_remove_user_provided_peers].

async def bind_metrics(self, *, addr: str | None = None):
1800    async def bind_metrics(
1801        self,
1802        *,
1803        addr: str | None = None,
1804    ):
1805        request = Request_SessionBindMetrics(
1806            addr,
1807        )
1808        response = await self._client.invoke(request)
1809        if isinstance(response, Response_Unit):
1810            return
1811        raise UnexpectedResponse()
async def bind_network(self, *, addrs: list[str]):
1813    async def bind_network(
1814        self,
1815        *,
1816        addrs: list[str],
1817    ):
1818        """
1819        Binds the network listeners to the specified interfaces.
1820
1821        Up to four listeners can be bound, one for each combination of protocol (TCP or QUIC) and IP
1822        family (IPv4 or IPv6). The format of the interfaces is "PROTO/IP:PORT" where PROTO is "tcp"
1823        or "quic". If IP is IPv6, it needs to be enclosed in square brackets.
1824
1825        If port is `0`, binds to a random port initially but on subsequent starts tries to use the
1826        same port (unless it's already taken). This can be useful to configuring port forwarding.
1827        """
1828        request = Request_SessionBindNetwork(
1829            addrs,
1830        )
1831        response = await self._client.invoke(request)
1832        if isinstance(response, Response_Unit):
1833            return
1834        raise UnexpectedResponse()

Binds the network listeners to the specified interfaces.

Up to four listeners can be bound, one for each combination of protocol (TCP or QUIC) and IP family (IPv4 or IPv6). The format of the interfaces is "PROTO/IP:PORT" where PROTO is "tcp" or "quic". If IP is IPv6, it needs to be enclosed in square brackets.

If port is 0, binds to a random port initially but on subsequent starts tries to use the same port (unless it's already taken). This can be useful to configuring port forwarding.

async def bind_remote_control(self, *, addr: str | None = None) -> int:
1836    async def bind_remote_control(
1837        self,
1838        *,
1839        addr: str | None = None,
1840    ) -> int:
1841        request = Request_SessionBindRemoteControl(
1842            addr,
1843        )
1844        response = await self._client.invoke(request)
1845        if isinstance(response, Response_U16):
1846            return response.value
1847        raise UnexpectedResponse()
async def copy( self, *, src_repo: str | None = None, src_path: str, dst_repo: str | None = None, dst_path: str):
1849    async def copy(
1850        self,
1851        *,
1852        src_repo: str | None = None,
1853        src_path: str,
1854        dst_repo: str | None = None,
1855        dst_path: str,
1856    ):
1857        """
1858        Copy file or directory into, from or between repositories
1859
1860        - `src_repo`: Name of the repository from which file will be copied.
1861        - `src_path`: Path of to the entry to be copied. If `src_repo` is set, the `src_path` is
1862          relative to the corresponding repository root. If `src_repo` is null, `src_path` is
1863          interpreted as path on the local file system.
1864        - `dst_repo`: Name of the repository into which the entry will be copied.
1865        - `dst_path`: Destination entry
1866        """
1867        request = Request_SessionCopy(
1868            src_repo,
1869            src_path,
1870            dst_repo,
1871            dst_path,
1872        )
1873        response = await self._client.invoke(request)
1874        if isinstance(response, Response_Unit):
1875            return
1876        raise UnexpectedResponse()

Copy file or directory into, from or between repositories

  • src_repo: Name of the repository from which file will be copied.
  • src_path: Path of to the entry to be copied. If src_repo is set, the src_path is relative to the corresponding repository root. If src_repo is null, src_path is interpreted as path on the local file system.
  • dst_repo: Name of the repository into which the entry will be copied.
  • dst_path: Destination entry
async def create_repository( self, *, path: str, read_secret: SetLocalSecret | None = None, write_secret: SetLocalSecret | None = None, token: str | None = None, sync_enabled: bool = False, dht_enabled: bool = False, pex_enabled: bool = False) -> Repository:
1878    async def create_repository(
1879        self,
1880        *,
1881        path: str,
1882        read_secret: SetLocalSecret | None = None,
1883        write_secret: SetLocalSecret | None = None,
1884        token: str | None = None,
1885        sync_enabled: bool = False,
1886        dht_enabled: bool = False,
1887        pex_enabled: bool = False,
1888    ) -> Repository:
1889        """
1890        Creates a new repository.
1891
1892        - `path`: path to the repository file or name of the repository.
1893        - `read_secret`: local secret for reading the repository on this device only. Do not share
1894          with peers!. If null, the repo won't be protected and anyone with physical access to the
1895          device will be able to read it.
1896        - `write_secret`: local secret for writing to the repository on this device only. Do not
1897          share with peers! Can be the same as `read_secret` if one wants to use only one secret
1898          for both reading and writing.  Separate secrets are useful for plausible deniability. If
1899          both `read_secret` and `write_secret` are `None`, the repo won't be protected and anyone
1900          with physical access to the device will be able to read and write to it. If `read_secret`
1901          is not `None` but `write_secret` is `None`, the repo won't be writable from this device.
1902        - `token`: used to share repositories between devices. If not `None`, this repo will be
1903          linked with the repos with the same token on other devices. See also
1904          [Self::repository_share]. This also determines the maximal access mode the repo can be
1905          opened in. If `None`, it's *write* mode.
1906        """
1907        request = Request_SessionCreateRepository(
1908            path,
1909            read_secret,
1910            write_secret,
1911            token,
1912            sync_enabled,
1913            dht_enabled,
1914            pex_enabled,
1915        )
1916        response = await self._client.invoke(request)
1917        if isinstance(response, Response_Repository):
1918            return Repository(self._client, response.value)
1919        raise UnexpectedResponse()

Creates a new repository.

  • path: path to the repository file or name of the repository.
  • read_secret: local secret for reading the repository on this device only. Do not share with peers!. If null, the repo won't be protected and anyone with physical access to the device will be able to read it.
  • write_secret: local secret for writing to the repository on this device only. Do not share with peers! Can be the same as read_secret if one wants to use only one secret for both reading and writing. Separate secrets are useful for plausible deniability. If both read_secret and write_secret are None, the repo won't be protected and anyone with physical access to the device will be able to read and write to it. If read_secret is not None but write_secret is None, the repo won't be writable from this device.
  • token: used to share repositories between devices. If not None, this repo will be linked with the repos with the same token on other devices. See also [Self::repository_share]. This also determines the maximal access mode the repo can be opened in. If None, it's write mode.
async def delete_repository_by_name(self, *, name: str):
1921    async def delete_repository_by_name(
1922        self,
1923        *,
1924        name: str,
1925    ):
1926        """Delete a repository with the given name."""
1927        request = Request_SessionDeleteRepositoryByName(
1928            name,
1929        )
1930        response = await self._client.invoke(request)
1931        if isinstance(response, Response_Unit):
1932            return
1933        raise UnexpectedResponse()

Delete a repository with the given name.

async def derive_secret_key( self, *, password: Password, salt: PasswordSalt) -> SecretKey:
1935    async def derive_secret_key(
1936        self,
1937        *,
1938        password: Password,
1939        salt: PasswordSalt,
1940    ) -> SecretKey:
1941        request = Request_SessionDeriveSecretKey(
1942            password,
1943            salt,
1944        )
1945        response = await self._client.invoke(request)
1946        if isinstance(response, Response_SecretKey):
1947            return response.value
1948        raise UnexpectedResponse()
async def find_repository(self, *, name: str) -> Repository:
1950    async def find_repository(
1951        self,
1952        *,
1953        name: str,
1954    ) -> Repository:
1955        request = Request_SessionFindRepository(
1956            name,
1957        )
1958        response = await self._client.invoke(request)
1959        if isinstance(response, Response_Repository):
1960            return Repository(self._client, response.value)
1961        raise UnexpectedResponse()
async def generate_password_salt(self) -> PasswordSalt:
1963    async def generate_password_salt(
1964        self,
1965    ) -> PasswordSalt:
1966        request = Request_SessionGeneratePasswordSalt()
1967        response = await self._client.invoke(request)
1968        if isinstance(response, Response_PasswordSalt):
1969            return response.value
1970        raise UnexpectedResponse()
async def generate_secret_key(self) -> SecretKey:
1972    async def generate_secret_key(
1973        self,
1974    ) -> SecretKey:
1975        request = Request_SessionGenerateSecretKey()
1976        response = await self._client.invoke(request)
1977        if isinstance(response, Response_SecretKey):
1978            return response.value
1979        raise UnexpectedResponse()
async def get_current_protocol_version(self) -> int:
1981    async def get_current_protocol_version(
1982        self,
1983    ) -> int:
1984        """
1985        Returns our Ouisync protocol version.
1986
1987        In order to establish connections with peers, they must use the same protocol version as
1988        us.
1989
1990        See also [Self::session_get_highest_seen_protocol_version]
1991        """
1992        request = Request_SessionGetCurrentProtocolVersion()
1993        response = await self._client.invoke(request)
1994        if isinstance(response, Response_U64):
1995            return response.value
1996        raise UnexpectedResponse()

Returns our Ouisync protocol version.

In order to establish connections with peers, they must use the same protocol version as us.

See also [Self::session_get_highest_seen_protocol_version]

async def get_default_block_expiration(self) -> int | None:
1998    async def get_default_block_expiration(
1999        self,
2000    ) -> int | None:
2001        request = Request_SessionGetDefaultBlockExpiration()
2002        response = await self._client.invoke(request)
2003        if isinstance(response, Response_Duration):
2004            return response.value
2005        if isinstance(response, Response_None):
2006            return None
2007        raise UnexpectedResponse()
async def get_default_quota(self) -> StorageSize | None:
2009    async def get_default_quota(
2010        self,
2011    ) -> StorageSize | None:
2012        request = Request_SessionGetDefaultQuota()
2013        response = await self._client.invoke(request)
2014        if isinstance(response, Response_StorageSize):
2015            return response.value
2016        if isinstance(response, Response_None):
2017            return None
2018        raise UnexpectedResponse()
async def get_default_repository_expiration(self) -> int | None:
2020    async def get_default_repository_expiration(
2021        self,
2022    ) -> int | None:
2023        request = Request_SessionGetDefaultRepositoryExpiration()
2024        response = await self._client.invoke(request)
2025        if isinstance(response, Response_Duration):
2026            return response.value
2027        if isinstance(response, Response_None):
2028            return None
2029        raise UnexpectedResponse()
async def get_dht_routers(self) -> list[str]:
2031    async def get_dht_routers(
2032        self,
2033    ) -> list[str]:
2034        """
2035        Returns the current DHT routers (bootstrap nodes). If the routers haven't been changed by
2036        the user yet, returns the default routers.
2037        """
2038        request = Request_SessionGetDhtRouters()
2039        response = await self._client.invoke(request)
2040        if isinstance(response, Response_Strings):
2041            return response.value
2042        raise UnexpectedResponse()

Returns the current DHT routers (bootstrap nodes). If the routers haven't been changed by the user yet, returns the default routers.

async def get_external_addr_v4(self) -> str | None:
2044    async def get_external_addr_v4(
2045        self,
2046    ) -> str | None:
2047        request = Request_SessionGetExternalAddrV4()
2048        response = await self._client.invoke(request)
2049        if isinstance(response, Response_SocketAddr):
2050            return response.value
2051        if isinstance(response, Response_None):
2052            return None
2053        raise UnexpectedResponse()
async def get_external_addr_v6(self) -> str | None:
2055    async def get_external_addr_v6(
2056        self,
2057    ) -> str | None:
2058        request = Request_SessionGetExternalAddrV6()
2059        response = await self._client.invoke(request)
2060        if isinstance(response, Response_SocketAddr):
2061            return response.value
2062        if isinstance(response, Response_None):
2063            return None
2064        raise UnexpectedResponse()
async def get_highest_seen_protocol_version(self) -> int:
2066    async def get_highest_seen_protocol_version(
2067        self,
2068    ) -> int:
2069        """
2070        Returns the highest protocol version of all known peers.
2071
2072        If this is higher than [our version](Self::session_get_current_protocol_version) it likely
2073        means we are using an outdated version of Ouisync. When a peer with higher protocol version
2074        is found, a [NetworkEvent::ProtocolVersionMismatch] is emitted.
2075        """
2076        request = Request_SessionGetHighestSeenProtocolVersion()
2077        response = await self._client.invoke(request)
2078        if isinstance(response, Response_U64):
2079            return response.value
2080        raise UnexpectedResponse()

Returns the highest protocol version of all known peers.

If this is higher than our version it likely means we are using an outdated version of Ouisync. When a peer with higher protocol version is found, a [NetworkEvent::ProtocolVersionMismatch] is emitted.

async def get_local_listener_addrs(self) -> list[str]:
2082    async def get_local_listener_addrs(
2083        self,
2084    ) -> list[str]:
2085        """Returns the listener addresses of this Ouisync instance."""
2086        request = Request_SessionGetLocalListenerAddrs()
2087        response = await self._client.invoke(request)
2088        if isinstance(response, Response_PeerAddrs):
2089            return response.value
2090        raise UnexpectedResponse()

Returns the listener addresses of this Ouisync instance.

async def get_metrics_listener_addr(self) -> str | None:
2092    async def get_metrics_listener_addr(
2093        self,
2094    ) -> str | None:
2095        request = Request_SessionGetMetricsListenerAddr()
2096        response = await self._client.invoke(request)
2097        if isinstance(response, Response_SocketAddr):
2098            return response.value
2099        if isinstance(response, Response_None):
2100            return None
2101        raise UnexpectedResponse()
async def get_mount_root(self) -> str | None:
2103    async def get_mount_root(
2104        self,
2105    ) -> str | None:
2106        request = Request_SessionGetMountRoot()
2107        response = await self._client.invoke(request)
2108        if isinstance(response, Response_Path):
2109            return response.value
2110        if isinstance(response, Response_None):
2111            return None
2112        raise UnexpectedResponse()
async def get_nat_behavior(self) -> NatBehavior | None:
2114    async def get_nat_behavior(
2115        self,
2116    ) -> NatBehavior | None:
2117        request = Request_SessionGetNatBehavior()
2118        response = await self._client.invoke(request)
2119        if isinstance(response, Response_NatBehavior):
2120            return response.value
2121        if isinstance(response, Response_None):
2122            return None
2123        raise UnexpectedResponse()
async def get_network_stats(self) -> Stats:
2125    async def get_network_stats(
2126        self,
2127    ) -> Stats:
2128        request = Request_SessionGetNetworkStats()
2129        response = await self._client.invoke(request)
2130        if isinstance(response, Response_Stats):
2131            return response.value
2132        raise UnexpectedResponse()
async def get_peers(self) -> list[PeerInfo]:
2134    async def get_peers(
2135        self,
2136    ) -> list[PeerInfo]:
2137        """
2138        Returns info about all known peers (both discovered and explicitly added).
2139
2140        When the set of known peers changes, a [NetworkEvent::PeerSetChange] is emitted. Calling
2141        this function afterwards returns the new peer info.
2142        """
2143        request = Request_SessionGetPeers()
2144        response = await self._client.invoke(request)
2145        if isinstance(response, Response_PeerInfos):
2146            return response.value
2147        raise UnexpectedResponse()

Returns info about all known peers (both discovered and explicitly added).

When the set of known peers changes, a [NetworkEvent::PeerSetChange] is emitted. Calling this function afterwards returns the new peer info.

async def get_remote_control_listener_addr(self) -> str | None:
2149    async def get_remote_control_listener_addr(
2150        self,
2151    ) -> str | None:
2152        request = Request_SessionGetRemoteControlListenerAddr()
2153        response = await self._client.invoke(request)
2154        if isinstance(response, Response_SocketAddr):
2155            return response.value
2156        if isinstance(response, Response_None):
2157            return None
2158        raise UnexpectedResponse()
async def get_remote_listener_addrs(self, *, host: str) -> list[str]:
2160    async def get_remote_listener_addrs(
2161        self,
2162        *,
2163        host: str,
2164    ) -> list[str]:
2165        """
2166        Returns the listener addresses of the specified remote Ouisync instance. Works only if the
2167        remote control API is enabled on the remote instance. Typically used with cache servers.
2168        """
2169        request = Request_SessionGetRemoteListenerAddrs(
2170            host,
2171        )
2172        response = await self._client.invoke(request)
2173        if isinstance(response, Response_PeerAddrs):
2174            return response.value
2175        raise UnexpectedResponse()

Returns the listener addresses of the specified remote Ouisync instance. Works only if the remote control API is enabled on the remote instance. Typically used with cache servers.

async def get_runtime_id(self) -> PublicRuntimeId:
2177    async def get_runtime_id(
2178        self,
2179    ) -> PublicRuntimeId:
2180        """
2181        Returns the runtime id of this Ouisync instance.
2182
2183        The runtime id is a unique identifier of this instance which is randomly generated every
2184        time Ouisync starts.
2185        """
2186        request = Request_SessionGetRuntimeId()
2187        response = await self._client.invoke(request)
2188        if isinstance(response, Response_PublicRuntimeId):
2189            return response.value
2190        raise UnexpectedResponse()

Returns the runtime id of this Ouisync instance.

The runtime id is a unique identifier of this instance which is randomly generated every time Ouisync starts.

async def get_share_token_access_mode(self, *, token: str) -> AccessMode:
2192    async def get_share_token_access_mode(
2193        self,
2194        *,
2195        token: str,
2196    ) -> AccessMode:
2197        """Returns the access mode that the given token grants."""
2198        request = Request_SessionGetShareTokenAccessMode(
2199            token,
2200        )
2201        response = await self._client.invoke(request)
2202        if isinstance(response, Response_AccessMode):
2203            return response.value
2204        raise UnexpectedResponse()

Returns the access mode that the given token grants.

async def get_share_token_info_hash(self, *, token: str) -> str:
2206    async def get_share_token_info_hash(
2207        self,
2208        *,
2209        token: str,
2210    ) -> str:
2211        """
2212        Return the info-hash of the repository corresponding to the given token, formatted as hex
2213        string.
2214
2215        See also: [repository_get_info_hash]
2216        """
2217        request = Request_SessionGetShareTokenInfoHash(
2218            token,
2219        )
2220        response = await self._client.invoke(request)
2221        if isinstance(response, Response_String):
2222            return response.value
2223        raise UnexpectedResponse()

Return the info-hash of the repository corresponding to the given token, formatted as hex string.

See also: [repository_get_info_hash]

async def get_share_token_suggested_name(self, *, token: str) -> str:
2225    async def get_share_token_suggested_name(
2226        self,
2227        *,
2228        token: str,
2229    ) -> str:
2230        """Returns the suggested name for the repository corresponding to the given token."""
2231        request = Request_SessionGetShareTokenSuggestedName(
2232            token,
2233        )
2234        response = await self._client.invoke(request)
2235        if isinstance(response, Response_String):
2236            return response.value
2237        raise UnexpectedResponse()

Returns the suggested name for the repository corresponding to the given token.

async def get_state_monitor( self, *, path: list[MonitorId]) -> typing.Any | None:
2239    async def get_state_monitor(
2240        self,
2241        *,
2242        path: list[MonitorId],
2243    ) -> typing.Any | None:
2244        request = Request_SessionGetStateMonitor(
2245            path,
2246        )
2247        response = await self._client.invoke(request)
2248        if isinstance(response, Response_StateMonitor):
2249            return response.value
2250        if isinstance(response, Response_None):
2251            return None
2252        raise UnexpectedResponse()
async def get_store_dirs(self) -> list[str]:
2254    async def get_store_dirs(
2255        self,
2256    ) -> list[str]:
2257        request = Request_SessionGetStoreDirs()
2258        response = await self._client.invoke(request)
2259        if isinstance(response, Response_Paths):
2260            return response.value
2261        raise UnexpectedResponse()
async def get_user_provided_peers(self) -> list[str]:
2263    async def get_user_provided_peers(
2264        self,
2265    ) -> list[str]:
2266        request = Request_SessionGetUserProvidedPeers()
2267        response = await self._client.invoke(request)
2268        if isinstance(response, Response_PeerAddrs):
2269            return response.value
2270        raise UnexpectedResponse()
async def init_network(self, *, defaults: NetworkDefaults):
2272    async def init_network(
2273        self,
2274        *,
2275        defaults: NetworkDefaults,
2276    ):
2277        """
2278        Initializes the network according to the stored configuration. If a particular network
2279        parameter is not yet configured, falls back to the given defaults.
2280        """
2281        request = Request_SessionInitNetwork(
2282            defaults,
2283        )
2284        response = await self._client.invoke(request)
2285        if isinstance(response, Response_Unit):
2286            return
2287        raise UnexpectedResponse()

Initializes the network according to the stored configuration. If a particular network parameter is not yet configured, falls back to the given defaults.

async def insert_store_dirs(self, *, paths: list[str]):
2289    async def insert_store_dirs(
2290        self,
2291        *,
2292        paths: list[str],
2293    ):
2294        request = Request_SessionInsertStoreDirs(
2295            paths,
2296        )
2297        response = await self._client.invoke(request)
2298        if isinstance(response, Response_Unit):
2299            return
2300        raise UnexpectedResponse()
async def is_local_dht_enabled(self) -> bool:
2302    async def is_local_dht_enabled(
2303        self,
2304    ) -> bool:
2305        """Checks whether local DHT is enabled."""
2306        request = Request_SessionIsLocalDhtEnabled()
2307        response = await self._client.invoke(request)
2308        if isinstance(response, Response_Bool):
2309            return response.value
2310        raise UnexpectedResponse()

Checks whether local DHT is enabled.

async def is_local_discovery_enabled(self) -> bool:
2312    async def is_local_discovery_enabled(
2313        self,
2314    ) -> bool:
2315        """Is local discovery enabled?"""
2316        request = Request_SessionIsLocalDiscoveryEnabled()
2317        response = await self._client.invoke(request)
2318        if isinstance(response, Response_Bool):
2319            return response.value
2320        raise UnexpectedResponse()

Is local discovery enabled?

async def is_pex_recv_enabled(self) -> bool:
2322    async def is_pex_recv_enabled(
2323        self,
2324    ) -> bool:
2325        """Checks whether accepting peers discovered on the peer exchange is enabled."""
2326        request = Request_SessionIsPexRecvEnabled()
2327        response = await self._client.invoke(request)
2328        if isinstance(response, Response_Bool):
2329            return response.value
2330        raise UnexpectedResponse()

Checks whether accepting peers discovered on the peer exchange is enabled.

async def is_pex_send_enabled(self) -> bool:
2332    async def is_pex_send_enabled(
2333        self,
2334    ) -> bool:
2335        request = Request_SessionIsPexSendEnabled()
2336        response = await self._client.invoke(request)
2337        if isinstance(response, Response_Bool):
2338            return response.value
2339        raise UnexpectedResponse()
async def is_port_forwarding_enabled(self) -> bool:
2341    async def is_port_forwarding_enabled(
2342        self,
2343    ) -> bool:
2344        """Is port forwarding (UPnP) enabled?"""
2345        request = Request_SessionIsPortForwardingEnabled()
2346        response = await self._client.invoke(request)
2347        if isinstance(response, Response_Bool):
2348            return response.value
2349        raise UnexpectedResponse()

Is port forwarding (UPnP) enabled?

async def list_repositories(self) -> dict[str, Repository]:
2351    async def list_repositories(
2352        self,
2353    ) -> dict[str, Repository]:
2354        request = Request_SessionListRepositories()
2355        response = await self._client.invoke(request)
2356        if isinstance(response, Response_Repositories):
2357            return {k: Repository(self._client, v) for k, v in response.value.items()}
2358        raise UnexpectedResponse()
async def mirror_exists(self, *, token: str, host: str) -> bool:
2360    async def mirror_exists(
2361        self,
2362        *,
2363        token: str,
2364        host: str,
2365    ) -> bool:
2366        request = Request_SessionMirrorExists(
2367            token,
2368            host,
2369        )
2370        response = await self._client.invoke(request)
2371        if isinstance(response, Response_Bool):
2372            return response.value
2373        raise UnexpectedResponse()
async def open_network_socket_v4(self) -> NetworkSocket | None:
2375    async def open_network_socket_v4(
2376        self,
2377    ) -> NetworkSocket | None:
2378        """
2379        Opens a side channel to the underlying IPv4 UDP socket. The side channel is used to
2380        send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is
2381        useful to share the socket between different protocols for hole punching.
2382
2383        Returns `None` if QUIC IPv4 endpoint isn't bound (see [Self::session_bind_network]).
2384        """
2385        request = Request_SessionOpenNetworkSocketV4()
2386        response = await self._client.invoke(request)
2387        if isinstance(response, Response_NetworkSocket):
2388            return NetworkSocket(self._client, response.value)
2389        if isinstance(response, Response_None):
2390            return None
2391        raise UnexpectedResponse()

Opens a side channel to the underlying IPv4 UDP socket. The side channel is used to send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is useful to share the socket between different protocols for hole punching.

Returns None if QUIC IPv4 endpoint isn't bound (see [Self::session_bind_network]).

async def open_network_socket_v6(self) -> NetworkSocket | None:
2393    async def open_network_socket_v6(
2394        self,
2395    ) -> NetworkSocket | None:
2396        """
2397        Opens a side channel to the underlying IPv6 UDP socket. The side channel is used to
2398        send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is
2399        useful to share the socket between different protocols for hole punching.
2400
2401        Returns `None` if QUIC IPv6 endpoint isn't bound (see [Self::session_bind_network]).
2402        """
2403        request = Request_SessionOpenNetworkSocketV6()
2404        response = await self._client.invoke(request)
2405        if isinstance(response, Response_NetworkSocket):
2406            return NetworkSocket(self._client, response.value)
2407        if isinstance(response, Response_None):
2408            return None
2409        raise UnexpectedResponse()

Opens a side channel to the underlying IPv6 UDP socket. The side channel is used to send/receive raw UDP datagrams on the same socket that the sync protocol uses. This is useful to share the socket between different protocols for hole punching.

Returns None if QUIC IPv6 endpoint isn't bound (see [Self::session_bind_network]).

async def open_network_stream( self, *, addr: str, topic_id: TopicId) -> NetworkStream:
2411    async def open_network_stream(
2412        self,
2413        *,
2414        addr: str,
2415        topic_id: TopicId,
2416    ) -> NetworkStream:
2417        """Opens a raw byte streams to the given peer, bound to the given topic."""
2418        request = Request_SessionOpenNetworkStream(
2419            addr,
2420            topic_id,
2421        )
2422        response = await self._client.invoke(request)
2423        if isinstance(response, Response_NetworkStream):
2424            return NetworkStream(self._client, response.value)
2425        raise UnexpectedResponse()

Opens a raw byte streams to the given peer, bound to the given topic.

async def open_repository( self, *, path: str, local_secret: LocalSecret | None = None) -> Repository:
2427    async def open_repository(
2428        self,
2429        *,
2430        path: str,
2431        local_secret: LocalSecret | None = None,
2432    ) -> Repository:
2433        """
2434        Opens an existing repository.
2435
2436        - `path`: path to the local file the repo is stored in.
2437        - `local_secret`: a local secret. See the `read_secret` and `write_secret` params in
2438          [Self::session_create_repository] for more details. If this repo uses local secret
2439          (s), this determines the access mode the repo is opened in: `read_secret` opens it
2440          in *read* mode, `write_secret` opens it in *write* mode and no secret or wrong secret
2441          opens it in *blind* mode. If this repo doesn't use local secret(s), the repo is opened in
2442          the maximal mode specified when the repo was created.
2443        """
2444        request = Request_SessionOpenRepository(
2445            path,
2446            local_secret,
2447        )
2448        response = await self._client.invoke(request)
2449        if isinstance(response, Response_Repository):
2450            return Repository(self._client, response.value)
2451        raise UnexpectedResponse()

Opens an existing repository.

  • path: path to the local file the repo is stored in.
  • local_secret: a local secret. See the read_secret and write_secret params in [Self::session_create_repository] for more details. If this repo uses local secret (s), this determines the access mode the repo is opened in: read_secret opens it in read mode, write_secret opens it in write mode and no secret or wrong secret opens it in blind mode. If this repo doesn't use local secret(s), the repo is opened in the maximal mode specified when the repo was created.
async def pin_dht(self):
2453    async def pin_dht(
2454        self,
2455    ):
2456        """
2457        Pin the DHT to ensure it starts and remains running even when there are no active DHT
2458        lookups and no DHT-enabled repositories. This is useful to prevent the DHT restarting
2459        between the lookups (which could be slow).
2460        """
2461        request = Request_SessionPinDht()
2462        response = await self._client.invoke(request)
2463        if isinstance(response, Response_Unit):
2464            return
2465        raise UnexpectedResponse()

Pin the DHT to ensure it starts and remains running even when there are no active DHT lookups and no DHT-enabled repositories. This is useful to prevent the DHT restarting between the lookups (which could be slow).

async def remove_store_dirs(self, *, paths: list[str]):
2467    async def remove_store_dirs(
2468        self,
2469        *,
2470        paths: list[str],
2471    ):
2472        request = Request_SessionRemoveStoreDirs(
2473            paths,
2474        )
2475        response = await self._client.invoke(request)
2476        if isinstance(response, Response_Unit):
2477            return
2478        raise UnexpectedResponse()
async def remove_user_provided_peers(self, *, addrs: list[str]):
2480    async def remove_user_provided_peers(
2481        self,
2482        *,
2483        addrs: list[str],
2484    ):
2485        """Removes peers previously added with [Self::session_add_user_provided_peers]."""
2486        request = Request_SessionRemoveUserProvidedPeers(
2487            addrs,
2488        )
2489        response = await self._client.invoke(request)
2490        if isinstance(response, Response_Unit):
2491            return
2492        raise UnexpectedResponse()

Removes peers previously added with [Self::session_add_user_provided_peers].

async def set_default_block_expiration(self, *, value: int | None = None):
2494    async def set_default_block_expiration(
2495        self,
2496        *,
2497        value: int | None = None,
2498    ):
2499        request = Request_SessionSetDefaultBlockExpiration(
2500            value,
2501        )
2502        response = await self._client.invoke(request)
2503        if isinstance(response, Response_Unit):
2504            return
2505        raise UnexpectedResponse()
async def set_default_quota( self, *, value: StorageSize | None = None):
2507    async def set_default_quota(
2508        self,
2509        *,
2510        value: StorageSize | None = None,
2511    ):
2512        request = Request_SessionSetDefaultQuota(
2513            value,
2514        )
2515        response = await self._client.invoke(request)
2516        if isinstance(response, Response_Unit):
2517            return
2518        raise UnexpectedResponse()
async def set_default_repository_expiration(self, *, value: int | None = None):
2520    async def set_default_repository_expiration(
2521        self,
2522        *,
2523        value: int | None = None,
2524    ):
2525        request = Request_SessionSetDefaultRepositoryExpiration(
2526            value,
2527        )
2528        response = await self._client.invoke(request)
2529        if isinstance(response, Response_Unit):
2530            return
2531        raise UnexpectedResponse()
async def set_dht_routers(self, *, routers: list[str]):
2533    async def set_dht_routers(
2534        self,
2535        *,
2536        routers: list[str],
2537    ):
2538        """
2539        Changes the DHT routers (bootstrap nodes), rebootstraps the DHTs and restart any ongoing
2540        lookups. If this is not called, a default set of routers is used. Each router is specified
2541        as hostname + port or ip address + port.
2542        """
2543        request = Request_SessionSetDhtRouters(
2544            routers,
2545        )
2546        response = await self._client.invoke(request)
2547        if isinstance(response, Response_Unit):
2548            return
2549        raise UnexpectedResponse()

Changes the DHT routers (bootstrap nodes), rebootstraps the DHTs and restart any ongoing lookups. If this is not called, a default set of routers is used. Each router is specified as hostname + port or ip address + port.

async def set_local_dht_enabled(self, *, enabled: bool = False):
2551    async def set_local_dht_enabled(
2552        self,
2553        *,
2554        enabled: bool = False,
2555    ):
2556        """
2557        Set whether DHT on the local network or localhost is allowed. By default this is `false`
2558        because DHT is a global discovery mechanism and finding a local peer on it is unexpected
2559        (and could indicate malice). However, is some situations it's still useful to enable it
2560        (typically for testing).
2561
2562        Note: this option is currently experimental and unstable (semver extempt). It's possible it
2563        will be removed in the future.
2564        """
2565        request = Request_SessionSetLocalDhtEnabled(
2566            enabled,
2567        )
2568        response = await self._client.invoke(request)
2569        if isinstance(response, Response_Unit):
2570            return
2571        raise UnexpectedResponse()

Set whether DHT on the local network or localhost is allowed. By default this is false because DHT is a global discovery mechanism and finding a local peer on it is unexpected (and could indicate malice). However, is some situations it's still useful to enable it (typically for testing).

Note: this option is currently experimental and unstable (semver extempt). It's possible it will be removed in the future.

async def set_local_discovery_enabled(self, *, enabled: bool = False):
2573    async def set_local_discovery_enabled(
2574        self,
2575        *,
2576        enabled: bool = False,
2577    ):
2578        """Enables/disables local discovery."""
2579        request = Request_SessionSetLocalDiscoveryEnabled(
2580            enabled,
2581        )
2582        response = await self._client.invoke(request)
2583        if isinstance(response, Response_Unit):
2584            return
2585        raise UnexpectedResponse()

Enables/disables local discovery.

async def set_mount_root(self, *, path: str | None = None):
2587    async def set_mount_root(
2588        self,
2589        *,
2590        path: str | None = None,
2591    ):
2592        request = Request_SessionSetMountRoot(
2593            path,
2594        )
2595        response = await self._client.invoke(request)
2596        if isinstance(response, Response_Unit):
2597            return
2598        raise UnexpectedResponse()
async def set_pex_recv_enabled(self, *, enabled: bool = False):
2600    async def set_pex_recv_enabled(
2601        self,
2602        *,
2603        enabled: bool = False,
2604    ):
2605        request = Request_SessionSetPexRecvEnabled(
2606            enabled,
2607        )
2608        response = await self._client.invoke(request)
2609        if isinstance(response, Response_Unit):
2610            return
2611        raise UnexpectedResponse()
async def set_pex_send_enabled(self, *, enabled: bool = False):
2613    async def set_pex_send_enabled(
2614        self,
2615        *,
2616        enabled: bool = False,
2617    ):
2618        request = Request_SessionSetPexSendEnabled(
2619            enabled,
2620        )
2621        response = await self._client.invoke(request)
2622        if isinstance(response, Response_Unit):
2623            return
2624        raise UnexpectedResponse()
async def set_port_forwarding_enabled(self, *, enabled: bool = False):
2626    async def set_port_forwarding_enabled(
2627        self,
2628        *,
2629        enabled: bool = False,
2630    ):
2631        """Enables/disables port forwarding (UPnP)."""
2632        request = Request_SessionSetPortForwardingEnabled(
2633            enabled,
2634        )
2635        response = await self._client.invoke(request)
2636        if isinstance(response, Response_Unit):
2637            return
2638        raise UnexpectedResponse()

Enables/disables port forwarding (UPnP).

async def set_store_dirs(self, *, paths: list[str]):
2640    async def set_store_dirs(
2641        self,
2642        *,
2643        paths: list[str],
2644    ):
2645        request = Request_SessionSetStoreDirs(
2646            paths,
2647        )
2648        response = await self._client.invoke(request)
2649        if isinstance(response, Response_Unit):
2650            return
2651        raise UnexpectedResponse()
async def unpin_dht(self):
2653    async def unpin_dht(
2654        self,
2655    ):
2656        """
2657        Unpin the DHT. If the DHT is not pinned and there are no more active DHT lookups and no
2658        DHT-enabled repositories, the DHT shuts down.
2659        """
2660        request = Request_SessionUnpinDht()
2661        response = await self._client.invoke(request)
2662        if isinstance(response, Response_Unit):
2663            return
2664        raise UnexpectedResponse()

Unpin the DHT. If the DHT is not pinned and there are no more active DHT lookups and no DHT-enabled repositories, the DHT shuts down.

async def validate_share_token(self, *, token: str) -> str:
2666    async def validate_share_token(
2667        self,
2668        *,
2669        token: str,
2670    ) -> str:
2671        """Checks whether the given string is a valid share token."""
2672        request = Request_SessionValidateShareToken(
2673            token,
2674        )
2675        response = await self._client.invoke(request)
2676        if isinstance(response, Response_ShareToken):
2677            return response.value
2678        raise UnexpectedResponse()

Checks whether the given string is a valid share token.

class SetLocalSecret:
86class SetLocalSecret:
87    """Used to set or change the read or write local secret of a repository."""
88    _variants: ClassVar[dict[str, type]] = {}

Used to set or change the read or write local secret of a repository.

@dataclass
class SetLocalSecret_KeyAndSalt(ouisync.session.SetLocalSecret):
 97@dataclass
 98class SetLocalSecret_KeyAndSalt(SetLocalSecret):
 99    """
100    Use to directly (without doing password hashing) set the `SecretKey` and `PasswordSalt` for
101    read or write access.
102    """
103    _tag: ClassVar[str] = "KeyAndSalt"
104    _shape: ClassVar[str] = "named"
105    key: SecretKey
106    salt: PasswordSalt

Use to directly (without doing password hashing) set the SecretKey and PasswordSalt for read or write access.

SetLocalSecret_KeyAndSalt( key: SecretKey, salt: PasswordSalt)
key: SecretKey
salt: PasswordSalt
@dataclass
class SetLocalSecret_Password(ouisync.session.SetLocalSecret):
90@dataclass
91class SetLocalSecret_Password(SetLocalSecret):
92    """Password provided by the user"""
93    _tag: ClassVar[str] = "Password"
94    _shape: ClassVar[str] = "unnamed"
95    value: Password

Password provided by the user

SetLocalSecret_Password(value: Password)
value: Password
@dataclass
class ShareToken:
113@dataclass
114class ShareToken:
115    """
116    Token to share a repository. It can be encoded as a URL-formatted string and transmitted to
117    other replicas.
118    """
119    _shape: ClassVar[str] = "unnamed"
120    value: str

Token to share a repository. It can be encoded as a URL-formatted string and transmitted to other replicas.

ShareToken(value: str)
value: str
@dataclass
class Stats:
218@dataclass
219class Stats:
220    """Network traffic statistics."""
221    _shape: ClassVar[str] = "named"
222    bytes_tx: int
223    bytes_rx: int
224    throughput_tx: int
225    throughput_rx: int

Network traffic statistics.

Stats(bytes_tx: int, bytes_rx: int, throughput_tx: int, throughput_rx: int)
bytes_tx: int
bytes_rx: int
throughput_tx: int
throughput_rx: int
@dataclass
class StorageSize:
48@dataclass
49class StorageSize:
50    """Strongly typed storage size."""
51    _shape: ClassVar[str] = "named"
52    bytes: int

Strongly typed storage size.

StorageSize(bytes: int)
bytes: int
@dataclass
class TopicId:
247@dataclass
248class TopicId:
249    """
250    Identified of a network stream topic.
251
252    When two connected peers open a stream with the same topic id, they can communicate over it with
253    each other.
254    """
255    _shape: ClassVar[str] = "unnamed"
256    value: bytes

Identified of a network stream topic.

When two connected peers open a stream with the same topic id, they can communicate over it with each other.

TopicId(value: bytes)
value: bytes
class UnexpectedResponse(ouisync.session.OuisyncError):
3633class UnexpectedResponse(OuisyncError):
3634    def __init__(self):
3635        super().__init__(ErrorCode.INVALID_DATA, "unexpected response")

Common base class for all non-exit exceptions.

@dataclass(frozen=True, order=True)
class MonitorId:
 5@dataclass(frozen=True, order=True)
 6class MonitorId:
 7    name: str
 8    disambiguator: int
 9
10    @staticmethod
11    def parse(raw: str) -> "MonitorId":
12        name, _, disambiguator = raw.rpartition(":")
13        return MonitorId(name, int(disambiguator))
14
15    def __str__(self) -> str:
16        return f"{self.name}:{self.disambiguator}"
MonitorId(name: str, disambiguator: int)
name: str
disambiguator: int
@staticmethod
def parse(raw: str) -> MonitorId:
10    @staticmethod
11    def parse(raw: str) -> "MonitorId":
12        name, _, disambiguator = raw.rpartition(":")
13        return MonitorId(name, int(disambiguator))