24
24
25
25
26
26
class _ManagedIdentityBase (object ):
27
+ """Sans I/O base for managed identity credentials"""
28
+
27
29
def __init__ (self , endpoint , client_cls , config = None , client_id = None , ** kwargs ):
28
30
# type: (str, Type, Optional[Configuration], Optional[str], Any) -> None
29
31
self ._client_id = client_id
@@ -34,6 +36,11 @@ def __init__(self, endpoint, client_cls, config=None, client_id=None, **kwargs):
34
36
@staticmethod
35
37
def create_config (** kwargs ):
36
38
# type: (Mapping[str, Any]) -> Configuration
39
+ """
40
+ Build a default configuration for the credential's HTTP pipeline.
41
+
42
+ :rtype: :class:`azure.core.configuration`
43
+ """
37
44
timeout = kwargs .pop ("connection_timeout" , 2 )
38
45
config = Configuration (connection_timeout = timeout , ** kwargs )
39
46
@@ -61,7 +68,12 @@ def create_config(**kwargs):
61
68
62
69
63
70
class ImdsCredential (_ManagedIdentityBase ):
64
- """Authenticates with a managed identity via the IMDS endpoint"""
71
+ """
72
+ Authenticates with a managed identity via the IMDS endpoint.
73
+
74
+ :param config: optional configuration for the underlying HTTP pipeline
75
+ :type config: :class:`azure.core.configuration`
76
+ """
65
77
66
78
def __init__ (self , config = None , ** kwargs ):
67
79
# type: (Optional[Configuration], Any) -> None
@@ -70,6 +82,13 @@ def __init__(self, config=None, **kwargs):
70
82
71
83
def get_token (self , * scopes ):
72
84
# type: (*str) -> AccessToken
85
+ """
86
+ Request an access token for `scopes`.
87
+
88
+ :param str scopes: desired scopes for the token
89
+ :rtype: :class:`azure.core.credentials.AccessToken`
90
+ :raises: :class:`azure.core.exceptions.ClientAuthenticationError`
91
+ """
73
92
if self ._endpoint_available is None :
74
93
# Lacking another way to determine whether the IMDS endpoint is listening,
75
94
# we send a request it would immediately reject (missing a required header),
@@ -103,7 +122,12 @@ def get_token(self, *scopes):
103
122
104
123
105
124
class MsiCredential (_ManagedIdentityBase ):
106
- """Authenticates via the MSI endpoint in App Service or Cloud Shell"""
125
+ """
126
+ Authenticates via the MSI endpoint in an App Service or Cloud Shell environment.
127
+
128
+ :param config: optional configuration for the underlying HTTP pipeline
129
+ :type config: :class:`azure.core.configuration`
130
+ """
107
131
108
132
def __init__ (self , config = None , ** kwargs ):
109
133
# type: (Optional[Configuration], Mapping[str, Any]) -> None
@@ -116,6 +140,14 @@ def __init__(self, config=None, **kwargs):
116
140
117
141
def get_token (self , * scopes ):
118
142
# type: (*str) -> AccessToken
143
+ """
144
+ Request an access token for `scopes`.
145
+
146
+ :param str scopes: desired scopes for the token
147
+ :rtype: :class:`azure.core.credentials.AccessToken`
148
+ :raises: :class:`azure.core.exceptions.ClientAuthenticationError`
149
+ """
150
+
119
151
if not self ._endpoint_available :
120
152
raise ClientAuthenticationError (message = "MSI endpoint unavailable" )
121
153
0 commit comments