Debian Codegraph @

src/auth0/management/user_blocks/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.request_options import RequestOptions
7 from ..types.list_user_blocks_by_identifier_response_content import ListUserBlocksByIdentifierResponseContent
8 from ..types.list_user_blocks_response_content import ListUserBlocksResponseContent
9 from .raw_client import AsyncRawUserBlocksClient, RawUserBlocksClient
10
11
12 class UserBlocksClient:
13 def __init__(self, *, client_wrapper: SyncClientWrapper):
14 self._raw_client = RawUserBlocksClient(client_wrapper=client_wrapper)
15
16 @property
17 def with_raw_response(self) -> RawUserBlocksClient:
18 """
19 Retrieves a raw implementation of this client that returns raw responses.
20
21 Returns
22 -------
23 RawUserBlocksClient
24 """
25 return self._raw_client
26
27 def list_by_identifier(
28 self,
29 *,
30 identifier: str,
31 consider_brute_force_enablement: typing.Optional[bool] = None,
32 request_options: typing.Optional[RequestOptions] = None,
33 ) -> ListUserBlocksByIdentifierResponseContent:
34 """
35 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email).
36
37 Parameters
38 ----------
39 identifier : str
40 Should be any of a username, phone number, or email.
41
42 consider_brute_force_enablement : typing.Optional[bool]
43
44 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
45 If true and Brute Force Protection is disabled, will return an empty list.
46
47
48 request_options : typing.Optional[RequestOptions]
49 Request-specific configuration.
50
51 Returns
52 -------
53 ListUserBlocksByIdentifierResponseContent
54 User successfully retrieved.
55
56 Examples
57 --------
58 from auth0 import Auth0
59
60 client = Auth0(
61 token="YOUR_TOKEN",
62 )
63 client.user_blocks.list_by_identifier(
64 identifier="identifier",
65 consider_brute_force_enablement=True,
66 )
67 """
68 _response = self._raw_client.list_by_identifier(
69 identifier=identifier,
70 consider_brute_force_enablement=consider_brute_force_enablement,
71 request_options=request_options,
72 )
73 return _response.data
74
75 def delete_by_identifier(self, *, identifier: str, request_options: typing.Optional[RequestOptions] = None) -> None:
76 """
77 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email).
78
79 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
80
81 Parameters
82 ----------
83 identifier : str
84 Should be any of a username, phone number, or email.
85
86 request_options : typing.Optional[RequestOptions]
87 Request-specific configuration.
88
89 Returns
90 -------
91 None
92
93 Examples
94 --------
95 from auth0 import Auth0
96
97 client = Auth0(
98 token="YOUR_TOKEN",
99 )
100 client.user_blocks.delete_by_identifier(
101 identifier="identifier",
102 )
103 """
104 _response = self._raw_client.delete_by_identifier(identifier=identifier, request_options=request_options)
105 return _response.data
106
107 def list(
108 self,
109 id: str,
110 *,
111 consider_brute_force_enablement: typing.Optional[bool] = None,
112 request_options: typing.Optional[RequestOptions] = None,
113 ) -> ListUserBlocksResponseContent:
114 """
115 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
116
117 Parameters
118 ----------
119 id : str
120 user_id of the user blocks to retrieve.
121
122 consider_brute_force_enablement : typing.Optional[bool]
123
124 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
125 If true and Brute Force Protection is disabled, will return an empty list.
126
127
128 request_options : typing.Optional[RequestOptions]
129 Request-specific configuration.
130
131 Returns
132 -------
133 ListUserBlocksResponseContent
134 User block successfully retrieved.
135
136 Examples
137 --------
138 from auth0 import Auth0
139
140 client = Auth0(
141 token="YOUR_TOKEN",
142 )
143 client.user_blocks.list(
144 id="id",
145 consider_brute_force_enablement=True,
146 )
147 """
148 _response = self._raw_client.list(
149 id, consider_brute_force_enablement=consider_brute_force_enablement, request_options=request_options
150 )
151 return _response.data
152
153 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
154 """
155 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
156
157 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
158
159 Parameters
160 ----------
161 id : str
162 The user_id of the user to update.
163
164 request_options : typing.Optional[RequestOptions]
165 Request-specific configuration.
166
167 Returns
168 -------
169 None
170
171 Examples
172 --------
173 from auth0 import Auth0
174
175 client = Auth0(
176 token="YOUR_TOKEN",
177 )
178 client.user_blocks.delete(
179 id="id",
180 )
181 """
182 _response = self._raw_client.delete(id, request_options=request_options)
183 return _response.data
184
185
186 class AsyncUserBlocksClient:
187 def __init__(self, *, client_wrapper: AsyncClientWrapper):
188 self._raw_client = AsyncRawUserBlocksClient(client_wrapper=client_wrapper)
189
190 @property
191 def with_raw_response(self) -> AsyncRawUserBlocksClient:
192 """
193 Retrieves a raw implementation of this client that returns raw responses.
194
195 Returns
196 -------
197 AsyncRawUserBlocksClient
198 """
199 return self._raw_client
200
201 async def list_by_identifier(
202 self,
203 *,
204 identifier: str,
205 consider_brute_force_enablement: typing.Optional[bool] = None,
206 request_options: typing.Optional[RequestOptions] = None,
207 ) -> ListUserBlocksByIdentifierResponseContent:
208 """
209 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email).
210
211 Parameters
212 ----------
213 identifier : str
214 Should be any of a username, phone number, or email.
215
216 consider_brute_force_enablement : typing.Optional[bool]
217
218 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
219 If true and Brute Force Protection is disabled, will return an empty list.
220
221
222 request_options : typing.Optional[RequestOptions]
223 Request-specific configuration.
224
225 Returns
226 -------
227 ListUserBlocksByIdentifierResponseContent
228 User successfully retrieved.
229
230 Examples
231 --------
232 import asyncio
233
234 from auth0 import AsyncAuth0
235
236 client = AsyncAuth0(
237 token="YOUR_TOKEN",
238 )
239
240
241 async def main() -> None:
242 await client.user_blocks.list_by_identifier(
243 identifier="identifier",
244 consider_brute_force_enablement=True,
245 )
246
247
248 asyncio.run(main())
249 """
250 _response = await self._raw_client.list_by_identifier(
251 identifier=identifier,
252 consider_brute_force_enablement=consider_brute_force_enablement,
253 request_options=request_options,
254 )
255 return _response.data
256
257 async def delete_by_identifier(
258 self, *, identifier: str, request_options: typing.Optional[RequestOptions] = None
259 ) -> None:
260 """
261 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email).
262
263 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
264
265 Parameters
266 ----------
267 identifier : str
268 Should be any of a username, phone number, or email.
269
270 request_options : typing.Optional[RequestOptions]
271 Request-specific configuration.
272
273 Returns
274 -------
275 None
276
277 Examples
278 --------
279 import asyncio
280
281 from auth0 import AsyncAuth0
282
283 client = AsyncAuth0(
284 token="YOUR_TOKEN",
285 )
286
287
288 async def main() -> None:
289 await client.user_blocks.delete_by_identifier(
290 identifier="identifier",
291 )
292
293
294 asyncio.run(main())
295 """
296 _response = await self._raw_client.delete_by_identifier(identifier=identifier, request_options=request_options)
297 return _response.data
298
299 async def list(
300 self,
301 id: str,
302 *,
303 consider_brute_force_enablement: typing.Optional[bool] = None,
304 request_options: typing.Optional[RequestOptions] = None,
305 ) -> ListUserBlocksResponseContent:
306 """
307 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
308
309 Parameters
310 ----------
311 id : str
312 user_id of the user blocks to retrieve.
313
314 consider_brute_force_enablement : typing.Optional[bool]
315
316 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
317 If true and Brute Force Protection is disabled, will return an empty list.
318
319
320 request_options : typing.Optional[RequestOptions]
321 Request-specific configuration.
322
323 Returns
324 -------
325 ListUserBlocksResponseContent
326 User block successfully retrieved.
327
328 Examples
329 --------
330 import asyncio
331
332 from auth0 import AsyncAuth0
333
334 client = AsyncAuth0(
335 token="YOUR_TOKEN",
336 )
337
338
339 async def main() -> None:
340 await client.user_blocks.list(
341 id="id",
342 consider_brute_force_enablement=True,
343 )
344
345
346 asyncio.run(main())
347 """
348 _response = await self._raw_client.list(
349 id, consider_brute_force_enablement=consider_brute_force_enablement, request_options=request_options
350 )
351 return _response.data
352
353 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
354 """
355 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
356
357 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
358
359 Parameters
360 ----------
361 id : str
362 The user_id of the user to update.
363
364 request_options : typing.Optional[RequestOptions]
365 Request-specific configuration.
366
367 Returns
368 -------
369 None
370
371 Examples
372 --------
373 import asyncio
374
375 from auth0 import AsyncAuth0
376
377 client = AsyncAuth0(
378 token="YOUR_TOKEN",
379 )
380
381
382 async def main() -> None:
383 await client.user_blocks.delete(
384 id="id",
385 )
386
387
388 asyncio.run(main())
389 """
390 _response = await self._raw_client.delete(id, request_options=request_options)
391 return _response.data