2# +==== BEGIN CatFeeder =================+
5# ...............)..(.')
7# ...............\(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
13# FILE: bucket_class_aliases.py
14# CREATION DATE: 19-11-2025
15# LAST Modified: 14:41:58 19-12-2025
17# This is the backend server in charge of making the actual website work.
18# Protocol aliases for the S3 bucket wrapper.
20# These lightweight ``typing.Protocol`` classes describe only the subset of the boto3 S3 interface that the bucket wrapper relies on.
21# They allow static type checking without introducing optional stub packages or a hard dependency on external type distributions.
23# COPYRIGHT: (c) Cat Feeder
24# PURPOSE: Class aliases used to help with typing for the bucket wrapper.
26# +==== END CatFeeder =================+
29from typing
import Protocol, Any, Iterable
33 """Minimal shape of an object stored in a bucket.
35 Only the attributes and methods actually accessed by the
36 wrapper are declared here.
40 """Return the byte size of the object's content."""
41 raise NotImplementedError
44 """Delete the object from its parent bucket."""
45 raise NotImplementedError
49 """Return the object key (its unique path within the bucket)."""
50 raise NotImplementedError
53 """Retrieve the object and return a response containing the object's body and metadata."""
54 raise NotImplementedError
58 """Iterable collection façade exposing ``all()`` to enumerate objects."""
60 def all(self) -> Iterable[S3ObjectLike]:
61 """Return an iterable over all objects in the collection."""
62 raise NotImplementedError
66 """Minimal bucket interface used for file/object operations."""
69 """Upload a local file specified by ``Filename`` to this bucket under ``Key``."""
70 raise NotImplementedError
73 """Download the object at ``Key`` into the local file path ``Filename``."""
74 raise NotImplementedError
77 """Upload a byte stream to this bucket under ``Key``."""
78 raise NotImplementedError
81 """Delete the bucket itself (must be empty)."""
82 raise NotImplementedError
84 def Object(self, key: str) -> S3ObjectLike:
85 """Return an object handle for the given key inside this bucket."""
86 raise NotImplementedError
89 def objects(self) -> S3ObjectsCollectionLike:
90 """Return a collection façade exposing enumeration of bucket objects."""
91 raise NotImplementedError
95 """Collection façade for listing bucket resources."""
97 def all(self) -> Iterable[Any]:
98 """Return an iterable over all available bucket resources (each with ``.name``)."""
99 raise NotImplementedError
103 """Top-level S3 service resource surface used by the wrapper.
105 Provides bucket lookup, bucket creation and metadata client
106 access for connectivity checks.
108 buckets: S3BucketsCollectionLike
111 def Bucket(self, name: str) -> S3BucketLike:
112 """Return a bucket handle for the given name."""
113 raise NotImplementedError
116 """Create a new bucket named ``Bucket`` with optional configuration ``kwargs``."""
117 raise NotImplementedError
Any upload_file(self, str Filename, str Key)
Any put_object(self, str Key, bytes Body)
S3ObjectsCollectionLike objects(self)
Any download_file(self, str Key, str Filename)
S3ObjectLike Object(self, str key)
Iterable[S3ObjectLike] all(self)
S3BucketLike Bucket(self, str name)
Any create_bucket(self, *, str Bucket, **Any kwargs)