11# For sphinx:
22from functools import wraps
3+ from sumo .wrapper ._auth_provider import AuthProviderSumoToken
34
45
56def raise_for_status (func ):
67 @wraps (func )
7- def wrapper (* args , ** kwargs ):
8+ def wrapper (self , * args , ** kwargs ):
89 # FIXME: in newer versions of httpx, raise_for_status() is chainable,
910 # so we could simply write
1011 # return func(*args, **kwargs).raise_for_status()
11- response = func (* args , ** kwargs )
12+ response = func (self , * args , ** kwargs )
13+ if response .status_code == 401 and isinstance (
14+ self .auth , AuthProviderSumoToken
15+ ):
16+ self ._handle_invalid_shared_key ()
1217 response .raise_for_status ()
1318 return response
1419
@@ -17,11 +22,15 @@ def wrapper(*args, **kwargs):
1722
1823def raise_for_status_async (func ):
1924 @wraps (func )
20- async def wrapper (* args , ** kwargs ):
25+ async def wrapper (self , * args , ** kwargs ):
2126 # FIXME: in newer versions of httpx, raise_for_status() is chainable,
2227 # so we could simply write
2328 # return func(*args, **kwargs).raise_for_status()
24- response = await func (* args , ** kwargs )
29+ response = await func (self , * args , ** kwargs )
30+ if response .status_code == 401 and isinstance (
31+ self .auth , AuthProviderSumoToken
32+ ):
33+ self ._handle_invalid_shared_key ()
2534 response .raise_for_status ()
2635 return response
2736
0 commit comments