99
1010
1111class UnsupportedAuthenticationError (Exception ):
12- """
13- Raised when an unsupported authentication method is used.
14- """
12+ """Raised when an unsupported authentication method is used."""
1513
1614 def __init__ (self , auth_type ):
1715 super ().__init__ (f"unsupported authentication type: { auth_type } " )
1816
1917
2018class AuthenticationError (Exception ):
21- """
22- Raised when an unknown authentication error is encountered.
23- """
19+ """Raised when an unknown authentication error is encountered."""
2420
2521 def __init__ (self , user ):
2622 super ().__init__ (f"failed to authenticate as user: { user } " )
2723
2824
2925class CatalogError (Exception ):
30- """
31- Raised when an unknown catalog service type is requested.
32- """
26+ """Raised when an unknown catalog service type is requested."""
3327
3428 def __init__ (self , name ):
3529 super ().__init__ (f"service type { name } not found in OpenStack service catalog" )
3630
3731
3832class Auth (httpx .Auth ):
39- """
40- Authenticator class for OpenStack connections.
41- """
33+ """Authenticator class for OpenStack connections."""
4234
4335 def __init__ (
4436 self , auth_url , application_credential_id , application_credential_secret
@@ -52,8 +44,9 @@ def __init__(
5244
5345 @contextlib .asynccontextmanager
5446 async def _refresh_token (self ):
55- """
56- Context manager to ensure only one request at a time triggers a token refresh.
47+ """Context manager to ensure only one request at a time
48+
49+ triggers a token refresh.
5750 """
5851 token = self ._token
5952 async with self ._lock :
@@ -95,9 +88,7 @@ async def async_auth_flow(self, request):
9588
9689
9790class Resource (rest .Resource ):
98- """
99- Base resource for OpenStack APIs.
100- """
91+ """Base resource for OpenStack APIs."""
10192
10293 def __init__ (self , client , name , prefix = None , plural_name = None , singular_name = None ):
10394 super ().__init__ (client , name , prefix )
@@ -140,9 +131,7 @@ def _extract_one(self, response):
140131
141132
142133class Client (rest .AsyncClient ):
143- """
144- Client for OpenStack APIs.
145- """
134+ """Client for OpenStack APIs."""
146135
147136 def __init__ (self , / , base_url , prefix = None , ** kwargs ):
148137 # Extract the path part of the base_url
@@ -173,9 +162,7 @@ def resource(self, name, prefix=None, plural_name=None, singular_name=None):
173162
174163
175164class Cloud :
176- """
177- Object for interacting with OpenStack clouds.
178- """
165+ """Object for interacting with OpenStack clouds."""
179166
180167 def __init__ (self , auth , transport , interface , region = None ):
181168 self ._auth = auth
@@ -219,29 +206,21 @@ async def __aexit__(self, exc_type, exc_value, traceback):
219206
220207 @property
221208 def is_authenticated (self ):
222- """
223- Returns True if the cloud is authenticated, False otherwise.
224- """
209+ """Returns True if the cloud is authenticated, False otherwise."""
225210 return bool (self ._endpoints )
226211
227212 @property
228213 def current_user_id (self ):
229- """
230- The ID of the current user.
231- """
214+ """The ID of the current user."""
232215 return self ._auth ._user_id
233216
234217 @property
235218 def apis (self ):
236- """
237- The APIs supported by the cloud.
238- """
219+ """The APIs supported by the cloud."""
239220 return list (self ._endpoints .keys ())
240221
241222 def api_client (self , name , prefix = None ):
242- """
243- Returns a client for the named API.
244- """
223+ """Returns a client for the named API."""
245224 if name not in self ._clients :
246225 self ._clients [name ] = Client (
247226 base_url = self ._endpoints [name ],
0 commit comments