Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff2ae5f

Browse files
committed
feat: Create new RestClientOptions for more graceful RestClient configuration
1 parent 904fdf9 commit ff2ae5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+397
-125
lines changed

auth0/v3/management/auth0.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,36 @@ class Auth0(object):
3232
domain (str): Your Auth0 domain, e.g: 'username.auth0.com'
3333
3434
token (str): Management API v2 Token
35+
36+
rest_options (RestClientOptions): Pass an instance of
37+
RestClientOptions to configure additional RestClient
38+
options, such as rate-limit retries.
39+
(defaults to None)
3540
"""
3641

37-
def __init__(self, domain, token):
38-
self.blacklists = Blacklists(domain, token)
39-
self.client_grants = ClientGrants(domain, token)
40-
self.clients = Clients(domain, token)
41-
self.connections = Connections(domain, token)
42-
self.custom_domains = CustomDomains(domain, token)
43-
self.device_credentials = DeviceCredentials(domain, token)
44-
self.email_templates = EmailTemplates(domain, token)
45-
self.emails = Emails(domain, token)
46-
self.grants = Grants(domain, token)
47-
self.guardian = Guardian(domain, token)
48-
self.hooks = Hooks(domain, token)
49-
self.jobs = Jobs(domain, token)
50-
self.log_streams = LogStreams(domain, token)
51-
self.logs = Logs(domain, token)
52-
self.organizations = Organizations(domain, token)
53-
self.resource_servers = ResourceServers(domain, token)
54-
self.roles = Roles(domain, token)
55-
self.rules_configs = RulesConfigs(domain, token)
56-
self.rules = Rules(domain, token)
57-
self.stats = Stats(domain, token)
58-
self.tenants = Tenants(domain, token)
59-
self.tickets = Tickets(domain, token)
60-
self.user_blocks = UserBlocks(domain, token)
61-
self.users_by_email = UsersByEmail(domain, token)
62-
self.users = Users(domain, token)
42+
def __init__(self, domain, token, rest_options=None):
43+
self.blacklists = Blacklists(domain=domain, token=token, rest_options=rest_options)
44+
self.client_grants = ClientGrants(domain=domain, token=token, rest_options=rest_options)
45+
self.clients = Clients(domain=domain, token=token, rest_options=rest_options)
46+
self.connections = Connections(domain=domain, token=token, rest_options=rest_options)
47+
self.custom_domains = CustomDomains(domain=domain, token=token, rest_options=rest_options)
48+
self.device_credentials = DeviceCredentials(domain=domain, token=token, rest_options=rest_options)
49+
self.email_templates = EmailTemplates(domain=domain, token=token, rest_options=rest_options)
50+
self.emails = Emails(domain=domain, token=token, rest_options=rest_options)
51+
self.grants = Grants(domain=domain, token=token, rest_options=rest_options)
52+
self.guardian = Guardian(domain=domain, token=token, rest_options=rest_options)
53+
self.hooks = Hooks(domain=domain, token=token, rest_options=rest_options)
54+
self.jobs = Jobs(domain=domain, token=token, rest_options=rest_options)
55+
self.log_streams = LogStreams(domain=domain, token=token, rest_options=rest_options)
56+
self.logs = Logs(domain=domain, token=token, rest_options=rest_options)
57+
self.organizations = Organizations(domain=domain, token=token, rest_options=rest_options)
58+
self.resource_servers = ResourceServers(domain=domain, token=token, rest_options=rest_options)
59+
self.roles = Roles(domain=domain, token=token, rest_options=rest_options)
60+
self.rules_configs = RulesConfigs(domain=domain, token=token, rest_options=rest_options)
61+
self.rules = Rules(domain=domain, token=token, rest_options=rest_options)
62+
self.stats = Stats(domain=domain, token=token, rest_options=rest_options)
63+
self.tenants = Tenants(domain=domain, token=token, rest_options=rest_options)
64+
self.tickets = Tickets(domain=domain, token=token, rest_options=rest_options)
65+
self.user_blocks = UserBlocks(domain=domain, token=token, rest_options=rest_options)
66+
self.users_by_email = UsersByEmail(domain=domain, token=token, rest_options=rest_options)
67+
self.users = Users(domain=domain, token=token, rest_options=rest_options)

auth0/v3/management/blacklists.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ class Blacklists(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.url = '{}://{}/api/v2/blacklists/tokens'.format(protocol, domain)
23-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
28+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2429

2530
def get(self, aud=None):
2631
"""Retrieves the jti and aud of all tokens in the blacklist.

auth0/v3/management/client_grants.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class ClientGrants(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/client-grants'.format(self.protocol, self.domain)

auth0/v3/management/clients.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Clients(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/clients'.format(self.protocol, self.domain)

auth0/v3/management/connections.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Connections(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/connections'.format(self.protocol, self.domain)

auth0/v3/management/custom_domains.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class CustomDomains(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/custom-domains'.format(self.protocol, self.domain)

auth0/v3/management/device_credentials.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class DeviceCredentials(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/device-credentials'.format(self.protocol, self.domain)

auth0/v3/management/email_templates.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class EmailTemplates(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/email-templates'.format(self.protocol, self.domain)

auth0/v3/management/emails.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Emails(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/emails/provider'.format(self.protocol, self.domain)

auth0/v3/management/grants.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Grants(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/grants'.format(self.protocol, self.domain)
@@ -45,7 +50,7 @@ def all(self, page=None, per_page=None, include_totals=False, extra_params=None)
4550
extra_params (dictionary, optional): The extra parameters to add to
4651
the request. The page, per_page, and include_totals values
4752
specified as parameters take precedence over the ones defined here.
48-
53+
4954
See: https://auth0.com/docs/api/management/v2#!/Grants/get_grants
5055
"""
5156
params = extra_params or {}

auth0/v3/management/guardian.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Guardian(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/guardian'.format(self.protocol, self.domain)
@@ -33,7 +38,7 @@ def all_factors(self):
3338
"""Retrieves all factors. Useful to check factor enablement and
3439
trial status.
3540
36-
See: https://auth0.com/docs/api/management/v2#!/Guardian/get_factors
41+
See: https://auth0.com/docs/api/management/v2#!/Guardian/get_factors
3742
"""
3843

3944
return self.client.get(self._url('factors'))

auth0/v3/management/hooks.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ class Hooks(object):
1717
connect and read timeout. Pass a tuple to specify
1818
both values separately or a float to set both to it.
1919
(defaults to 5.0 for both)
20+
21+
rest_options (RestClientOptions): Pass an instance of
22+
RestClientOptions to configure additional RestClient
23+
options, such as rate-limit retries.
24+
(defaults to None)
2025
"""
2126

22-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
27+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2328
self.domain = domain
2429
self.protocol = protocol
25-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
30+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2631

2732
def _url(self, id=None):
2833
url = "{}://{}/api/v2/hooks".format(self.protocol, self.domain)

auth0/v3/management/jobs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@ class Jobs(object):
1717
connect and read timeout. Pass a tuple to specify
1818
both values separately or a float to set both to it.
1919
(defaults to 5.0 for both)
20+
21+
rest_options (RestClientOptions): Pass an instance of
22+
RestClientOptions to configure additional RestClient
23+
options, such as rate-limit retries.
24+
(defaults to None)
2025
"""
2126

22-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
27+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2328
self.domain = domain
2429
self.protocol = protocol
25-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
30+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2631

2732
def _url(self, path=None):
2833
url = '{}://{}/api/v2/jobs'.format(self.protocol, self.domain)
@@ -57,10 +62,10 @@ def get_results(self, job_id):
5762
Args:
5863
job_id (str): The id of the job.
5964
60-
Deprecation:
65+
Deprecation:
6166
The /jobs/{id}/results endpoint was removed from the Management API.
6267
You can obtain the Job results by querying a Job by ID.
63-
68+
6469
See: https://auth0.com/docs/api/management/v2#!/Jobs/get_jobs_by_id
6570
"""
6671
warnings.warn("/jobs/{id}/results is no longer available. The get(id) function will be called instead.", DeprecationWarning)

auth0/v3/management/log_streams.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class LogStreams(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/log-streams'.format(self.protocol, self.domain)

auth0/v3/management/logs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Logs(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, id=None):
2732
url = '{}://{}/api/v2/logs'.format(self.protocol, self.domain)

auth0/v3/management/organizations.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ class Organizations(object):
1616
connect and read timeout. Pass a tuple to specify
1717
both values separately or a float to set both to it.
1818
(defaults to 5.0 for both)
19+
20+
rest_options (RestClientOptions): Pass an instance of
21+
RestClientOptions to configure additional RestClient
22+
options, such as rate-limit retries.
23+
(defaults to None)
1924
"""
2025

21-
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https"):
26+
def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https", rest_options=None):
2227
self.domain = domain
2328
self.protocol = protocol
24-
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout)
29+
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
2530

2631
def _url(self, *args):
2732
url = '{}://{}/api/v2/organizations'.format(self.protocol, self.domain)

0 commit comments

Comments
 (0)