EngineConfiguration_ObjectStorageService
What it is
Pydantic-based configuration models and loaders for wiring an ObjectStorageService with a selectable object storage adapter (fs, s3, naas, or custom).
Public API
Classes
-
ObjectStorageAdapterFSConfiguration- Filesystem adapter config.
- Fields:
base_path: str extra="forbid"(unknown fields are rejected)
-
ObjectStorageAdapterS3Configuration- S3-compatible adapter config.
- Fields:
bucket_name: strbase_prefix: straccess_key_id: strsecret_access_key: strsession_token: str | None = Noneendpoint_url: str | None = None
extra="forbid"
-
ObjectStorageAdapterNaasConfiguration- Naas object storage adapter config.
- Fields:
naas_api_key: strworkspace_id: strstorage_name: strbase_prefix: str = ""
extra="forbid"
-
ObjectStorageAdapterConfiguration(extendsGenericLoader)- Selects which adapter to instantiate and validates its config.
- Fields:
adapter: Literal["fs", "s3", "naas", "custom"]config: ObjectStorageAdapterFSConfiguration | ObjectStorageAdapterS3Configuration | ObjectStorageAdapterNaasConfiguration | None = None
- Methods:
validate_adapter() -> Self(Pydantic model validator)- Requires
configwhenadapter != "custom" - Validates
configtype/shape against the selected adapter model
- Requires
load() -> IObjectStorageAdapter- For
fs,s3,naas: imports and instantiates the corresponding adapter withconfig.model_dump() - For
custom: delegates toGenericLoader.load()
- For
-
ObjectStorageServiceConfiguration- Top-level service configuration.
- Fields:
object_storage_adapter: ObjectStorageAdapterConfiguration - Methods:
load() -> ObjectStorageService- Builds
ObjectStorageService(adapter=...)using the configured adapter.
- Builds
Configuration/Dependencies
- Depends on Pydantic v2 features (
BaseModel,ConfigDict,model_validator). - Adapter-specific implementations are imported at load time:
naas_abi_core.services.object_storage.adapters.secondary.ObjectStorageSecondaryAdapterFSnaas_abi_core.services.object_storage.adapters.secondary.ObjectStorageSecondaryAdapterS3naas_abi_core.services.object_storage.adapters.secondary.ObjectStorageSecondaryAdapterNaas
customadapter path is handled byGenericLoader(not defined in this file).
Usage
from naas_abi_core.engine.engine_configuration.EngineConfiguration_ObjectStorageService import (
ObjectStorageServiceConfiguration,
ObjectStorageAdapterConfiguration,
ObjectStorageAdapterFSConfiguration,
)
cfg = ObjectStorageServiceConfiguration(
object_storage_adapter=ObjectStorageAdapterConfiguration(
adapter="fs",
config=ObjectStorageAdapterFSConfiguration(base_path="storage/datastore"),
)
)
service = cfg.load() # ObjectStorageService with FS adapter
Caveats
configis required foradaptervaluesfs,s3, andnaas. Missing it triggers an assertion error.- Unknown fields in adapter config models are rejected (
extra="forbid"). - Selecting
adapter="custom"bypasses the built-in adapter validation/instantiation and relies onGenericLoaderbehavior.