pylegend 0.2.0__py3-none-any.whl → 0.2.2__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.
@@ -13,6 +13,9 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from abc import ABCMeta, abstractmethod
16
+
17
+ from requests import PreparedRequest
18
+
16
19
  from pylegend._typing import (
17
20
  PyLegendSequence,
18
21
  PyLegendOptional,
@@ -22,6 +25,7 @@ from requests.auth import AuthBase
22
25
  __all__: PyLegendSequence[str] = [
23
26
  "AuthScheme",
24
27
  "LocalhostEmptyAuthScheme",
28
+ "BearerAuthScheme"
25
29
  ]
26
30
 
27
31
 
@@ -36,3 +40,22 @@ class LocalhostEmptyAuthScheme(AuthScheme):
36
40
 
37
41
  def get_auth_base(self) -> PyLegendOptional[AuthBase]:
38
42
  return None
43
+
44
+
45
+ class BearerAuth(AuthBase):
46
+ def __init__(self, headerName: str, token: str) -> None:
47
+ self.headerName = headerName
48
+ self.token = token
49
+
50
+ def __call__(self, r: PreparedRequest) -> PreparedRequest:
51
+ r.headers[self.headerName] = self.token
52
+ return r
53
+
54
+
55
+ class BearerAuthScheme(AuthScheme):
56
+ def __init__(self, headerName: str, token: str) -> None:
57
+ self.headerName = headerName
58
+ self.token = token
59
+
60
+ def get_auth_base(self) -> PyLegendOptional[AuthBase]:
61
+ return BearerAuth(self.headerName, self.token)
@@ -35,12 +35,18 @@ class LegendClient(ServiceClient):
35
35
  self,
36
36
  host: str,
37
37
  port: int,
38
- auth_scheme: AuthScheme = LocalhostEmptyAuthScheme(),
39
38
  secure_http: bool = True,
39
+ path_prefix: PyLegendOptional[str] = "/api",
40
+ auth_scheme: AuthScheme = LocalhostEmptyAuthScheme(),
40
41
  retry_count: int = 2
41
42
  ) -> None:
42
43
  super().__init__(
43
- host=host, port=port, auth_scheme=auth_scheme, secure_http=secure_http, retry_count=retry_count
44
+ host=host,
45
+ port=port,
46
+ secure_http=secure_http,
47
+ path_prefix=path_prefix,
48
+ auth_scheme=auth_scheme,
49
+ retry_count=retry_count
44
50
  )
45
51
 
46
52
  def get_sql_string_schema(
@@ -49,7 +55,7 @@ class LegendClient(ServiceClient):
49
55
  ) -> PyLegendSequence[TdsColumn]:
50
56
  response = super()._execute_service(
51
57
  method=RequestMethod.POST,
52
- path="api/sql/v1/execution/getSchemaFromQueryString",
58
+ path="sql/v1/execution/getSchemaFromQueryString",
53
59
  data=sql,
54
60
  headers={"Content-Type": "text/plain"},
55
61
  stream=False
@@ -64,7 +70,7 @@ class LegendClient(ServiceClient):
64
70
  ) -> ResponseReader:
65
71
  iter_content = super()._execute_service(
66
72
  method=RequestMethod.POST,
67
- path="api/sql/v1/execution/executeQueryString",
73
+ path="sql/v1/execution/executeQueryString",
68
74
  data=sql,
69
75
  headers={"Content-Type": "text/plain"},
70
76
  stream=True
@@ -40,10 +40,19 @@ class RequestMethod(Enum):
40
40
 
41
41
  class ServiceClient(metaclass=ABCMeta):
42
42
 
43
- def __init__(self, host: str, port: int, auth_scheme: AuthScheme, secure_http: bool, retry_count: int) -> None:
43
+ def __init__(
44
+ self,
45
+ host: str,
46
+ port: int,
47
+ secure_http: bool,
48
+ path_prefix: PyLegendOptional[str],
49
+ auth_scheme: AuthScheme,
50
+ retry_count: int
51
+ ) -> None:
44
52
  self.__host = host
45
53
  self.__port = port
46
54
  self.__auth_scheme = auth_scheme
55
+ self.__path_prefix = path_prefix
47
56
  self.__secure_http = secure_http
48
57
  if retry_count < 1:
49
58
  raise ValueError("Retry count should be a number greater than 1. Got " + str(retry_count))
@@ -66,7 +75,9 @@ class ServiceClient(metaclass=ABCMeta):
66
75
  ) -> requests.Response:
67
76
 
68
77
  scheme = "https" if self.__secure_http else "http"
69
- url = f"{scheme}://{self.__host}:{self.__port}/{path}"
78
+ prefix = (self.__path_prefix if self.__path_prefix.startswith("/") else f"/{self.__path_prefix}") \
79
+ if self.__path_prefix is not None else ""
80
+ url = f"{scheme}://{self.__host}:{self.__port}{prefix}/{path}"
70
81
 
71
82
  request = requests.Request(
72
83
  method=method.name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylegend
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Python language binding for Legend data management platform
5
5
  Home-page: https://github.com/finos/pylegend
6
6
  License: Apache-2.0
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.8
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
16
17
  Requires-Dist: ijson (>=3.1.4)
17
18
  Requires-Dist: numpy (>=1.20.0) ; python_version < "3.12"
18
19
  Requires-Dist: numpy (>=1.26.0) ; python_version >= "3.12"
@@ -38,10 +38,10 @@ pylegend/core/language/primitives/string.py,sha256=riI340Iytk7zfThbPIfnJ3dyGnOZy
38
38
  pylegend/core/language/tds_row.py,sha256=lrf129CatediTnbEh_d_IAIWjddoywxer_1L6fsBtUY,8175
39
39
  pylegend/core/project_cooridnates.py,sha256=t1G6gJzcRQRbCjGpCOk0vBiqd0F8Y_e15Nu4NuzYd6I,3751
40
40
  pylegend/core/request/__init__.py,sha256=IHt1dQ2lEa7ibDgZC2jUAnGXG_lG-UOC_I4V7JkC6qk,967
41
- pylegend/core/request/auth.py,sha256=XEl0VPvH-8_IU4hGL1Et7MJgSKFrBqJNVZEpIZo89Hg,1077
42
- pylegend/core/request/legend_client.py,sha256=B7Rx-y61o1t_n9j8lpVbLm4vOFCVAvjqt47UJs47PRM,2639
41
+ pylegend/core/request/auth.py,sha256=IuoRYqolYPQA83lQuoOk7_7lPlJPvMeKovbpZwM8pm0,1701
42
+ pylegend/core/request/legend_client.py,sha256=upAAQt9Zhtf_oczlfV-LoWR7cm7y5bsGVf2p2aU7s_E,2773
43
43
  pylegend/core/request/response_reader.py,sha256=TNMi2GKk4lkmf7VMeY5n2AwhxxuWbX4M8pgC2_pXFbE,1691
44
- pylegend/core/request/service_client.py,sha256=Zau4uh66qFvuNuf1Ksj5JSV86YdurJHh_FByQS4pLq8,3040
44
+ pylegend/core/request/service_client.py,sha256=oNvMR6qNl5UcxpcAjIb4CCpd0MB3Z-Y5OJSyFPGeerM,3377
45
45
  pylegend/core/sql/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
46
46
  pylegend/core/sql/metamodel.py,sha256=B7aqblDyyiTsqWZUW2Is9_2FHTsYTkvhJ1FVxXxoSF8,20134
47
47
  pylegend/core/sql/metamodel_extension.py,sha256=A3B1anMf1x54sjBIjZJhQWXX5IKIsQXFYaL5vWJC4ow,15348
@@ -108,8 +108,8 @@ pylegend/extensions/tds/result_handler/to_pandas_df_result_handler.py,sha256=tvV
108
108
  pylegend/legend_api_tds_client.py,sha256=I0uRF7ADGvV5fHN-dEBIrdxTy7GC8jV91V62rgXn6c0,2319
109
109
  pylegend/utils/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
110
110
  pylegend/utils/class_utils.py,sha256=t4PpF3jAXS_D6p9TqlSppryNYNOuy5C-kbKn2Kgb4QU,973
111
- pylegend-0.2.0.dist-info/LICENSE,sha256=AGR96_qQPZO66Gjqq4G6r_g670K35VtW-IobTAkmZJM,11343
112
- pylegend-0.2.0.dist-info/LICENSE.spdx,sha256=i7TsBclLotUvMjx9vZ_6S8Pp0r4uknWGw1RwiKBBvQ4,207
113
- pylegend-0.2.0.dist-info/METADATA,sha256=UwGXNF0RYKLzLFT2er91aejVAe2i0JoWwlH0Pk34-qs,4216
114
- pylegend-0.2.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
115
- pylegend-0.2.0.dist-info/RECORD,,
111
+ pylegend-0.2.2.dist-info/LICENSE,sha256=AGR96_qQPZO66Gjqq4G6r_g670K35VtW-IobTAkmZJM,11343
112
+ pylegend-0.2.2.dist-info/LICENSE.spdx,sha256=i7TsBclLotUvMjx9vZ_6S8Pp0r4uknWGw1RwiKBBvQ4,207
113
+ pylegend-0.2.2.dist-info/METADATA,sha256=lmfSjBstKvYcjXXTrlAkhGfvA3llmC_iOxK2SYbx8t8,4267
114
+ pylegend-0.2.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
115
+ pylegend-0.2.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.7.0
2
+ Generator: poetry-core 1.8.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any