Debian Codegraph @

src/auth0/management/event_streams/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_event_stream_response_content import CreateEventStreamResponseContent
11 from ..types.create_event_stream_test_event_response_content import CreateEventStreamTestEventResponseContent
12 from ..types.event_stream_destination_patch import EventStreamDestinationPatch
13 from ..types.event_stream_response_content import EventStreamResponseContent
14 from ..types.event_stream_status_enum import EventStreamStatusEnum
15 from ..types.event_stream_subscription import EventStreamSubscription
16 from ..types.event_stream_test_event_type_enum import EventStreamTestEventTypeEnum
17 from ..types.get_event_stream_response_content import GetEventStreamResponseContent
18 from ..types.list_event_streams_response_content import ListEventStreamsResponseContent
19 from ..types.test_event_data_content import TestEventDataContent
20 from ..types.update_event_stream_response_content import UpdateEventStreamResponseContent
21 from .raw_client import AsyncRawEventStreamsClient, RawEventStreamsClient
22 from .types.event_streams_create_request import EventStreamsCreateRequest
23
24 if typing.TYPE_CHECKING:
25 from .deliveries.client import AsyncDeliveriesClient, DeliveriesClient
26 from .redeliveries.client import AsyncRedeliveriesClient, RedeliveriesClient
27 # this is used as the default value for optional parameters
28 OMIT = typing.cast(typing.Any, ...)
29
30
31 class EventStreamsClient:
32 def __init__(self, *, client_wrapper: SyncClientWrapper):
33 self._raw_client = RawEventStreamsClient(client_wrapper=client_wrapper)
34 self._client_wrapper = client_wrapper
35 self._deliveries: typing.Optional[DeliveriesClient] = None
36 self._redeliveries: typing.Optional[RedeliveriesClient] = None
37
38 @property
39 def with_raw_response(self) -> RawEventStreamsClient:
40 """
41 Retrieves a raw implementation of this client that returns raw responses.
42
43 Returns
44 -------
45 RawEventStreamsClient
46 """
47 return self._raw_client
48
49 def list(
50 self,
51 *,
52 from_: typing.Optional[str] = None,
53 take: typing.Optional[int] = 50,
54 request_options: typing.Optional[RequestOptions] = None,
55 ) -> SyncPager[EventStreamResponseContent, ListEventStreamsResponseContent]:
56 """
57 Parameters
58 ----------
59 from_ : typing.Optional[str]
60 Optional Id from which to start selection.
61
62 take : typing.Optional[int]
63 Number of results per page. Defaults to 50.
64
65 request_options : typing.Optional[RequestOptions]
66 Request-specific configuration.
67
68 Returns
69 -------
70 SyncPager[EventStreamResponseContent, ListEventStreamsResponseContent]
71 Event streams successfully retrieved.
72
73 Examples
74 --------
75 from auth0 import Auth0
76
77 client = Auth0(
78 token="YOUR_TOKEN",
79 )
80 response = client.event_streams.list(
81 from_="from",
82 take=1,
83 )
84 for item in response:
85 yield item
86 # alternatively, you can paginate page-by-page
87 for page in response.iter_pages():
88 yield page
89 """
90 return self._raw_client.list(from_=from_, take=take, request_options=request_options)
91
92 def create(
93 self, *, request: EventStreamsCreateRequest, request_options: typing.Optional[RequestOptions] = None
94 ) -> CreateEventStreamResponseContent:
95 """
96 Parameters
97 ----------
98 request : EventStreamsCreateRequest
99
100 request_options : typing.Optional[RequestOptions]
101 Request-specific configuration.
102
103 Returns
104 -------
105 CreateEventStreamResponseContent
106 Event Stream stream created successfully.
107
108 Examples
109 --------
110 from auth0 import (
111 Auth0,
112 CreateEventStreamWebHookRequestContent,
113 EventStreamWebhookBasicAuth,
114 EventStreamWebhookConfiguration,
115 EventStreamWebhookDestination,
116 )
117
118 client = Auth0(
119 token="YOUR_TOKEN",
120 )
121 client.event_streams.create(
122 request=CreateEventStreamWebHookRequestContent(
123 destination=EventStreamWebhookDestination(
124 type="webhook",
125 configuration=EventStreamWebhookConfiguration(
126 webhook_endpoint="webhook_endpoint",
127 webhook_authorization=EventStreamWebhookBasicAuth(
128 method="basic",
129 username="username",
130 ),
131 ),
132 ),
133 ),
134 )
135 """
136 _response = self._raw_client.create(request=request, request_options=request_options)
137 return _response.data
138
139 def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetEventStreamResponseContent:
140 """
141 Parameters
142 ----------
143 id : str
144 Unique identifier for the event stream.
145
146 request_options : typing.Optional[RequestOptions]
147 Request-specific configuration.
148
149 Returns
150 -------
151 GetEventStreamResponseContent
152 Event stream successfully retrieved.
153
154 Examples
155 --------
156 from auth0 import Auth0
157
158 client = Auth0(
159 token="YOUR_TOKEN",
160 )
161 client.event_streams.get(
162 id="id",
163 )
164 """
165 _response = self._raw_client.get(id, request_options=request_options)
166 return _response.data
167
168 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
169 """
170 Parameters
171 ----------
172 id : str
173 Unique identifier for the event stream.
174
175 request_options : typing.Optional[RequestOptions]
176 Request-specific configuration.
177
178 Returns
179 -------
180 None
181
182 Examples
183 --------
184 from auth0 import Auth0
185
186 client = Auth0(
187 token="YOUR_TOKEN",
188 )
189 client.event_streams.delete(
190 id="id",
191 )
192 """
193 _response = self._raw_client.delete(id, request_options=request_options)
194 return _response.data
195
196 def update(
197 self,
198 id: str,
199 *,
200 name: typing.Optional[str] = OMIT,
201 subscriptions: typing.Optional[typing.Sequence[EventStreamSubscription]] = OMIT,
202 destination: typing.Optional[EventStreamDestinationPatch] = OMIT,
203 status: typing.Optional[EventStreamStatusEnum] = OMIT,
204 request_options: typing.Optional[RequestOptions] = None,
205 ) -> UpdateEventStreamResponseContent:
206 """
207 Parameters
208 ----------
209 id : str
210 Unique identifier for the event stream.
211
212 name : typing.Optional[str]
213 Name of the event stream.
214
215 subscriptions : typing.Optional[typing.Sequence[EventStreamSubscription]]
216 List of event types subscribed to in this stream.
217
218 destination : typing.Optional[EventStreamDestinationPatch]
219
220 status : typing.Optional[EventStreamStatusEnum]
221
222 request_options : typing.Optional[RequestOptions]
223 Request-specific configuration.
224
225 Returns
226 -------
227 UpdateEventStreamResponseContent
228 Event stream successfully updated.
229
230 Examples
231 --------
232 from auth0 import Auth0
233
234 client = Auth0(
235 token="YOUR_TOKEN",
236 )
237 client.event_streams.update(
238 id="id",
239 )
240 """
241 _response = self._raw_client.update(
242 id,
243 name=name,
244 subscriptions=subscriptions,
245 destination=destination,
246 status=status,
247 request_options=request_options,
248 )
249 return _response.data
250
251 def test(
252 self,
253 id: str,
254 *,
255 event_type: EventStreamTestEventTypeEnum,
256 data: typing.Optional[TestEventDataContent] = OMIT,
257 request_options: typing.Optional[RequestOptions] = None,
258 ) -> CreateEventStreamTestEventResponseContent:
259 """
260 Parameters
261 ----------
262 id : str
263 Unique identifier for the event stream.
264
265 event_type : EventStreamTestEventTypeEnum
266
267 data : typing.Optional[TestEventDataContent]
268
269 request_options : typing.Optional[RequestOptions]
270 Request-specific configuration.
271
272 Returns
273 -------
274 CreateEventStreamTestEventResponseContent
275 Test event successfully submitted.
276
277 Examples
278 --------
279 from auth0 import Auth0
280
281 client = Auth0(
282 token="YOUR_TOKEN",
283 )
284 client.event_streams.test(
285 id="id",
286 event_type="connection.created",
287 )
288 """
289 _response = self._raw_client.test(id, event_type=event_type, data=data, request_options=request_options)
290 return _response.data
291
292 @property
293 def deliveries(self):
294 if self._deliveries is None:
295 from .deliveries.client import DeliveriesClient # noqa: E402
296
297 self._deliveries = DeliveriesClient(client_wrapper=self._client_wrapper)
298 return self._deliveries
299
300 @property
301 def redeliveries(self):
302 if self._redeliveries is None:
303 from .redeliveries.client import RedeliveriesClient # noqa: E402
304
305 self._redeliveries = RedeliveriesClient(client_wrapper=self._client_wrapper)
306 return self._redeliveries
307
308
309 class AsyncEventStreamsClient:
310 def __init__(self, *, client_wrapper: AsyncClientWrapper):
311 self._raw_client = AsyncRawEventStreamsClient(client_wrapper=client_wrapper)
312 self._client_wrapper = client_wrapper
313 self._deliveries: typing.Optional[AsyncDeliveriesClient] = None
314 self._redeliveries: typing.Optional[AsyncRedeliveriesClient] = None
315
316 @property
317 def with_raw_response(self) -> AsyncRawEventStreamsClient:
318 """
319 Retrieves a raw implementation of this client that returns raw responses.
320
321 Returns
322 -------
323 AsyncRawEventStreamsClient
324 """
325 return self._raw_client
326
327 async def list(
328 self,
329 *,
330 from_: typing.Optional[str] = None,
331 take: typing.Optional[int] = 50,
332 request_options: typing.Optional[RequestOptions] = None,
333 ) -> AsyncPager[EventStreamResponseContent, ListEventStreamsResponseContent]:
334 """
335 Parameters
336 ----------
337 from_ : typing.Optional[str]
338 Optional Id from which to start selection.
339
340 take : typing.Optional[int]
341 Number of results per page. Defaults to 50.
342
343 request_options : typing.Optional[RequestOptions]
344 Request-specific configuration.
345
346 Returns
347 -------
348 AsyncPager[EventStreamResponseContent, ListEventStreamsResponseContent]
349 Event streams successfully retrieved.
350
351 Examples
352 --------
353 import asyncio
354
355 from auth0 import AsyncAuth0
356
357 client = AsyncAuth0(
358 token="YOUR_TOKEN",
359 )
360
361
362 async def main() -> None:
363 response = await client.event_streams.list(
364 from_="from",
365 take=1,
366 )
367 async for item in response:
368 yield item
369
370 # alternatively, you can paginate page-by-page
371 async for page in response.iter_pages():
372 yield page
373
374
375 asyncio.run(main())
376 """
377 return await self._raw_client.list(from_=from_, take=take, request_options=request_options)
378
379 async def create(
380 self, *, request: EventStreamsCreateRequest, request_options: typing.Optional[RequestOptions] = None
381 ) -> CreateEventStreamResponseContent:
382 """
383 Parameters
384 ----------
385 request : EventStreamsCreateRequest
386
387 request_options : typing.Optional[RequestOptions]
388 Request-specific configuration.
389
390 Returns
391 -------
392 CreateEventStreamResponseContent
393 Event Stream stream created successfully.
394
395 Examples
396 --------
397 import asyncio
398
399 from auth0 import (
400 AsyncAuth0,
401 CreateEventStreamWebHookRequestContent,
402 EventStreamWebhookBasicAuth,
403 EventStreamWebhookConfiguration,
404 EventStreamWebhookDestination,
405 )
406
407 client = AsyncAuth0(
408 token="YOUR_TOKEN",
409 )
410
411
412 async def main() -> None:
413 await client.event_streams.create(
414 request=CreateEventStreamWebHookRequestContent(
415 destination=EventStreamWebhookDestination(
416 type="webhook",
417 configuration=EventStreamWebhookConfiguration(
418 webhook_endpoint="webhook_endpoint",
419 webhook_authorization=EventStreamWebhookBasicAuth(
420 method="basic",
421 username="username",
422 ),
423 ),
424 ),
425 ),
426 )
427
428
429 asyncio.run(main())
430 """
431 _response = await self._raw_client.create(request=request, request_options=request_options)
432 return _response.data
433
434 async def get(
435 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
436 ) -> GetEventStreamResponseContent:
437 """
438 Parameters
439 ----------
440 id : str
441 Unique identifier for the event stream.
442
443 request_options : typing.Optional[RequestOptions]
444 Request-specific configuration.
445
446 Returns
447 -------
448 GetEventStreamResponseContent
449 Event stream successfully retrieved.
450
451 Examples
452 --------
453 import asyncio
454
455 from auth0 import AsyncAuth0
456
457 client = AsyncAuth0(
458 token="YOUR_TOKEN",
459 )
460
461
462 async def main() -> None:
463 await client.event_streams.get(
464 id="id",
465 )
466
467
468 asyncio.run(main())
469 """
470 _response = await self._raw_client.get(id, request_options=request_options)
471 return _response.data
472
473 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
474 """
475 Parameters
476 ----------
477 id : str
478 Unique identifier for the event stream.
479
480 request_options : typing.Optional[RequestOptions]
481 Request-specific configuration.
482
483 Returns
484 -------
485 None
486
487 Examples
488 --------
489 import asyncio
490
491 from auth0 import AsyncAuth0
492
493 client = AsyncAuth0(
494 token="YOUR_TOKEN",
495 )
496
497
498 async def main() -> None:
499 await client.event_streams.delete(
500 id="id",
501 )
502
503
504 asyncio.run(main())
505 """
506 _response = await self._raw_client.delete(id, request_options=request_options)
507 return _response.data
508
509 async def update(
510 self,
511 id: str,
512 *,
513 name: typing.Optional[str] = OMIT,
514 subscriptions: typing.Optional[typing.Sequence[EventStreamSubscription]] = OMIT,
515 destination: typing.Optional[EventStreamDestinationPatch] = OMIT,
516 status: typing.Optional[EventStreamStatusEnum] = OMIT,
517 request_options: typing.Optional[RequestOptions] = None,
518 ) -> UpdateEventStreamResponseContent:
519 """
520 Parameters
521 ----------
522 id : str
523 Unique identifier for the event stream.
524
525 name : typing.Optional[str]
526 Name of the event stream.
527
528 subscriptions : typing.Optional[typing.Sequence[EventStreamSubscription]]
529 List of event types subscribed to in this stream.
530
531 destination : typing.Optional[EventStreamDestinationPatch]
532
533 status : typing.Optional[EventStreamStatusEnum]
534
535 request_options : typing.Optional[RequestOptions]
536 Request-specific configuration.
537
538 Returns
539 -------
540 UpdateEventStreamResponseContent
541 Event stream successfully updated.
542
543 Examples
544 --------
545 import asyncio
546
547 from auth0 import AsyncAuth0
548
549 client = AsyncAuth0(
550 token="YOUR_TOKEN",
551 )
552
553
554 async def main() -> None:
555 await client.event_streams.update(
556 id="id",
557 )
558
559
560 asyncio.run(main())
561 """
562 _response = await self._raw_client.update(
563 id,
564 name=name,
565 subscriptions=subscriptions,
566 destination=destination,
567 status=status,
568 request_options=request_options,
569 )
570 return _response.data
571
572 async def test(
573 self,
574 id: str,
575 *,
576 event_type: EventStreamTestEventTypeEnum,
577 data: typing.Optional[TestEventDataContent] = OMIT,
578 request_options: typing.Optional[RequestOptions] = None,
579 ) -> CreateEventStreamTestEventResponseContent:
580 """
581 Parameters
582 ----------
583 id : str
584 Unique identifier for the event stream.
585
586 event_type : EventStreamTestEventTypeEnum
587
588 data : typing.Optional[TestEventDataContent]
589
590 request_options : typing.Optional[RequestOptions]
591 Request-specific configuration.
592
593 Returns
594 -------
595 CreateEventStreamTestEventResponseContent
596 Test event successfully submitted.
597
598 Examples
599 --------
600 import asyncio
601
602 from auth0 import AsyncAuth0
603
604 client = AsyncAuth0(
605 token="YOUR_TOKEN",
606 )
607
608
609 async def main() -> None:
610 await client.event_streams.test(
611 id="id",
612 event_type="connection.created",
613 )
614
615
616 asyncio.run(main())
617 """
618 _response = await self._raw_client.test(id, event_type=event_type, data=data, request_options=request_options)
619 return _response.data
620
621 @property
622 def deliveries(self):
623 if self._deliveries is None:
624 from .deliveries.client import AsyncDeliveriesClient # noqa: E402
625
626 self._deliveries = AsyncDeliveriesClient(client_wrapper=self._client_wrapper)
627 return self._deliveries
628
629 @property
630 def redeliveries(self):
631 if self._redeliveries is None:
632 from .redeliveries.client import AsyncRedeliveriesClient # noqa: E402
633
634 self._redeliveries = AsyncRedeliveriesClient(client_wrapper=self._client_wrapper)
635 return self._redeliveries