Skip to content

Commit ddede97

Browse files
committed
add to auth0 factory
1 parent 13fb25e commit ddede97

1 file changed

Lines changed: 41 additions & 54 deletions

File tree

auth0/v3/management/auth0.py

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from ..utils import is_async_available
12
from .actions import Actions
23
from .attack_protection import AttackProtection
34
from .blacklists import Blacklists
@@ -27,6 +28,37 @@
2728
from .users import Users
2829
from .users_by_email import UsersByEmail
2930

31+
modules = {
32+
"actions": Actions,
33+
"attack_protection": AttackProtection,
34+
"blacklists": Blacklists,
35+
"client_grants": ClientGrants,
36+
"clients": Clients,
37+
"connections": Connections,
38+
"custom_domains": CustomDomains,
39+
"device_credentials": DeviceCredentials,
40+
"email_templates": EmailTemplates,
41+
"emails": Emails,
42+
"grants": Grants,
43+
"guardian": Guardian,
44+
"hooks": Hooks,
45+
"jobs": Jobs,
46+
"log_streams": LogStreams,
47+
"logs": Logs,
48+
"organizations": Organizations,
49+
"prompts": Prompts,
50+
"resource_servers": ResourceServers,
51+
"roles": Roles,
52+
"rules_configs": RulesConfigs,
53+
"rules": Rules,
54+
"stats": Stats,
55+
"tenants": Tenants,
56+
"tickets": Tickets,
57+
"user_blocks": UserBlocks,
58+
"users_by_email": UsersByEmail,
59+
"users": Users,
60+
}
61+
3062

3163
class Auth0(object):
3264
"""Provides easy access to all endpoint classes
@@ -43,57 +75,12 @@ class Auth0(object):
4375
"""
4476

4577
def __init__(self, domain, token, rest_options=None):
46-
self.actions = Actions(domain=domain, token=token, rest_options=rest_options)
47-
self.attack_protection = AttackProtection(
48-
domain=domain, token=token, rest_options=rest_options
49-
)
50-
self.blacklists = Blacklists(
51-
domain=domain, token=token, rest_options=rest_options
52-
)
53-
self.client_grants = ClientGrants(
54-
domain=domain, token=token, rest_options=rest_options
55-
)
56-
self.clients = Clients(domain=domain, token=token, rest_options=rest_options)
57-
self.connections = Connections(
58-
domain=domain, token=token, rest_options=rest_options
59-
)
60-
self.custom_domains = CustomDomains(
61-
domain=domain, token=token, rest_options=rest_options
62-
)
63-
self.device_credentials = DeviceCredentials(
64-
domain=domain, token=token, rest_options=rest_options
65-
)
66-
self.email_templates = EmailTemplates(
67-
domain=domain, token=token, rest_options=rest_options
68-
)
69-
self.emails = Emails(domain=domain, token=token, rest_options=rest_options)
70-
self.grants = Grants(domain=domain, token=token, rest_options=rest_options)
71-
self.guardian = Guardian(domain=domain, token=token, rest_options=rest_options)
72-
self.hooks = Hooks(domain=domain, token=token, rest_options=rest_options)
73-
self.jobs = Jobs(domain=domain, token=token, rest_options=rest_options)
74-
self.log_streams = LogStreams(
75-
domain=domain, token=token, rest_options=rest_options
76-
)
77-
self.logs = Logs(domain=domain, token=token, rest_options=rest_options)
78-
self.organizations = Organizations(
79-
domain=domain, token=token, rest_options=rest_options
80-
)
81-
self.prompts = Prompts(domain=domain, token=token, rest_options=rest_options)
82-
self.resource_servers = ResourceServers(
83-
domain=domain, token=token, rest_options=rest_options
84-
)
85-
self.roles = Roles(domain=domain, token=token, rest_options=rest_options)
86-
self.rules_configs = RulesConfigs(
87-
domain=domain, token=token, rest_options=rest_options
88-
)
89-
self.rules = Rules(domain=domain, token=token, rest_options=rest_options)
90-
self.stats = Stats(domain=domain, token=token, rest_options=rest_options)
91-
self.tenants = Tenants(domain=domain, token=token, rest_options=rest_options)
92-
self.tickets = Tickets(domain=domain, token=token, rest_options=rest_options)
93-
self.user_blocks = UserBlocks(
94-
domain=domain, token=token, rest_options=rest_options
95-
)
96-
self.users_by_email = UsersByEmail(
97-
domain=domain, token=token, rest_options=rest_options
98-
)
99-
self.users = Users(domain=domain, token=token, rest_options=rest_options)
78+
if is_async_available():
79+
from ..asyncify import asyncify
80+
81+
for name, cls in modules.items():
82+
cls = asyncify(cls)
83+
setattr(self, name, cls(domain=domain, token=token, rest_options=None))
84+
else:
85+
for name, cls in modules.items():
86+
setattr(self, name, cls(domain=domain, token=token, rest_options=None))

0 commit comments

Comments
 (0)