2020 AsyncKeepaliveTransport ,
2121 KeepaliveTransport ,
2222)
23- from firebolt .common ._types import _AccountInfo
24- from firebolt .common .cache import _firebolt_account_info_cache
2523from firebolt .utils .exception import (
2624 AccountNotFoundError ,
27- AccountNotFoundOrNoAccessError ,
2825 FireboltEngineError ,
2926 InterfaceError ,
3027)
3128from firebolt .utils .urls import (
32- ACCOUNT_BY_NAME_URL ,
3329 ACCOUNT_BY_NAME_URL_V1 ,
3430 ACCOUNT_ENGINE_ID_BY_NAME_URL ,
3531 ACCOUNT_ENGINE_URL ,
4743FireboltClientMixinBase = mixin_for (HttpxClient ) # type: Any
4844
4945
50- def parse_response_for_account_info (response : Response ) -> _AccountInfo :
51- """Construct account info object from the API response."""
52- account_id = response .json ()["id" ]
53- account_version = int (response .json ().get ("infraVersion" , 2 ))
54- return _AccountInfo (id = account_id , version = account_version )
55-
56-
5746class FireboltClientMixin (FireboltClientMixinBase ):
5847 """HttpxAsyncClient mixin with Firebolt authentication functionality."""
5948
@@ -101,7 +90,7 @@ def _merge_auth_request(self, request: Request) -> Request:
10190 return request
10291
10392 def _enforce_trailing_slash (self , url : URL ) -> URL :
104- """Don't automatically append trailing slach to a base url"""
93+ """Don't automatically append trailing slash to a base url"""
10594 return url
10695
10796 def clone (self ) -> "Client" :
@@ -124,11 +113,6 @@ def __init__(self, *args: Any, **kwargs: Any):
124113 def account_id (self ) -> str :
125114 ...
126115
127- @property
128- @abstractmethod
129- def _account_version (self ) -> int :
130- ...
131-
132116 def _send_handling_redirects (
133117 self , request : Request , * args : Any , ** kwargs : Any
134118 ) -> Response :
@@ -161,40 +145,6 @@ def __init__(
161145 ** kwargs ,
162146 )
163147
164- @property
165- def _account_info (self ) -> _AccountInfo :
166- if account_info := _firebolt_account_info_cache .get (
167- [self .account_name , self ._api_endpoint .host ]
168- ):
169- return account_info
170- response = self .get (
171- url = self ._api_endpoint .copy_with (
172- path = ACCOUNT_BY_NAME_URL .format (account_name = self .account_name )
173- )
174- )
175- if response .status_code == HttpxCodes .NOT_FOUND :
176- assert self .account_name is not None
177- raise AccountNotFoundOrNoAccessError (self .account_name )
178- # process all other status codes
179- response .raise_for_status ()
180- account_info = parse_response_for_account_info (response )
181- _firebolt_account_info_cache .set (
182- key = [self .account_name , self ._api_endpoint .host ], value = account_info
183- )
184- return account_info
185-
186- @property
187- def _account_version (self ) -> int :
188- """User account version. 2 means both database and engine v2 are supported.
189-
190- Returns:
191- int: Account version
192-
193- Raises:
194- AccountNotFoundError: No account found with provided name
195- """
196- return self ._account_info .version
197-
198148 @property
199149 def account_id (self ) -> str :
200150 """User account ID.
@@ -208,7 +158,7 @@ def account_id(self) -> str:
208158 Raises:
209159 AccountNotFoundError: No account found with provided name
210160 """
211- return self . _account_info . id
161+ return ""
212162
213163
214164class ClientV1 (Client ):
@@ -236,13 +186,6 @@ def __init__(
236186 )
237187 self ._auth_endpoint = URL (fix_url_schema (api_endpoint ))
238188
239- @property
240- def _account_version (self ) -> int :
241- """User account version. Hardcoded since it's not returned
242- by the backend for V1.
243- """
244- return 1
245-
246189 @cached_property
247190 def account_id (self ) -> str :
248191 """User account ID.
@@ -333,11 +276,6 @@ def __init__(self, *args: Any, **kwargs: Any):
333276 async def account_id (self ) -> str :
334277 ...
335278
336- @property
337- @abstractmethod
338- async def _account_version (self ) -> int :
339- ...
340-
341279 async def _send_handling_redirects (
342280 self , request : Request , * args : Any , ** kwargs : Any
343281 ) -> Response :
@@ -370,30 +308,6 @@ def __init__(
370308 ** kwargs ,
371309 )
372310
373- async def _account_info (self ) -> _AccountInfo :
374- # manual caching to avoid async_cached_property issues
375- if account_info := _firebolt_account_info_cache .get (
376- [self .account_name , self ._api_endpoint .host ]
377- ):
378- return account_info
379-
380- response = await self .get (
381- url = self ._api_endpoint .copy_with (
382- path = ACCOUNT_BY_NAME_URL .format (account_name = self .account_name )
383- )
384- )
385- if response .status_code == HttpxCodes .NOT_FOUND :
386- assert self .account_name is not None
387- raise AccountNotFoundOrNoAccessError (self .account_name )
388- # process all other status codes
389- response .raise_for_status ()
390- account_info = parse_response_for_account_info (response )
391- # cache for future use
392- _firebolt_account_info_cache .set (
393- key = [self .account_name , self ._api_endpoint .host ], value = account_info
394- )
395- return account_info
396-
397311 @property
398312 async def account_id (self ) -> str :
399313 """User account ID.
@@ -407,19 +321,7 @@ async def account_id(self) -> str:
407321 Raises:
408322 AccountNotFoundError: No account found with provided name
409323 """
410- return (await self ._account_info ()).id
411-
412- @property
413- async def _account_version (self ) -> int :
414- """User account version. 2 means both database and engine v2 are supported.
415-
416- Returns:
417- int: Account version
418-
419- Raises:
420- AccountNotFoundError: No account found with provided name
421- """
422- return (await self ._account_info ()).version
324+ return ""
423325
424326
425327class AsyncClientV1 (AsyncClient ):
@@ -448,12 +350,6 @@ def __init__(
448350 self .account_id_cache : Dict [str , str ] = {}
449351 self ._auth_endpoint = URL (fix_url_schema (api_endpoint ))
450352
451- @property
452- async def _account_version (self ) -> int :
453- """User account version. Hardcoded since it's not returned
454- by the backend for V1."""
455- return 1
456-
457353 @property
458354 async def account_id (self ) -> str :
459355 """User account ID.
0 commit comments