Coverage for mlos_bench/mlos_bench/services/types/authenticator_type.py: 73%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-21 01:50 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5"""Protocol interface for authentication for the cloud services.""" 

6 

7from typing import Protocol, TypeVar, runtime_checkable 

8 

9T_co = TypeVar("T_co", covariant=True) 

10"""Type variable for the return type of the credential object.""" 

11 

12 

13@runtime_checkable 

14class SupportsAuth(Protocol[T_co]): 

15 """Protocol interface for authentication for the cloud services.""" 

16 

17 # Needed by pyright 

18 # pylint: disable=unnecessary-ellipsis,redundant-returns-doc 

19 

20 def get_access_token(self) -> str: 

21 """ 

22 Get the access token for cloud services. 

23 

24 Returns 

25 ------- 

26 access_token : str 

27 Access token. 

28 """ 

29 ... 

30 

31 def get_auth_headers(self) -> dict: 

32 """ 

33 Get the authorization part of HTTP headers for REST API calls. 

34 

35 Returns 

36 ------- 

37 access_header : dict 

38 HTTP header containing the access token. 

39 """ 

40 ... 

41 

42 def get_credential(self) -> T_co: 

43 """ 

44 Get the credential object for cloud services. 

45 

46 Returns 

47 ------- 

48 credential : T_co 

49 Cloud-specific credential object. 

50 """ 

51 ...