aeat.adapters.outbound.storage._factory module¶
get_storage_provider() factory keyed on ProviderKind.
The factory is the single entry point upper layers (sync coordinator,
CLI commands, application services) call to obtain a
adapters.outbound.storage.StorageProvider configured for the
active profile. core.config.Settings drives the choice:
aeat_storage_provider_kindselects the backend.aeat_local_storage_rootchooses the root directory for the local backend.aeat_google_drive_root_folder_idplus the per-profile persistedGoogleCredentialSourceKindselection (GoogleCredentialSourceSelection, loaded viaadapters.outbound.google._session_store) parameterise the Drive backend’s credentials — either the default per-profileOAuthClient/OAuthTokenrecords, or a service-account impersonation grant resolved viaresolve_impersonated_credentials().
Composition order:
Resolve the active profile via
adapters.outbound.google._active_profile.resolve_active_profile().Read settings via
load_settings().Dispatch on
ProviderKind.LOCAL_FILESYSTEMbuilds aadapters.outbound.storage._local.LocalFileSystemProviderrooted ataeat_local_storage_root / profile;GOOGLE_DRIVEcallsbuild_google_credentials(), which reads the profile’s persistedGoogleCredentialSourceSelection(a missing selection defaults toOAUTH_DESKTOP, preserving the existing default byte-for-byte) and dispatches to either the OAuth-Desktop hydration orresolve_impersonated_credentials(), then instantiatesadapters.outbound.storage._google_drive.GoogleDriveProviderkeyed onaeat_google_drive_root_folder_id.Refuse unknown kinds with
OutboundStorageValidationError.
- build_google_credentials(*, profile)[source]¶
Resolve Google
Credentialsfor the profile’s chosen credential source.Reads the profile’s persisted
GoogleCredentialSourceSelection(load_credential_source_selection()). A missing selection defaults toOAUTH_DESKTOP, so a profile that has never opted into service-account impersonation gets byte-for-byte the same behaviour as before this dispatch existed.OAUTH_DESKTOP(the default): hydratesCredentialsfrom the per-profileOAuthClientandOAuthTokenrecords via_build_oauth_desktop_credentials().SERVICE_ACCOUNT_IMPERSONATION: delegates toresolve_impersonated_credentials()with the persistedGoogleImpersonationConfig(percomposition-service-no-parallel-write-path: this factory never re-implements ADC discovery or impersonation wrapping).
Imports the upstream Google libraries lazily so unit tests for the local backend do not pay the cost.
- Return type:
Credentials- Parameters:
profile (str)
- resolve_drive_root_folder_id(*, profile, settings)[source]¶
Resolve the Drive root folder id with the canonical precedence.
AEAT_GOOGLE_DRIVE_ROOT_FOLDER_IDenv var /.envvalue (core.config.Settingsaeat_google_drive_root_folder_id; overrides for one-off / CI / debugging without persisting state)Per-profile persisted
adapters.outbound.google.DriveConfigrecord (canonical operator enrolment viaaeat config google folder set <id>)
Returns the empty string when neither source is configured.
- get_storage_provider(*, settings=None)[source]¶
Build a
StorageProviderfor the active AEAT profile.- Parameters:
settings (
Settings|None) – Optional pre-builtcore.config.Settings. Defaults tocore.config.load_settings().- Return type:
- Returns:
A concrete
StorageProvideralready wired with credentials and root directory or folder ID for the resolved profile.- Raises:
OutboundStorageValidationError – When the settings value is unknown, the Drive backend is selected without
aeat_google_drive_root_folder_id, or the profile lacks the records the chosen backend needs.