|
None | __init__ (self, int error=84, int success=0, bool debug=False) |
|
int | connect (self) |
|
bool | is_connected (self) |
|
int | disconnect (self) |
|
Union[List[str], int] | get_bucket_names (self) |
|
int | create_bucket (self, str bucket_name) |
|
int | upload_file (self, str bucket_name, str file_path, Optional[str] key_name=None) |
|
int | download_file (self, str bucket_name, str key_name, str destination_path) |
|
int | delete_file (self, str bucket_name, str key_name) |
|
int | delete_bucket (self, str bucket_name) |
|
Union[List[str], int] | get_bucket_files (self, str bucket_name) |
|
Union[Dict[str, Any], int] | get_bucket_file (self, str bucket_name, str key_name) |
|
Class to manage interaction with an S3-compatible bucket like MinIO.
Definition at line 13 of file bucket.py.
◆ __init__()
None src.lib.bucket.bucket.Bucket.__init__ |
( |
| self, |
|
|
int | error = 84, |
|
|
int | success = 0, |
|
|
bool | debug = False ) |
◆ connect()
int src.lib.bucket.bucket.Bucket.connect |
( |
| self | ) |
|
Connect to the S3 bucket or MinIO service.
Returns:
int: success or error code.
Definition at line 35 of file bucket.py.
◆ create_bucket()
int src.lib.bucket.bucket.Bucket.create_bucket |
( |
| self, |
|
|
str | bucket_name ) |
Create a new bucket.
Args:
bucket_name (str): Name of the bucket to create.
Returns:
int: success or error code.
Definition at line 132 of file bucket.py.
◆ delete_bucket()
int src.lib.bucket.bucket.Bucket.delete_bucket |
( |
| self, |
|
|
str | bucket_name ) |
Delete a bucket.
Args:
bucket_name (str): Name of the bucket to delete.
Returns:
int: success or error code.
Definition at line 239 of file bucket.py.
◆ delete_file()
int src.lib.bucket.bucket.Bucket.delete_file |
( |
| self, |
|
|
str | bucket_name, |
|
|
str | key_name ) |
Delete a file from the specified bucket.
Args:
bucket_name (str): Name of the bucket.
key_name (str): Name of the file to delete.
Returns:
int: success or error code.
Definition at line 213 of file bucket.py.
◆ disconnect()
int src.lib.bucket.bucket.Bucket.disconnect |
( |
| self | ) |
|
Disconnect from the S3-compatible service by setting the connection to None.
Returns:
int: success or error code.
Definition at line 85 of file bucket.py.
◆ download_file()
int src.lib.bucket.bucket.Bucket.download_file |
( |
| self, |
|
|
str | bucket_name, |
|
|
str | key_name, |
|
|
str | destination_path ) |
Download a file from the specified bucket.
Args:
bucket_name (str): Name of the target bucket.
key_name (str): Name of the file to download.
destination_path (str): Local path where the file will be saved.
Returns:
int: success or error code.
Definition at line 186 of file bucket.py.
◆ get_bucket_file()
Union[Dict[str, Any], int] src.lib.bucket.bucket.Bucket.get_bucket_file |
( |
| self, |
|
|
str | bucket_name, |
|
|
str | key_name ) |
Get information about a specific file in the bucket.
Args:
bucket_name (str): Name of the bucket.
key_name (str): Name of the file.
Returns:
Union[Dict[str, Any], int]: File metadata (path and size) or error code.
Definition at line 288 of file bucket.py.
◆ get_bucket_files()
Union[List[str], int] src.lib.bucket.bucket.Bucket.get_bucket_files |
( |
| self, |
|
|
str | bucket_name ) |
List all files in the specified bucket.
Args:
bucket_name (str): Name of the bucket.
Returns:
Union[List[str], int]: List of file names or error code.
Definition at line 265 of file bucket.py.
◆ get_bucket_names()
Union[List[str], int] src.lib.bucket.bucket.Bucket.get_bucket_names |
( |
| self | ) |
|
Retrieve a list of all bucket names.
Returns:
Union[List[str], int]: A list of bucket names or error code.
Definition at line 113 of file bucket.py.
◆ is_connected()
bool src.lib.bucket.bucket.Bucket.is_connected |
( |
| self | ) |
|
Check if the connection to the S3-compatible service is active.
Returns:
bool: True if connected, False otherwise.
Definition at line 62 of file bucket.py.
◆ upload_file()
int src.lib.bucket.bucket.Bucket.upload_file |
( |
| self, |
|
|
str | bucket_name, |
|
|
str | file_path, |
|
|
Optional[str] | key_name = None ) |
Upload a file to the specified bucket.
Args:
bucket_name (str): Name of the target bucket.
file_path (str): Path of the file to upload.
key_name (Optional[str]): Name to save the file as in the bucket. Defaults to the file path name.
Returns:
int: success or error code.
Definition at line 158 of file bucket.py.
◆ connection
Optional[boto3.resource] src.lib.bucket.bucket.Bucket.connection = None |
◆ debug
bool src.lib.bucket.bucket.Bucket.debug = debug |
◆ disp
Disp src.lib.bucket.bucket.Bucket.disp |
Initial value:= Disp(
TOML_CONF,
FILE_DESCRIPTOR,
SAVE_TO_FILE,
FILE_NAME,
debug=self.debug,
logger=self.__class__.__name__
)
Definition at line 24 of file bucket.py.
◆ error
int src.lib.bucket.bucket.Bucket.error = error |
◆ success
int src.lib.bucket.bucket.Bucket.success = success |
The documentation for this class was generated from the following file: