feat(shared/kanidm): Add helper function sync_call
This avoids wrapping the methods each time we want to call the API in sync mode
This commit is contained in:
parent
5940aaa284
commit
6860d6cb3b
1 changed files with 8 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
from asgiref.sync import async_to_sync
|
||||
from kanidm import KanidmClient
|
||||
from loadcredential import Credentials
|
||||
|
||||
|
@ -6,3 +7,10 @@ credentials = Credentials(env_prefix="DGSI_")
|
|||
klient = KanidmClient(
|
||||
uri=credentials["KANIDM_URI"], token=credentials["KANIDM_AUTH_TOKEN"]
|
||||
)
|
||||
|
||||
|
||||
def sync_call(name, *args, **kwargs):
|
||||
"""
|
||||
Wraps the required action for use in sync contexts
|
||||
"""
|
||||
return async_to_sync(getattr(klient, name))(*args, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue