|
| 1 | +from .rest import RestClient |
| 2 | + |
| 3 | + |
| 4 | +class Logs(object): |
| 5 | + """Auth0 log streams 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 | + |
| 21 | + def __init__(self, domain, token, telemetry=True, timeout=5.0): |
| 22 | + self.domain = domain |
| 23 | + self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout) |
| 24 | + |
| 25 | + def _url(self, id=None): |
| 26 | + url = 'https://{}/api/v2/log-streams'.format(self.domain) |
| 27 | + if id is not None: |
| 28 | + return '{}/{}'.format(url, id) |
| 29 | + return url |
| 30 | + |
| 31 | + def list(self): |
| 32 | + """Search log events. |
| 33 | +
|
| 34 | + Args: |
| 35 | + See: https://auth0.com/docs/api/management/v2/#!/Log_Streams/get_log_streams |
| 36 | + """ |
| 37 | + |
| 38 | + return self.client.get(self._url(), params={}) |
| 39 | + |
| 40 | + def get(self, id): |
| 41 | + """Retrieves the data related to the log stream entry identified by id. |
| 42 | +
|
| 43 | + Args: |
| 44 | + id (str): The id of the log stream to retrieve. |
| 45 | +
|
| 46 | + See: https://auth0.com/docs/api/management/v2/#!/Log_Streams/get_log_streams_by_id |
| 47 | + """ |
| 48 | + |
| 49 | + return self.client.get(self._url(id)) |
| 50 | + |
| 51 | + def create(self, body): |
| 52 | + """Creates a new log stream. |
| 53 | +
|
| 54 | + Args: |
| 55 | + body (dict): the attributes for the role to create. |
| 56 | +
|
| 57 | + See: https://auth0.com/docs/api/management/v2/#!/Log_Streams/post_log_streams |
| 58 | + """ |
| 59 | + return self.client.post(self._url(), data=body) |
| 60 | + |
| 61 | + def delete(self, id): |
| 62 | + """Delete a log stream. |
| 63 | +
|
| 64 | + Args: |
| 65 | + id (str): The id of the log ste to delete. |
| 66 | +
|
| 67 | + See: https://auth0.com/docs/api/management/v2/#!/Log_Streams/delete_log_streams_by_id |
| 68 | + """ |
| 69 | + return self.client.delete(self._url(id)) |
| 70 | + |
| 71 | + def update(self, id, body): |
| 72 | + """Update a log stream with the attributes passed in 'body' |
| 73 | +
|
| 74 | + Args: |
| 75 | + id (str): The id of the log stream to update. |
| 76 | +
|
| 77 | + body (dict): the attributes to update on the log stream. |
| 78 | +
|
| 79 | + See: https://auth0.com/docs/api/management/v2/#!/Log_Streams/patch_log_streams_by_id |
| 80 | + """ |
| 81 | + return self.client.patch(self._url(id), data=body) |
0 commit comments