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: AsyncClosing

Discovers repositories and owns every store and Repository it hands out. Use as an async context manager or call close; close_repo releases one repository early.

async discover(source, key=None, *, root='', progress=None, trace=None)

Walk source for repositories, yielding each as it’s opened (open collects 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’s is_encrypted is probed instead.

  • root (str) – The path within source to scan from.

  • progress (ProgressCallback | None) – Receives an indeterminate Progress per candidate found.

  • trace (Callable[[TraceEvent], None] | None) – Receives a TraceEvent for every ObjectStore call the yielded repositories make, for their whole lifetime.

Raises:
async open(source, key=None, *, root='', progress=None, trace=None)

discover, collected into a list.

async resolve(ref, *, raw=None)

Repository.resolve on whichever open repository owns ref.repo_path; a caller holding the repository already can call that directly.

Raises:
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).