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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-20 00:44 +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 def get_access_token(self) -> str: 

18 """ 

19 Get the access token for cloud services. 

20 

21 Returns 

22 ------- 

23 access_token : str 

24 Access token. 

25 """ 

26 

27 def get_auth_headers(self) -> dict: 

28 """ 

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

30 

31 Returns 

32 ------- 

33 access_header : dict 

34 HTTP header containing the access token. 

35 """ 

36 

37 def get_credential(self) -> T_co: 

38 """ 

39 Get the credential object for cloud services. 

40 

41 Returns 

42 ------- 

43 credential : T_co 

44 Cloud-specific credential object. 

45 """