🧰 API Reference¶

exasol.bucketfs.Service¶

class exasol.bucketfs.Service(url: str, credentials: Mapping[str, Mapping[str, str]] | None = None, verify: bool | str = True)[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, verify: bool | str = True)[source]

Create a new Service instance.

Parameters:
  • url – 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” }}

  • verify – Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True.

property buckets: MutableMapping[str, Bucket]

List all available buckets.

exasol.bucketfs.Bucket¶

class exasol.bucketfs.Bucket(name: str, service: str, username: str, password: str, verify: bool | str = True)[source]¶

Bases: object

__init__(name: str, service: str, username: str, password: str, verify: bool | str = True)[source]¶

Create a new bucket instance.

Parameters:
  • name – Name of the bucket.

  • service – Url where this bucket is hosted on.

  • username – Username used for authentication.

  • password – Password used for authentication.

  • verify – Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True.

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.

property files: Iterable[str]¶
property name: str¶
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_file(chunks: Iterable[ByteString], filename: str | Path) Path[source]¶

Transforms a set of byte chunks into a string.

Parameters:
  • chunks – which shall be written to file.

  • filename – for the file which is to be created.

Returns:

A path to the created 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.

__init__(bucket: Bucket, chunk_size: int = 8192)[source]¶

Creates a new MappedBucket.

Parameters:
  • bucket – which shall be wrapped.

  • chunk_size – which shall be used for downloads.

property chunk_size: int¶

Chunk size which will be used for downloads.

exasol.bucketfs.BucketFsError¶

exception exasol.bucketfs.BucketFsError(*args, **kwargs)[source]¶

Error occurred while interacting with the bucket fs service.