jetraw.storages module¶
Storage management for Jetraw.
Storages are backend storage systems used by spaces to store files and folders. The platform supports AWS S3, custom S3-compatible backends, and local storage.
- class jetraw.storages.Storage(storage, client)¶
Bases:
object
Represents a Jetraw storage backend.
Storages are backend storage systems that spaces use to store files and folders. Supported types include AWS S3, custom S3-compatible backends, and local storage.
Example
>>> # Create a local storage >>> storage = create_storage("local-backup", "local", "Backup Storage", "/data/backup") >>> >>> # Create an AWS S3 storage >>> s3_storage = create_aws_s3_storage("s3-backup", "S3 Backup", "us-west-2", "my-bucket") >>> >>> # Update storage properties >>> storage.name = "Updated Backup Storage" >>> storage.label = "Primary Backup"
- checksums()¶
Get checksums for files in this storage.
- Yields:
tuple – (upload_id, checksum, checksum_on_disk) for each file
Example
>>> storage = get_storage("my-storage") >>> for upload_id, checksum, disk_checksum in storage.checksums(): ... print(f"File {upload_id}: {checksum}")
- property created_at: datetime¶
Get the timestamp when the storage was created.
- property default_url: str¶
Get the default URL for the storage.
- property id: str¶
Get the unique identifier of the storage.
- property label: str¶
Get the storage label.
- property name: str¶
Get the storage name.
- remove()¶
Delete this storage.
- Raises:
RuntimeError – If the storage deletion fails
Example
>>> storage = get_storage("my-storage") >>> storage.remove() # Storage is now deleted
- property type: str¶
Get the storage type (S3 or local).
- property url: str | None¶
Get the current URL for the storage (may be overridden).
- jetraw.storages.create_aws_s3_storage(name, label, region, bucket, *, client=None)¶
Create a new AWS S3 storage backend.
- Parameters:
name (
str
) – Unique name for the storagelabel (
str
) – Human-readable label for the storageregion (
str
) – AWS region (e.g., “us-west-2”, “eu-central-1”)bucket (
str
) – S3 bucket nameclient (
Client
) – Jetraw client instance (uses default if None)
- Returns:
The created AWS S3 storage
- Return type:
- Raises:
ValueError – If parameters are invalid
Example
>>> # Create an AWS S3 storage >>> storage = create_aws_s3_storage("s3-backup", "S3 Backup", "us-west-2", "my-bucket") >>> print(f"Created S3 storage: {storage.name}")
- jetraw.storages.create_storage(name, type, label, default_url, *, client=None)¶
Create a new storage backend.
- Parameters:
name (
str
) – Unique name for the storagetype (
str
) – Storage type (“S3” or “local”)label (
str
) – Human-readable label for the storagedefault_url (
str
) – Default URL for the storageclient (
Client
) – Jetraw client instance (uses default if None)
- Returns:
The created storage
- Return type:
- Raises:
ValueError – If parameters are invalid
Example
>>> # Create a local storage >>> storage = create_storage("local-backup", "local", "Backup Storage", "/data/backup") >>> >>> # Create an S3 storage >>> storage = create_storage("s3-backup", "S3", "S3 Backup", "https://storage-server:PORT/my-bucket")
- jetraw.storages.get_storage(name, *, client=None)¶
Get a storage by name.
- Parameters:
name (
str
) – Name of the storage to retrieveclient (
Client
) – Jetraw client instance (uses default if None)
- Returns:
The storage object
- Return type:
- Raises:
KeyError – If the storage is not found
Example
>>> storage = get_storage("my-storage") >>> print(f"Storage: {storage.label}")
- jetraw.storages.list_storages(*, client=None)¶
List all storages accessible to the current user.
- Parameters:
client (
Client
) – Jetraw client instance (uses default if None)- Returns:
List of all accessible storages
- Return type:
list[Storage]
Example
>>> # List all storages >>> storages = list_storages() >>> for storage in storages: ... print(f"{storage.name}: {storage.type}")