graflo.object_storage¶
S3-compatible object storage helpers (boto3): config, client, bucket ensure.
This package is separate from graph :class:~graflo.db.ConnectionManager targets.
Use :class:~graflo.object_storage.config.S3EndpointConfig; its
:meth:~graflo.object_storage.config.S3EndpointConfig.from_docker_env reads
the bundled S3 service's settings, as Neo4jConfig.from_docker_env does.
Modules:
| Name | Description |
|---|---|
bucket |
Ensure S3 buckets exist (idempotent). |
config |
S3-compatible endpoint configuration (SeaweedFS, AWS S3, MinIO, etc.). |
s3_client |
Shared boto3 S3 client construction. |
Attributes¶
__all__ = ['S3EndpointConfig', 'boto3_s3_client', 'boto3_s3_client_from_endpoint', 'ensure_bucket_exists', 'ensure_staging_bucket_for_config']
module-attribute
¶
Classes¶
S3EndpointConfig
¶
Bases: BaseModel
Credentials and endpoint for any S3-compatible API (boto3).
Source code in graflo/object_storage/config.py
Attributes¶
access_key = Field(description='S3 access key id.')
class-attribute
instance-attribute
¶
bucket = Field(default='graflo-staging', description='Default bucket.')
class-attribute
instance-attribute
¶
endpoint_url = Field(description='Base URL for the S3 API, e.g. http://127.0.0.1:8333')
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='forbid')
class-attribute
instance-attribute
¶
region = Field(default='us-east-1', description='AWS region string passed to boto3 (us-east-1 for a local S3 service).')
class-attribute
instance-attribute
¶
secret_key = Field(description='S3 secret access key.')
class-attribute
instance-attribute
¶
Methods:¶
from_docker_env(docker_dir=None)
classmethod
¶
Load the S3 service settings of docker/seaweedfs.
Reads <docker_dir>/.env.example when it exists; every setting has a default
matching the bundled compose file, whose S3 API accepts any key pair, so
the file is optional.
Settings: S3_ENDPOINT (or S3_PROTOCOL, S3_HOSTNAME,
S3_API_PORT), S3_ACCESS_KEY, S3_SECRET_KEY, S3_BUCKET
and AWS_REGION.
Source code in graflo/object_storage/config.py
to_files_conn_config()
¶
The files connection of :attr:bucket, as a connection provider stores it.
Source code in graflo/object_storage/config.py
Functions:¶
boto3_s3_client(cfg)
¶
Build a boto3 S3 client from :class:~graflo.connections.sources.S3ConnConfig.
Source code in graflo/object_storage/s3_client.py
boto3_s3_client_from_endpoint(cfg)
¶
Build a boto3 S3 client from :class:~graflo.object_storage.config.S3EndpointConfig.
Source code in graflo/object_storage/s3_client.py
ensure_bucket_exists(client, bucket)
¶
Create bucket if it does not exist. Return bucket.
Safe to call repeatedly. Raises :exc:botocore.exceptions.ClientError
for non-recoverable API errors.
Source code in graflo/object_storage/bucket.py
ensure_staging_bucket_for_config(cfg=None)
¶
Ensure :attr:~graflo.object_storage.config.S3EndpointConfig.bucket exists.
If cfg is None, loads :meth:~graflo.object_storage.config.S3EndpointConfig.from_docker_env.