Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/add support for tls settings #93

Merged
merged 10 commits into from
Feb 16, 2024
21 changes: 17 additions & 4 deletions exasol/bucketfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,38 @@ class Service:
buckets: lists all available buckets.
"""

def __init__(self, url: str, credentials: Mapping[str, Mapping[str, str]] = None):
def __init__(
self,
url: str,
credentials: Mapping[str, Mapping[str, str]] = None,
verify: bool | str = True,
):
"""Create a new Service instance.

Args:
url: of the bucketfs service, e.g. `http(s)://127.0.0.1:2580`.
credentials: a mapping containing credentials (username and password) for buckets.
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``.
Nicoretti marked this conversation as resolved.
Show resolved Hide resolved

"""
self._url = _parse_service_url(url)
self._authenticator = defaultdict(
lambda: {"username": "r", "password": "read"},
credentials if credentials is not None else {},
)
self._verify = verify

@property
def buckets(self) -> MutableMapping[str, "Bucket"]:
"""List all available buckets."""
url = _build_url(service_url=self._url)
response = requests.get(url)
response = requests.get(url, verify=self._verify)
try:
response.raise_for_status()
except HTTPError as ex:
Expand Down
Loading
Loading