π§° API Reference#
exasol.bucketfs.Service#
- class exasol.bucketfs.Service(url: str, credentials: Mapping[str, Mapping[str, str]] | None = None)[source]
Bases:
objectProvides a simple to use api to access a bucketfs service.
- buckets
lists all available buckets.
- __init__(url: str, credentials: Mapping[str, Mapping[str, str]] | None = None)[source]
Create a new Service instance.
- Parameters:
url β of the bucketfs service, e.g. http(s)://127.0.0.1:2580.
credentials β a mapping containing credentials (username and password) for buckets. E.g. {βbucket1β: { βusernameβ: βfooβ, βpasswordβ: βbarβ }}
- property buckets: MutableMapping[str, Bucket]
List all available buckets.
exasol.bucketfs.Bucket#
- class exasol.bucketfs.Bucket(name: str, service: str, username: str, password: str)[source]#
Bases:
object- __init__(name: str, service: str, username: str, password: str)[source]#
Create a new bucket instance.
- Parameters:
name β of the bucket.
service β url where this bucket is hosted on.
username β used for authentication.
password β used for authentication.
- delete(path) None[source]#
Deletes a specific file in this bucket.
- Parameters:
path β points to the file which shall be deleted.
- Raises:
A BucketFsError if the operation couldn't be executed successfully. β
- download(path: str, chunk_size: int = 8192) Iterable[ByteString][source]#
Downloads a specific file of this bucket.
- Parameters:
path β which shall be downloaded.
chunk_size β which shall be used for downloading.
- Returns:
An iterable of binary chunks representing the downloaded file.
- upload(path: str, data: ByteString | BinaryIO | Iterable[ByteString]) None[source]#
Uploads a file onto this bucket
- Parameters:
path β in the bucket the file shall be associated with.
data β raw content of the file.
exasol.bucketfs.as_bytes#
- exasol.bucketfs.as_bytes(chunks: Iterable[ByteString]) ByteString[source]#
Transforms a set of byte chunks into a bytes like object.
- Parameters:
chunks β which shall be concatenated.
- Returns:
A single continues byte like object.
exasol.bucketfs.as_string#
- exasol.bucketfs.as_string(chunks: Iterable[ByteString], encoding: str = 'utf-8') str[source]#
Transforms a set of byte chunks into a string.
- Parameters:
chunks β which shall be converted into a single string.
encoding β which shall be used to convert the bytes to a string.
- Returns:
A string representation of the converted bytes.
exasol.bucketfs.as_file#
exasol.bucketfs.as_hash#
- exasol.bucketfs.as_hash(chunks: Iterable[ByteString], algorithm: str = 'sha1') ByteString[source]#
Calculate the hash for a set of byte chunks.
- Parameters:
chunks β which shall be used as input for the checksum.
algorithm β which shall be used for calculating the checksum.
- Returns:
A string representing the hex digest.
exasol.bucketfs.MappedBucket#
- class exasol.bucketfs.MappedBucket(bucket: Bucket, chunk_size: int = 8192)[source]#
Bases:
objectWraps a bucket and provides various convenience features to it (e.g. index based access).
Attention
Even though this class provides a very convenient interface, the functionality of this class should be used with care. Even though it may not be obvious, all the provided features do involve interactions with a bucketfs service in the background (upload, download, sync, etc.). Keep this in mind when using this class.