synology_apm_repo.sdk.units.saas.services module¶
Content inspection for embedded saas_obj objects already located
through the object-name index: open_service_db opens a service DB
snapshot, sniff/inspect_object classify an object’s bytes. Never
used to discover where an object is.
Bytes classify into ServiceKind by a fixed rule: ZSTD-framed SQLite,
then a JSON object, then an RFC822 header, else binary.
- class synology_apm_repo.sdk.units.saas.services.ServiceKind(*values)¶
Bases:
EnumWhat one already-located object’s raw bytes turn out to be (
sniff’s classification).SERVICE_DB: ZSTD -> SQLite; the owning app is guessed from itssqlite_mastertable names (_SERVICE_TABLE_HINTS).INDEX: JSON matching thedb_objects/db_infos_in_snapshotshape (_index_entries) — extracted asIndexEntrytuples.META_JSON: any other JSON object (content-list fragments, Contact/Calendar client metadata, search-index documents).MAIL_SKELETON: an RFC822 header in the first few hundred bytes.BINARY: anything else — the common case for real Drive content.
- INDEX = 'index'¶
- SERVICE_DB = 'service_db'¶
- META_JSON = 'meta_json'¶
- MAIL_SKELETON = 'mail_skeleton'¶
- BINARY = 'binary'¶
- class synology_apm_repo.sdk.units.saas.services.IndexEntry(name, object_id)¶
Bases:
objectOne entry in a connector’s own index object: a display name paired with the backing object id.
- class synology_apm_repo.sdk.units.saas.services.SniffResult(kind, tables=frozenset({}), service_name=None, index_entries=())¶
Bases:
objectWhat sniffing a service-DB/index object’s bytes found: its
ServiceKind, plus whichever oftables/service_name/index_entriesthat kind actually carries.- kind: ServiceKind¶
- index_entries: tuple[IndexEntry, ...]¶
- async synology_apm_repo.sdk.units.saas.services.open_service_db(data)¶
Decompress one service-level DB snapshot’s bytes into a temp file and open it as SQLite; the caller closes the returned source. No fixed size cap, since the object was already identified through the index; a frame declaring no size is bounded by the free disk space above the reserve.
- Raises:
DataCorruptError –
dataisn’t ZSTD-framed SQLite.ResourceLimitExceededError – The decompressed size doesn’t fit in free disk space with the reserve left free.
- async synology_apm_repo.sdk.units.saas.services.sniff(data)¶
Classify one object’s raw bytes into a
ServiceKind. Touches no repository; decompression runs off the event loop.A zstd frame that fails to decompress, or declares a size over
_MAX_SNIFF_DECOMPRESS(checked before decompressing, sincedatais untrusted), is unclassifiable rather than an error, as is{-prefixed data that doesn’t parse as JSON (invalid, or nested too deep for the decoder).- Raises:
sqlite3.DatabaseError – The payload has the SQLite magic but its table list can’t be read.
ResourceLimitExceededError – The decompressed SQLite payload doesn’t fit in free disk space with the reserve left free.
- async synology_apm_repo.sdk.units.saas.services.inspect_object(dedup_file, offset, length)¶
sniffan already-located object, reading only its head when it’s over_FULL_READ_CAPand not zstd-framed.- Raises:
sqlite3.DatabaseError – As
sniff.ResourceLimitExceededError – As
sniff, or a zstd-framed object is overDedupFile.read()’s single-read ceiling.