feldera 0.131.0__py3-none-any.whl → 0.192.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of feldera might be problematic. Click here for more details.

feldera/rest/config.py CHANGED
@@ -1,33 +1,44 @@
1
- from typing import Optional
2
-
3
-
4
- class Config:
5
- """
6
- :class:`.FelderaClient`'s credentials and configuration parameters
7
- """
8
-
9
- def __init__(
10
- self,
11
- url: str,
12
- api_key: Optional[str] = None,
13
- version: Optional[str] = None,
14
- timeout: Optional[float] = None,
15
- connection_timeout: Optional[float] = None,
16
- requests_verify: bool = True,
17
- ) -> None:
18
- """
19
- :param url: The url to the Feldera API (ex: https://try.feldera.com)
20
- :param api_key: The optional API key to access Feldera
21
- :param version: The version of the API to use
22
- :param timeout: The timeout for the HTTP requests
23
- :param connection_timeout: The connection timeout for the HTTP requests
24
- :param requests_verify: The `verify` parameter passed to the requests
25
- library. `True` by default.
26
- """
27
-
28
- self.url: str = url
29
- self.api_key: Optional[str] = api_key
30
- self.version: Optional[str] = version or "v0"
31
- self.timeout: Optional[float] = timeout
32
- self.connection_timeout: Optional[float] = connection_timeout
33
- self.requests_verify: bool = requests_verify
1
+ import logging
2
+ import os
3
+ from typing import Optional
4
+
5
+ from feldera.rest._helpers import requests_verify_from_env
6
+
7
+
8
+ class Config:
9
+ """
10
+ :class:`.FelderaClient` configuration, which includes authentication information
11
+ and the address of the Feldera API the client will interact with.
12
+ """
13
+
14
+ def __init__(
15
+ self,
16
+ url: Optional[str] = None,
17
+ api_key: Optional[str] = None,
18
+ version: Optional[str] = None,
19
+ timeout: Optional[float] = None,
20
+ connection_timeout: Optional[float] = None,
21
+ requests_verify: Optional[bool | str] = None,
22
+ health_recovery_timeout: Optional[int] = None,
23
+ ) -> None:
24
+ """
25
+ See documentation of the `FelderaClient` constructor for the other arguments.
26
+
27
+ :param version: (Optional) Version of the API to use.
28
+ Default: `v0`.
29
+ :param health_recovery_timeout: (Optional) Maximum time in seconds to wait for cluster health recovery after a 502 error.
30
+ Default: `300` (5 minutes).
31
+ """
32
+ self.url: str = url or os.environ.get("FELDERA_HOST") or "http://localhost:8080"
33
+ self.api_key: Optional[str] = api_key or os.environ.get("FELDERA_API_KEY")
34
+ self.version: str = version or "v0"
35
+ self.timeout: Optional[float] = timeout
36
+ self.connection_timeout: Optional[float] = connection_timeout
37
+ self.health_recovery_timeout: int = health_recovery_timeout or 300
38
+ env_verify = requests_verify_from_env()
39
+ self.requests_verify: bool | str = (
40
+ requests_verify if requests_verify is not None else env_verify
41
+ )
42
+
43
+ if self.requests_verify is False:
44
+ logging.warning("Feldera client: TLS verification is disabled!")
feldera/rest/errors.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from requests import Response
2
2
  import json
3
+ from urllib.parse import urlparse
3
4
 
4
5
 
5
6
  class FelderaError(Exception):
@@ -40,6 +41,21 @@ class FelderaAPIError(FelderaError):
40
41
  self.details = json_data.get("details")
41
42
  except Exception:
42
43
  self.message = request.text
44
+ err_msg += request.text
45
+
46
+ err_msg += f"\nResponse Status: {request.status_code}"
47
+
48
+ if int(request.status_code) == 401:
49
+ parsed = urlparse(request.request.url)
50
+
51
+ auth_err = f"\nAuthorization error: Failed to connect to '{parsed.scheme}://{parsed.hostname}': "
52
+ auth = request.request.headers.get("Authorization")
53
+ if auth is None:
54
+ err_msg += f"{auth_err} API key not set"
55
+ else:
56
+ err_msg += f"{auth_err} invalid API key"
57
+
58
+ err_msg = err_msg.strip()
43
59
 
44
60
  super().__init__(err_msg)
45
61