Debian Codegraph @

src/auth0/management/flows/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 from __future__ import annotations
4
5 import typing
6
7 from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ..core.pagination import AsyncPager, SyncPager
9 from ..core.request_options import RequestOptions
10 from ..types.create_flow_response_content import CreateFlowResponseContent
11 from ..types.flow_action import FlowAction
12 from ..types.flow_summary import FlowSummary
13 from ..types.get_flow_request_parameters_hydrate_enum import GetFlowRequestParametersHydrateEnum
14 from ..types.get_flow_response_content import GetFlowResponseContent
15 from ..types.list_flows_offset_paginated_response_content import ListFlowsOffsetPaginatedResponseContent
16 from ..types.list_flows_request_parameters_hydrate_enum import ListFlowsRequestParametersHydrateEnum
17 from ..types.update_flow_response_content import UpdateFlowResponseContent
18 from .raw_client import AsyncRawFlowsClient, RawFlowsClient
19
20 if typing.TYPE_CHECKING:
21 from .executions.client import AsyncExecutionsClient, ExecutionsClient
22 from .vault.client import AsyncVaultClient, VaultClient
23 # this is used as the default value for optional parameters
24 OMIT = typing.cast(typing.Any, ...)
25
26
27 class FlowsClient:
28 def __init__(self, *, client_wrapper: SyncClientWrapper):
29 self._raw_client = RawFlowsClient(client_wrapper=client_wrapper)
30 self._client_wrapper = client_wrapper
31 self._executions: typing.Optional[ExecutionsClient] = None
32 self._vault: typing.Optional[VaultClient] = None
33
34 @property
35 def with_raw_response(self) -> RawFlowsClient:
36 """
37 Retrieves a raw implementation of this client that returns raw responses.
38
39 Returns
40 -------
41 RawFlowsClient
42 """
43 return self._raw_client
44
45 def list(
46 self,
47 *,
48 page: typing.Optional[int] = 0,
49 per_page: typing.Optional[int] = 50,
50 include_totals: typing.Optional[bool] = True,
51 hydrate: typing.Optional[
52 typing.Union[ListFlowsRequestParametersHydrateEnum, typing.Sequence[ListFlowsRequestParametersHydrateEnum]]
53 ] = None,
54 synchronous: typing.Optional[bool] = None,
55 request_options: typing.Optional[RequestOptions] = None,
56 ) -> SyncPager[FlowSummary, ListFlowsOffsetPaginatedResponseContent]:
57 """
58 Parameters
59 ----------
60 page : typing.Optional[int]
61 Page index of the results to return. First page is 0.
62
63 per_page : typing.Optional[int]
64 Number of results per page. Defaults to 50.
65
66 include_totals : typing.Optional[bool]
67 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
68
69 hydrate : typing.Optional[typing.Union[ListFlowsRequestParametersHydrateEnum, typing.Sequence[ListFlowsRequestParametersHydrateEnum]]]
70 hydration param
71
72 synchronous : typing.Optional[bool]
73 flag to filter by sync/async flows
74
75 request_options : typing.Optional[RequestOptions]
76 Request-specific configuration.
77
78 Returns
79 -------
80 SyncPager[FlowSummary, ListFlowsOffsetPaginatedResponseContent]
81 Flows successfully retrieved.
82
83 Examples
84 --------
85 from auth0 import Auth0
86
87 client = Auth0(
88 token="YOUR_TOKEN",
89 )
90 response = client.flows.list(
91 page=1,
92 per_page=1,
93 include_totals=True,
94 hydrate=["form_count"],
95 synchronous=True,
96 )
97 for item in response:
98 yield item
99 # alternatively, you can paginate page-by-page
100 for page in response.iter_pages():
101 yield page
102 """
103 return self._raw_client.list(
104 page=page,
105 per_page=per_page,
106 include_totals=include_totals,
107 hydrate=hydrate,
108 synchronous=synchronous,
109 request_options=request_options,
110 )
111
112 def create(
113 self,
114 *,
115 name: str,
116 actions: typing.Optional[typing.Sequence[FlowAction]] = OMIT,
117 request_options: typing.Optional[RequestOptions] = None,
118 ) -> CreateFlowResponseContent:
119 """
120 Parameters
121 ----------
122 name : str
123
124 actions : typing.Optional[typing.Sequence[FlowAction]]
125
126 request_options : typing.Optional[RequestOptions]
127 Request-specific configuration.
128
129 Returns
130 -------
131 CreateFlowResponseContent
132 Flow successfully created.
133
134 Examples
135 --------
136 from auth0 import Auth0
137
138 client = Auth0(
139 token="YOUR_TOKEN",
140 )
141 client.flows.create(
142 name="name",
143 )
144 """
145 _response = self._raw_client.create(name=name, actions=actions, request_options=request_options)
146 return _response.data
147
148 def get(
149 self,
150 id: str,
151 *,
152 hydrate: typing.Optional[
153 typing.Union[GetFlowRequestParametersHydrateEnum, typing.Sequence[GetFlowRequestParametersHydrateEnum]]
154 ] = None,
155 request_options: typing.Optional[RequestOptions] = None,
156 ) -> GetFlowResponseContent:
157 """
158 Parameters
159 ----------
160 id : str
161 Flow identifier
162
163 hydrate : typing.Optional[typing.Union[GetFlowRequestParametersHydrateEnum, typing.Sequence[GetFlowRequestParametersHydrateEnum]]]
164 hydration param
165
166 request_options : typing.Optional[RequestOptions]
167 Request-specific configuration.
168
169 Returns
170 -------
171 GetFlowResponseContent
172 Flow successfully retrieved.
173
174 Examples
175 --------
176 from auth0 import Auth0
177
178 client = Auth0(
179 token="YOUR_TOKEN",
180 )
181 client.flows.get(
182 id="id",
183 hydrate=["form_count"],
184 )
185 """
186 _response = self._raw_client.get(id, hydrate=hydrate, request_options=request_options)
187 return _response.data
188
189 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
190 """
191 Parameters
192 ----------
193 id : str
194 Flow id
195
196 request_options : typing.Optional[RequestOptions]
197 Request-specific configuration.
198
199 Returns
200 -------
201 None
202
203 Examples
204 --------
205 from auth0 import Auth0
206
207 client = Auth0(
208 token="YOUR_TOKEN",
209 )
210 client.flows.delete(
211 id="id",
212 )
213 """
214 _response = self._raw_client.delete(id, request_options=request_options)
215 return _response.data
216
217 def update(
218 self,
219 id: str,
220 *,
221 name: typing.Optional[str] = OMIT,
222 actions: typing.Optional[typing.Sequence[FlowAction]] = OMIT,
223 request_options: typing.Optional[RequestOptions] = None,
224 ) -> UpdateFlowResponseContent:
225 """
226 Parameters
227 ----------
228 id : str
229 Flow identifier
230
231 name : typing.Optional[str]
232
233 actions : typing.Optional[typing.Sequence[FlowAction]]
234
235 request_options : typing.Optional[RequestOptions]
236 Request-specific configuration.
237
238 Returns
239 -------
240 UpdateFlowResponseContent
241 Flow successfully updated.
242
243 Examples
244 --------
245 from auth0 import Auth0
246
247 client = Auth0(
248 token="YOUR_TOKEN",
249 )
250 client.flows.update(
251 id="id",
252 )
253 """
254 _response = self._raw_client.update(id, name=name, actions=actions, request_options=request_options)
255 return _response.data
256
257 @property
258 def executions(self):
259 if self._executions is None:
260 from .executions.client import ExecutionsClient # noqa: E402
261
262 self._executions = ExecutionsClient(client_wrapper=self._client_wrapper)
263 return self._executions
264
265 @property
266 def vault(self):
267 if self._vault is None:
268 from .vault.client import VaultClient # noqa: E402
269
270 self._vault = VaultClient(client_wrapper=self._client_wrapper)
271 return self._vault
272
273
274 class AsyncFlowsClient:
275 def __init__(self, *, client_wrapper: AsyncClientWrapper):
276 self._raw_client = AsyncRawFlowsClient(client_wrapper=client_wrapper)
277 self._client_wrapper = client_wrapper
278 self._executions: typing.Optional[AsyncExecutionsClient] = None
279 self._vault: typing.Optional[AsyncVaultClient] = None
280
281 @property
282 def with_raw_response(self) -> AsyncRawFlowsClient:
283 """
284 Retrieves a raw implementation of this client that returns raw responses.
285
286 Returns
287 -------
288 AsyncRawFlowsClient
289 """
290 return self._raw_client
291
292 async def list(
293 self,
294 *,
295 page: typing.Optional[int] = 0,
296 per_page: typing.Optional[int] = 50,
297 include_totals: typing.Optional[bool] = True,
298 hydrate: typing.Optional[
299 typing.Union[ListFlowsRequestParametersHydrateEnum, typing.Sequence[ListFlowsRequestParametersHydrateEnum]]
300 ] = None,
301 synchronous: typing.Optional[bool] = None,
302 request_options: typing.Optional[RequestOptions] = None,
303 ) -> AsyncPager[FlowSummary, ListFlowsOffsetPaginatedResponseContent]:
304 """
305 Parameters
306 ----------
307 page : typing.Optional[int]
308 Page index of the results to return. First page is 0.
309
310 per_page : typing.Optional[int]
311 Number of results per page. Defaults to 50.
312
313 include_totals : typing.Optional[bool]
314 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
315
316 hydrate : typing.Optional[typing.Union[ListFlowsRequestParametersHydrateEnum, typing.Sequence[ListFlowsRequestParametersHydrateEnum]]]
317 hydration param
318
319 synchronous : typing.Optional[bool]
320 flag to filter by sync/async flows
321
322 request_options : typing.Optional[RequestOptions]
323 Request-specific configuration.
324
325 Returns
326 -------
327 AsyncPager[FlowSummary, ListFlowsOffsetPaginatedResponseContent]
328 Flows successfully retrieved.
329
330 Examples
331 --------
332 import asyncio
333
334 from auth0 import AsyncAuth0
335
336 client = AsyncAuth0(
337 token="YOUR_TOKEN",
338 )
339
340
341 async def main() -> None:
342 response = await client.flows.list(
343 page=1,
344 per_page=1,
345 include_totals=True,
346 hydrate=["form_count"],
347 synchronous=True,
348 )
349 async for item in response:
350 yield item
351
352 # alternatively, you can paginate page-by-page
353 async for page in response.iter_pages():
354 yield page
355
356
357 asyncio.run(main())
358 """
359 return await self._raw_client.list(
360 page=page,
361 per_page=per_page,
362 include_totals=include_totals,
363 hydrate=hydrate,
364 synchronous=synchronous,
365 request_options=request_options,
366 )
367
368 async def create(
369 self,
370 *,
371 name: str,
372 actions: typing.Optional[typing.Sequence[FlowAction]] = OMIT,
373 request_options: typing.Optional[RequestOptions] = None,
374 ) -> CreateFlowResponseContent:
375 """
376 Parameters
377 ----------
378 name : str
379
380 actions : typing.Optional[typing.Sequence[FlowAction]]
381
382 request_options : typing.Optional[RequestOptions]
383 Request-specific configuration.
384
385 Returns
386 -------
387 CreateFlowResponseContent
388 Flow successfully created.
389
390 Examples
391 --------
392 import asyncio
393
394 from auth0 import AsyncAuth0
395
396 client = AsyncAuth0(
397 token="YOUR_TOKEN",
398 )
399
400
401 async def main() -> None:
402 await client.flows.create(
403 name="name",
404 )
405
406
407 asyncio.run(main())
408 """
409 _response = await self._raw_client.create(name=name, actions=actions, request_options=request_options)
410 return _response.data
411
412 async def get(
413 self,
414 id: str,
415 *,
416 hydrate: typing.Optional[
417 typing.Union[GetFlowRequestParametersHydrateEnum, typing.Sequence[GetFlowRequestParametersHydrateEnum]]
418 ] = None,
419 request_options: typing.Optional[RequestOptions] = None,
420 ) -> GetFlowResponseContent:
421 """
422 Parameters
423 ----------
424 id : str
425 Flow identifier
426
427 hydrate : typing.Optional[typing.Union[GetFlowRequestParametersHydrateEnum, typing.Sequence[GetFlowRequestParametersHydrateEnum]]]
428 hydration param
429
430 request_options : typing.Optional[RequestOptions]
431 Request-specific configuration.
432
433 Returns
434 -------
435 GetFlowResponseContent
436 Flow successfully retrieved.
437
438 Examples
439 --------
440 import asyncio
441
442 from auth0 import AsyncAuth0
443
444 client = AsyncAuth0(
445 token="YOUR_TOKEN",
446 )
447
448
449 async def main() -> None:
450 await client.flows.get(
451 id="id",
452 hydrate=["form_count"],
453 )
454
455
456 asyncio.run(main())
457 """
458 _response = await self._raw_client.get(id, hydrate=hydrate, request_options=request_options)
459 return _response.data
460
461 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
462 """
463 Parameters
464 ----------
465 id : str
466 Flow id
467
468 request_options : typing.Optional[RequestOptions]
469 Request-specific configuration.
470
471 Returns
472 -------
473 None
474
475 Examples
476 --------
477 import asyncio
478
479 from auth0 import AsyncAuth0
480
481 client = AsyncAuth0(
482 token="YOUR_TOKEN",
483 )
484
485
486 async def main() -> None:
487 await client.flows.delete(
488 id="id",
489 )
490
491
492 asyncio.run(main())
493 """
494 _response = await self._raw_client.delete(id, request_options=request_options)
495 return _response.data
496
497 async def update(
498 self,
499 id: str,
500 *,
501 name: typing.Optional[str] = OMIT,
502 actions: typing.Optional[typing.Sequence[FlowAction]] = OMIT,
503 request_options: typing.Optional[RequestOptions] = None,
504 ) -> UpdateFlowResponseContent:
505 """
506 Parameters
507 ----------
508 id : str
509 Flow identifier
510
511 name : typing.Optional[str]
512
513 actions : typing.Optional[typing.Sequence[FlowAction]]
514
515 request_options : typing.Optional[RequestOptions]
516 Request-specific configuration.
517
518 Returns
519 -------
520 UpdateFlowResponseContent
521 Flow successfully updated.
522
523 Examples
524 --------
525 import asyncio
526
527 from auth0 import AsyncAuth0
528
529 client = AsyncAuth0(
530 token="YOUR_TOKEN",
531 )
532
533
534 async def main() -> None:
535 await client.flows.update(
536 id="id",
537 )
538
539
540 asyncio.run(main())
541 """
542 _response = await self._raw_client.update(id, name=name, actions=actions, request_options=request_options)
543 return _response.data
544
545 @property
546 def executions(self):
547 if self._executions is None:
548 from .executions.client import AsyncExecutionsClient # noqa: E402
549
550 self._executions = AsyncExecutionsClient(client_wrapper=self._client_wrapper)
551 return self._executions
552
553 @property
554 def vault(self):
555 if self._vault is None:
556 from .vault.client import AsyncVaultClient # noqa: E402
557
558 self._vault = AsyncVaultClient(client_wrapper=self._client_wrapper)
559 return self._vault