Debian Codegraph @

src/auth0/management/users/logs/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4
5 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6 from ...core.pagination import AsyncPager, SyncPager
7 from ...core.request_options import RequestOptions
8 from ...types.log import Log
9 from ...types.user_list_log_offset_paginated_response_content import UserListLogOffsetPaginatedResponseContent
10 from .raw_client import AsyncRawLogsClient, RawLogsClient
11
12
13 class LogsClient:
14 def __init__(self, *, client_wrapper: SyncClientWrapper):
15 self._raw_client = RawLogsClient(client_wrapper=client_wrapper)
16
17 @property
18 def with_raw_response(self) -> RawLogsClient:
19 """
20 Retrieves a raw implementation of this client that returns raw responses.
21
22 Returns
23 -------
24 RawLogsClient
25 """
26 return self._raw_client
27
28 def list(
29 self,
30 id: str,
31 *,
32 page: typing.Optional[int] = 0,
33 per_page: typing.Optional[int] = 50,
34 sort: typing.Optional[str] = None,
35 include_totals: typing.Optional[bool] = True,
36 request_options: typing.Optional[RequestOptions] = None,
37 ) -> SyncPager[Log, UserListLogOffsetPaginatedResponseContent]:
38 """
39 Retrieve log events for a specific user.
40
41 Note: For more information on all possible event types, their respective acronyms and descriptions, see <a href="https://auth0.com/docs/logs/log-event-type-codes">Log Event Type Codes</a>.
42
43 For more information on the list of fields that can be used in `sort`, see <a href="https://auth0.com/docs/logs/log-search-query-syntax#searchable-fields">Searchable Fields</a>.
44
45 Auth0 <a href="https://auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#limitations">limits the number of logs</a> you can return by search criteria to 100 logs per request. Furthermore, you may only paginate through up to 1,000 search results. If you exceed this threshold, please redefine your search.
46
47 Parameters
48 ----------
49 id : str
50 ID of the user of the logs to retrieve
51
52 page : typing.Optional[int]
53 Page index of the results to return. First page is 0.
54
55 per_page : typing.Optional[int]
56 Number of results per page. Paging is disabled if parameter not sent.
57
58 sort : typing.Optional[str]
59 Field to sort by. Use `fieldname:1` for ascending order and `fieldname:-1` for descending.
60
61 include_totals : typing.Optional[bool]
62 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
63
64 request_options : typing.Optional[RequestOptions]
65 Request-specific configuration.
66
67 Returns
68 -------
69 SyncPager[Log, UserListLogOffsetPaginatedResponseContent]
70 Logs successfully retrieved.
71
72 Examples
73 --------
74 from auth0 import Auth0
75
76 client = Auth0(
77 token="YOUR_TOKEN",
78 )
79 response = client.users.logs.list(
80 id="id",
81 page=1,
82 per_page=1,
83 sort="sort",
84 include_totals=True,
85 )
86 for item in response:
87 yield item
88 # alternatively, you can paginate page-by-page
89 for page in response.iter_pages():
90 yield page
91 """
92 return self._raw_client.list(
93 id, page=page, per_page=per_page, sort=sort, include_totals=include_totals, request_options=request_options
94 )
95
96
97 class AsyncLogsClient:
98 def __init__(self, *, client_wrapper: AsyncClientWrapper):
99 self._raw_client = AsyncRawLogsClient(client_wrapper=client_wrapper)
100
101 @property
102 def with_raw_response(self) -> AsyncRawLogsClient:
103 """
104 Retrieves a raw implementation of this client that returns raw responses.
105
106 Returns
107 -------
108 AsyncRawLogsClient
109 """
110 return self._raw_client
111
112 async def list(
113 self,
114 id: str,
115 *,
116 page: typing.Optional[int] = 0,
117 per_page: typing.Optional[int] = 50,
118 sort: typing.Optional[str] = None,
119 include_totals: typing.Optional[bool] = True,
120 request_options: typing.Optional[RequestOptions] = None,
121 ) -> AsyncPager[Log, UserListLogOffsetPaginatedResponseContent]:
122 """
123 Retrieve log events for a specific user.
124
125 Note: For more information on all possible event types, their respective acronyms and descriptions, see <a href="https://auth0.com/docs/logs/log-event-type-codes">Log Event Type Codes</a>.
126
127 For more information on the list of fields that can be used in `sort`, see <a href="https://auth0.com/docs/logs/log-search-query-syntax#searchable-fields">Searchable Fields</a>.
128
129 Auth0 <a href="https://auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#limitations">limits the number of logs</a> you can return by search criteria to 100 logs per request. Furthermore, you may only paginate through up to 1,000 search results. If you exceed this threshold, please redefine your search.
130
131 Parameters
132 ----------
133 id : str
134 ID of the user of the logs to retrieve
135
136 page : typing.Optional[int]
137 Page index of the results to return. First page is 0.
138
139 per_page : typing.Optional[int]
140 Number of results per page. Paging is disabled if parameter not sent.
141
142 sort : typing.Optional[str]
143 Field to sort by. Use `fieldname:1` for ascending order and `fieldname:-1` for descending.
144
145 include_totals : typing.Optional[bool]
146 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
147
148 request_options : typing.Optional[RequestOptions]
149 Request-specific configuration.
150
151 Returns
152 -------
153 AsyncPager[Log, UserListLogOffsetPaginatedResponseContent]
154 Logs successfully retrieved.
155
156 Examples
157 --------
158 import asyncio
159
160 from auth0 import AsyncAuth0
161
162 client = AsyncAuth0(
163 token="YOUR_TOKEN",
164 )
165
166
167 async def main() -> None:
168 response = await client.users.logs.list(
169 id="id",
170 page=1,
171 per_page=1,
172 sort="sort",
173 include_totals=True,
174 )
175 async for item in response:
176 yield item
177
178 # alternatively, you can paginate page-by-page
179 async for page in response.iter_pages():
180 yield page
181
182
183 asyncio.run(main())
184 """
185 return await self._raw_client.list(
186 id, page=page, per_page=per_page, sort=sort, include_totals=include_totals, request_options=request_options
187 )