diff --git a/doc/design/bucketpath.rst b/doc/design/bucketpath.rst new file mode 100644 index 00000000..8959207f --- /dev/null +++ b/doc/design/bucketpath.rst @@ -0,0 +1,157 @@ +============================== +Design Document Bucket Path(s) +============================== + +Introduction +============ + +- Purpose of the document / Problem description +- Definitions and Acronyms + +Overview +======== + +Design Goals +============ + +Path Design +=========== + +Future Considerations +===================== + +Sudo Code Outline +================= + +.. code-block:: python + + from exasol.bucketfs import PathBuilder + + Path = PathBuilder(credentials) + + udf_path = Path("bfsl://some/local/path/file.tar.gz") + http_bucket_path = Path("bfs://127.0.0.1:8888/service/bucket/some/file.tar.gz") + https_bucket_path = Path("bfss://127.0.0.1:8888/service/bucket/some/file.tar.gz") + chroot_path = Path("bfss://127.0.0.1:8888/service/bucket/some/sub/subsub/file.tar.gz?chroot=/some/sub/") + + + +.. code-block:: python + + from typing import Protocol + + # interface / protocol or abc + # Note: should mimic pathlib.Path so it can easily understood and adopted. + class Pathlike(Protocol): + + @property + def name: + ... + + @property + def suffix: + ... + + @property + def root: + ... + + def as_uri(): + ... + + def exists(): + ... + + def is_dir(): + ... + + def is_file(): + ... + + def read_text(): + ... + + def read_bytes(): + ... + + def write_text(): + ... + + def write_bytes(): + ... + + def unlink(): + ... + + def rmdir(): + ... + + def join() + ... + + def walk(): + ... + + def iterdir(): + ... + + # overload / for joining + def __truediv__(): + ... + + + # Note: needs to support Pathlike + class BucketPath: + + protocol = ['bfs', 'bfss'] + + def __init__(bucket: Bucket, path): + ... + + + # QUESTION: UdfPath? Do we need to distuinguish between localpaths and localpaths within udf? + # Note: needs to support Pathlike + class LocalPath: + + protocol = ['bfsl'] + + def __init__(path): + ... + + # Note: needs to support Pathlike + # restrict a path to use a specific root, instead of the "normal" root + # this shall and should work on every Pathlike + class Chroot: + + # does not have a protocol, works on all kinds. + # if ?chroot is part of the uri the path LocalPath/BucketPath needs + # to be additionaly wrapped into a Chroot + + def __init__(self, path: Pathlike, chroot='/'): + pass + + def PathBuilder: + + def __init__(*args, **kwargs): + """ + Pass credentails/crendentails store etc. + """ + pass + + def __call__(path, chroot='/') -> Pathlike: + # type: LocalPath, BucketPath, Chroot + type = _determine_type(path) + facories = { + "udf" = _create_udf_path, + "bfs" = _create_bucket_path, + "chroot" = _create_chroot_path, + } + factory = factory[type] + return factory(args) + + + + + + + diff --git a/doc/design/design.rst b/doc/design/design.rst new file mode 100644 index 00000000..3e8cebab --- /dev/null +++ b/doc/design/design.rst @@ -0,0 +1,7 @@ +📑 Design Documents +=================== + +.. toctree:: + :maxdepth: 1 + + bucketpath diff --git a/doc/index.rst b/doc/index.rst index 96527d94..9f463ef8 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -7,4 +7,5 @@ user_guide/user_guide api developer_guide/developer_guide + design/design changes/changelog