synology_apm_repo.sdk.api.session module¶
Session: repository discovery, and the lifetime of the stores and
Repository instances it hands out.
- class synology_apm_repo.sdk.api.session.Session¶
Bases:
AsyncClosingDiscovers repositories and owns every store and
Repositoryit hands out. Use as an async context manager or callclose;close_reporeleases one repository early.- async discover(source, key=None, *, root='', progress=None, trace=None)¶
Walk
sourcefor repositories, yielding each as it’s opened (opencollects them). A candidate with nothing to browse, or whose key record is unreadable, is skipped.- Parameters:
source (Path | str | ObjectStore) – A local directory, or an
ObjectStore(S3/Azure/SMB/…) this session takes ownership of.key (str | None) –
"<userKeyID>@<base64 userKey>", verified against each repository found. When omitted, each repository’sis_encryptedis probed instead.root (str) – The path within
sourceto scan from.progress (ProgressCallback | None) – Receives an indeterminate
Progressper candidate found.trace (Callable[[TraceEvent], None] | None) – Receives a
TraceEventfor everyObjectStorecall the yielded repositories make, for their whole lifetime.
- Raises:
KeyMaterialError –
keyis malformed.StorageBackendError – The store failed while scanning.
ExceptionGroup – Closing the store failed after
close_reporeleased its last repository mid-discovery.
- async open(source, key=None, *, root='', progress=None, trace=None)¶
discover, collected into a list.
- async resolve(ref, *, raw=None)¶
Repository.resolveon whichever open repository ownsref.repo_path; a caller holding the repository already can call that directly.- Raises:
NotFoundError – No open repository owns the ref, or no node matches it.
InvalidArgumentError – See
Repository.resolve.KeyRequiredError – See
Repository.resolve.KeyMismatchError – See
Repository.resolve.ValueError – The string is not a parseable ref.
- async close_repo(repo)¶
Close and forget one repository, and its store when no other tracked repository shares it and no discovery over it is still running.
- Raises:
ExceptionGroup – The repository or its store failed to close.
- async close()¶
Close every repository this session handed out, then every store it owns (the network clients of S3/Azure/SMB stores).
- Raises:
ExceptionGroup – One or more resources failed to close (every one was still attempted).