synology_apm_repo.sdk.profiles.model module

Data model for saved S3/Azure/SMB connection profiles.

Profile fields go by one canonical name everywhere (CLI flags, TUI forms, these dataclasses): bucket/endpoint/region/verify_tls/… Each config’s client_kwargs translates them to its client’s kwarg names. Secret fields (S3’s access/secret key, Azure’s credential, SMB’s password) live in the OS keyring, never on these dataclasses; client_kwargs_with_secrets merges them in.

class synology_apm_repo.sdk.profiles.model.BackendKind(*values)

Bases: StrEnum

Which backend a profile targets; the value is also its CLI/TUI name.

S3 = 's3'
AZURE = 'azure'
SMB = 'smb'
class synology_apm_repo.sdk.profiles.model.S3ProfileConfig(bucket, endpoint=None, region=None, verify_tls=True)

Bases: object

Non-secret S3Store constructor inputs. access_key/ secret_key are not fields here — see secrets.py.

kind: ClassVar[BackendKind] = 's3'
bucket: str
endpoint: str | None
region: str | None
verify_tls: bool
open_store(**client_kwargs)

The S3Store for this bucket, built with client_kwargs (client_kwargs_with_secrets’s result).

property client_kwargs: dict[str, Any]

S3Store kwargs for everything but bucket and the secrets.

property display_fields: dict[str, str | None]

Ordered field name -> value pairs the CLI and TUI display.

property label: str

s3://<bucket>, how CLI/TUI name the store this config opens.

class synology_apm_repo.sdk.profiles.model.AzureProfileConfig(container, account_url=None, verify_tls=True)

Bases: object

Non-secret AzureStore constructor inputs. credential is not a field here — see secrets.py.

kind: ClassVar[BackendKind] = 'azure'
container: str
account_url: str | None
verify_tls: bool
open_store(**client_kwargs)

The AzureStore for this container; see S3ProfileConfig.open_store.

Raises:

ProfileFieldError – Azure rejected account_url (missing or malformed).

property client_kwargs: dict[str, Any]

AzureStore kwargs for everything but container and the secret (TLS verification is connection_verify there).

property display_fields: dict[str, str | None]

Same role as S3ProfileConfig.display_fields.

property label: str

azure://<container>; see S3ProfileConfig.label.

class synology_apm_repo.sdk.profiles.model.SmbProfileConfig(server, share, port=445, username=None)

Bases: object

Non-secret SmbStore constructor inputs. password is not a field here — see secrets.py. username may carry a domain as DOMAIN\username or user@domain; a profile names a whole share.

kind: ClassVar[BackendKind] = 'smb'
server: str
share: str
port: int
username: str | None
open_store(**client_kwargs)

The SmbStore for this share; see S3ProfileConfig.open_store.

property client_kwargs: dict[str, Any]

SmbStore kwargs for everything but share and the secret.

property display_fields: dict[str, str | int | None]

Same role as S3ProfileConfig.display_fields.

property label: str

smb://<server>/<share>; see S3ProfileConfig.label.

synology_apm_repo.sdk.profiles.model.ProfileConfig = synology_apm_repo.sdk.profiles.model.S3ProfileConfig | synology_apm_repo.sdk.profiles.model.AzureProfileConfig | synology_apm_repo.sdk.profiles.model.SmbProfileConfig

Any backend’s non-secret profile config.

class synology_apm_repo.sdk.profiles.model.Profile(name, config)

Bases: object

One saved profile, keyed by its user-chosen name (unique across every backend kind). Never carries secret values.

name: str
config: S3ProfileConfig | AzureProfileConfig | SmbProfileConfig
property kind: BackendKind

The backend this profile targets, its config’s kind.

class synology_apm_repo.sdk.profiles.model.ProfileFieldSpec(name, strip=True, is_checkbox=False, is_port=False, required=False, secret=False, prompt='')

Bases: object

One profile field, in canonical collection/display order for its backend: what a connection form binds and how config_from_fields reads it.

Variables:
  • name (str) – The canonical field name.

  • strip (bool) – Whether leading/trailing whitespace is dropped; False where 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_PORT when 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.

name: str
strip: bool
is_checkbox: bool
is_port: bool
required: bool
secret: bool
prompt: str
synology_apm_repo.sdk.profiles.model.form_fields_for(kind)

kind’s full field list, in canonical order — every field a connection form binds, secrets included.

synology_apm_repo.sdk.profiles.model.secret_fields_for(kind)

Which field names are secret (keyring-backed) for kind — the rest are plain config, persisted to profiles.json.

synology_apm_repo.sdk.profiles.model.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 into kind’s config. A blank optional field means “not set”; a blank port means DEFAULT_SMB_PORT. check_required=False accepts 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.

synology_apm_repo.sdk.profiles.model.config_from_json(kind, raw)

kind’s config from one saved profiles.json entry, strictly: nothing is coerced, so a hand-edited "false" is rejected rather than read as true.

Raises:
  • KeyError – A required field is missing.

  • TypeError – A field has the wrong JSON type.

synology_apm_repo.sdk.profiles.model.client_kwargs_with_secrets(config, secrets)

config.client_kwargs plus each of its kind’s secret fields that secrets holds as a non-empty string; other keys in secrets are ignored.