|
| 1 | +from .rest import RestClient |
| 2 | + |
| 3 | + |
| 4 | +class Branding(object): |
| 5 | + """Auth0 Branding endpoints |
| 6 | +
|
| 7 | + Args: |
| 8 | + domain (str): Your Auth0 domain, e.g: 'username.auth0.com' |
| 9 | +
|
| 10 | + token (str): Management API v2 Token |
| 11 | +
|
| 12 | + telemetry (bool, optional): Enable or disable Telemetry |
| 13 | + (defaults to True) |
| 14 | +
|
| 15 | + timeout (float or tuple, optional): Change the requests |
| 16 | + connect and read timeout. Pass a tuple to specify |
| 17 | + both values separately or a float to set both to it. |
| 18 | + (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) |
| 24 | + """ |
| 25 | + |
| 26 | + def __init__( |
| 27 | + self, |
| 28 | + domain, |
| 29 | + token, |
| 30 | + telemetry=True, |
| 31 | + timeout=5.0, |
| 32 | + protocol="https", |
| 33 | + rest_options=None, |
| 34 | + ): |
| 35 | + self.domain = domain |
| 36 | + self.protocol = protocol |
| 37 | + self.client = RestClient( |
| 38 | + jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options |
| 39 | + ) |
| 40 | + |
| 41 | + def _url(self, *args): |
| 42 | + url = "{}://{}/api/v2/branding".format(self.protocol, self.domain) |
| 43 | + for p in args: |
| 44 | + if p is not None: |
| 45 | + url = "{}/{}".format(url, p) |
| 46 | + return url |
| 47 | + |
| 48 | + def get(self, aud=None): |
| 49 | + """Retrieve branding settings. Requires "read:branding" scope. |
| 50 | +
|
| 51 | + See: https://auth0.com/docs/api/management/v2#!/Branding/get_branding |
| 52 | + """ |
| 53 | + |
| 54 | + return self.client.get(self._url()) |
| 55 | + |
| 56 | + def update(self, body): |
| 57 | + """Update branding settings. Requires "update:branding" scope. |
| 58 | +
|
| 59 | + Args: |
| 60 | + body (dict): Attributes for the updated trigger binding. |
| 61 | +
|
| 62 | + See: https://auth0.com/docs/api/management/v2#!/Branding/patch_branding |
| 63 | + """ |
| 64 | + |
| 65 | + return self.client.patch(self._url(), data=body) |
| 66 | + |
| 67 | + def get_template_universal_login(self): |
| 68 | + """Get template for New Universal Login Experience. Requires "read:branding" scope. |
| 69 | +
|
| 70 | + See: https://auth0.com/docs/api/management/v2#!/Branding/get_universal_login |
| 71 | + """ |
| 72 | + |
| 73 | + return self.client.get(self._url("templates", "universal-login")) |
| 74 | + |
| 75 | + def delete_template_universal_login(self): |
| 76 | + """Delete template for New Universal Login Experience. Requires "delete:branding" scope. |
| 77 | +
|
| 78 | + See: https://auth0.com/docs/api/management/v2#!/Branding/delete_universal_login |
| 79 | + """ |
| 80 | + |
| 81 | + return self.client.delete(self._url("templates", "universal-login")) |
| 82 | + |
| 83 | + def update_template_universal_login(self, body): |
| 84 | + """Update template for New Universal Login Experience. Requires "update:branding" scope. |
| 85 | +
|
| 86 | + Args: |
| 87 | + body (str): Complete HTML content to assign to the template. See linked API documentation for example. |
| 88 | +
|
| 89 | + See: https://auth0.com/docs/api/management/v2#!/Branding/put_universal_login |
| 90 | + """ |
| 91 | + |
| 92 | + return self.client.put(self._url("templates", "universal-login"), type="put_universal-login_body", body={"template":body}) |
0 commit comments