🧰 API Reference¶
exasol.bucketfs.Service¶
- class exasol.bucketfs.Service(url: str, credentials: Mapping[str, Mapping[str, str]] | None = None)[source]
Bases:
object
Provides 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:
object
Wraps 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.