synology_apm_repo.sdk.profiles package¶
Saved S3/Azure/SMB connection profiles, shared by the CLI and TUI: the
non-secret half in profiles.json, secrets in the OS keyring. Outside
the layer stack: it builds ObjectStore instances and lists a backend’s
buckets/containers through storage, but reads no repository.
The I/O functions are async, running file and keyring access off the
event loop (a keyring prompt must not freeze the TUI). config_dir
overrides the per-user config directory. get_profile and the listing
functions never touch the keyring, so they can’t leak a secret;
profile_fields_with_secrets and store_from_profile read it.
- class synology_apm_repo.sdk.profiles.AzureProfileConfig(container, account_url=None, verify_tls=True)¶
Bases:
objectNon-secret
AzureStoreconstructor inputs.credentialis not a field here — seesecrets.py.- kind: ClassVar[BackendKind] = 'azure'¶
- open_store(**client_kwargs)¶
The
AzureStorefor this container; seeS3ProfileConfig.open_store.- Raises:
ProfileFieldError – Azure rejected
account_url(missing or malformed).
- class synology_apm_repo.sdk.profiles.BackendKind(*values)¶
Bases:
StrEnumWhich backend a profile targets; the value is also its CLI/TUI name.
- S3 = 's3'¶
- AZURE = 'azure'¶
- SMB = 'smb'¶
- class synology_apm_repo.sdk.profiles.Profile(name, config)¶
Bases:
objectOne saved profile, keyed by its user-chosen
name(unique across every backend kind). Never carries secret values.- config: S3ProfileConfig | AzureProfileConfig | SmbProfileConfig¶
- property kind: BackendKind¶
The backend this profile targets, its config’s
kind.
- exception synology_apm_repo.sdk.profiles.ProfileConfigCorruptError(message, *, ref=None, spec=None)¶
Bases:
ApmRepoErrorprofiles.jsonfailed to parse, or failed schema validation (badschema_version, unknownkind, missing/malformed field). Not aDataCorruptError: the file is local configuration, not repository data.
- exception synology_apm_repo.sdk.profiles.ProfileFieldError(field, message)¶
Bases:
ValueErrorA connection-profile field is missing or malformed (a blank required field, a non-numeric port): a user-input problem, hence a
ValueErrorrather than part of the on-disk-data hierarchy.- Variables:
field – The canonical field name (
"bucket","port", …).
- class synology_apm_repo.sdk.profiles.ProfileFieldSpec(name, strip=True, is_checkbox=False, is_port=False, required=False, secret=False, prompt='')¶
Bases:
objectOne profile field, in canonical collection/display order for its backend: what a connection form binds and how
config_from_fieldsreads it.- Variables:
name (str) – The canonical field name.
strip (bool) – Whether leading/trailing whitespace is dropped;
Falsewhere it might be significant (secret_key/credential/password).is_checkbox (bool) – A boolean field, true when absent.
is_port (bool) – A port number,
DEFAULT_SMB_PORTwhen blank.required (bool) – Must be non-blank.
secret (bool) – Kept in the OS keyring, never in
profiles.json.prompt (str) – The interactive prompt for a secret field.
- exception synology_apm_repo.sdk.profiles.ProfileNotFoundError(message, *, ref=None, spec=None)¶
Bases:
NotFoundErrorThe named S3/Azure/SMB connection profile does not exist in
profiles.json.
Bases:
ApmRepoErrorNo usable OS keyring backend can store or retrieve a profile’s secret fields:
keyringfailed to import or resolved no real backend (e.g. headless Linux without Secret Service).
- class synology_apm_repo.sdk.profiles.S3ProfileConfig(bucket, endpoint=None, region=None, verify_tls=True)¶
Bases:
objectNon-secret
S3Storeconstructor inputs.access_key/secret_keyare not fields here — seesecrets.py.- kind: ClassVar[BackendKind] = 's3'¶
- open_store(**client_kwargs)¶
The
S3Storefor this bucket, built withclient_kwargs(client_kwargs_with_secrets’s result).
- class synology_apm_repo.sdk.profiles.SmbProfileConfig(server, share, port=445, username=None)¶
Bases:
objectNon-secret
SmbStoreconstructor inputs.passwordis not a field here — seesecrets.py.usernamemay carry a domain asDOMAIN\usernameoruser@domain; a profile names a whole share.- kind: ClassVar[BackendKind] = 'smb'¶
- open_store(**client_kwargs)¶
The
SmbStorefor this share; seeS3ProfileConfig.open_store.
- synology_apm_repo.sdk.profiles.account_client_kwargs(kind, fields)¶
The account-level client kwargs (no bucket/container chosen yet) that
list_remote_itemstakes, from a connection form’s rawfields.
- synology_apm_repo.sdk.profiles.config_from_fields(kind, fields, *, check_required=True)¶
fields(canonical names, as a connection form or the CLI collects them; extra keys, secrets included, are ignored) turned intokind’s config. A blank optional field means “not set”; a blank port meansDEFAULT_SMB_PORT.check_required=Falseaccepts blank required fields, for an account-level operation (listing buckets) that has none chosen yet.- Raises:
ProfileFieldError – A required field is blank, or the port is not a number.
- async synology_apm_repo.sdk.profiles.delete_profile(name, *, config_dir=None)¶
Remove profile
nameand its keyring secrets; theprofiles.jsonentry goes first.- Raises:
ProfileNotFoundError – No such profile.
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.ProfileSecretBackendUnavailableError – No usable keyring (the profile is already removed from
profiles.json).
- synology_apm_repo.sdk.profiles.form_fields_for(kind)¶
kind’s full field list, in canonical order — every field a connection form binds, secrets included.
- async synology_apm_repo.sdk.profiles.get_profile(name, *, config_dir=None)¶
The non-secret half of profile
name, safe to display or log.- Raises:
ProfileNotFoundError – No such profile.
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.
- async synology_apm_repo.sdk.profiles.list_profiles(*, config_dir=None)¶
Every saved profile’s non-secret half, sorted by name, from one read of
profiles.json.- Raises:
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.
- async synology_apm_repo.sdk.profiles.list_remote_items(kind, **client_kwargs)¶
Every bucket (S3) or container (Azure) reachable with the resolved
client_kwargs(seeaccount_client_kwargs).- Raises:
ValueError –
kindisSMB, which has no account-level listing.
- async synology_apm_repo.sdk.profiles.profile_fields_with_secrets(name, *, config_dir=None)¶
Every field of profile
name, secrets included and unmasked, under the canonical field names, for refilling a connection form; useget_profilefor anything displayed or logged.- Raises:
ProfileNotFoundError – No such profile.
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.ProfileSecretBackendUnavailableError – No usable keyring.
- async synology_apm_repo.sdk.profiles.save_profile(name, kind, fields, *, config_dir=None)¶
Save profile
name, replacing an existing one’s non-secret half; secrets are merged into those already stored (an empty one is left as stored).fieldsusesprofile_fields_with_secrets’s canonical names. The fields and the existingprofiles.jsonare checked before anything is written, and secrets are written beforeprofiles.json, so a listed profile never lacks its secrets.- Raises:
ProfileFieldError – A required field is blank or malformed.
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.ProfileSecretBackendUnavailableError – No usable keyring.
- async synology_apm_repo.sdk.profiles.store_from_config(config, secret_source)¶
The
ObjectStoreforconfigwith credentials fromsecret_source(seeclient_kwargs_with_secrets), saved as a profile or not.- Raises:
ProfileFieldError – Azure rejected
account_url(missing or malformed); S3 and SMB check their settings on first use.
- async synology_apm_repo.sdk.profiles.store_from_fields(kind, fields)¶
store_from_configfor a not-yet-saved connection form’s rawfields(secrets included, canonical names).- Raises:
ProfileFieldError – A required field is blank or malformed, or (see
store_from_config) Azure rejectedaccount_url.
- async synology_apm_repo.sdk.profiles.store_from_profile(name, *, config_dir=None)¶
Profile
namewith its keyring secrets, as a store forSession.discover()/open(); the session then owns and closes it.- Raises:
ProfileNotFoundError – No such profile.
ProfileConfigCorruptError –
profiles.jsonis unreadable or invalid.ProfileSecretBackendUnavailableError – No usable keyring.
ProfileFieldError – Azure rejected the saved
account_url.
Submodules¶
- synology_apm_repo.sdk.profiles.config_file module
- synology_apm_repo.sdk.profiles.model module
- synology_apm_repo.sdk.profiles.secrets module