Debian Codegraph @

src/auth0/management/log_streams/raw_client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4 from json.decoder import JSONDecodeError
5
6 from ..core.api_error import ApiError
7 from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ..core.http_response import AsyncHttpResponse, HttpResponse
9 from ..core.jsonable_encoder import encode_path_param
10 from ..core.parse_error import ParsingError
11 from ..core.pydantic_utilities import parse_obj_as
12 from ..core.request_options import RequestOptions
13 from ..core.serialization import convert_and_respect_annotation_metadata
14 from ..errors.bad_request_error import BadRequestError
15 from ..errors.conflict_error import ConflictError
16 from ..errors.forbidden_error import ForbiddenError
17 from ..errors.not_found_error import NotFoundError
18 from ..errors.too_many_requests_error import TooManyRequestsError
19 from ..errors.unauthorized_error import UnauthorizedError
20 from ..types.create_log_stream_request_content import CreateLogStreamRequestContent
21 from ..types.create_log_stream_response_content import CreateLogStreamResponseContent
22 from ..types.get_log_stream_response_content import GetLogStreamResponseContent
23 from ..types.log_stream_filter import LogStreamFilter
24 from ..types.log_stream_pii_config import LogStreamPiiConfig
25 from ..types.log_stream_response_schema import LogStreamResponseSchema
26 from ..types.log_stream_sink_patch import LogStreamSinkPatch
27 from ..types.log_stream_status_enum import LogStreamStatusEnum
28 from ..types.update_log_stream_response_content import UpdateLogStreamResponseContent
29 from pydantic import ValidationError
30
31 # this is used as the default value for optional parameters
32 OMIT = typing.cast(typing.Any, ...)
33
34
35 class RawLogStreamsClient:
36 def __init__(self, *, client_wrapper: SyncClientWrapper):
37 self._client_wrapper = client_wrapper
38
39 def list(
40 self, *, request_options: typing.Optional[RequestOptions] = None
41 ) -> HttpResponse[typing.List[LogStreamResponseSchema]]:
42 """
43 Retrieve details on [log streams](https://auth0.com/docs/logs/streams).
44
45 **Sample Response**
46
47 ```json
48 [{
49 "id": "string",
50 "name": "string",
51 "type": "eventbridge",
52 "status": "active|paused|suspended",
53 "sink": {
54 "awsAccountId": "string",
55 "awsRegion": "string",
56 "awsPartnerEventSource": "string"
57 }
58 }, {
59 "id": "string",
60 "name": "string",
61 "type": "http",
62 "status": "active|paused|suspended",
63 "sink": {
64 "httpContentFormat": "JSONLINES|JSONARRAY",
65 "httpContentType": "string",
66 "httpEndpoint": "string",
67 "httpAuthorization": "string"
68 }
69 },
70 {
71 "id": "string",
72 "name": "string",
73 "type": "eventgrid",
74 "status": "active|paused|suspended",
75 "sink": {
76 "azureSubscriptionId": "string",
77 "azureResourceGroup": "string",
78 "azureRegion": "string",
79 "azurePartnerTopic": "string"
80 }
81 },
82 {
83 "id": "string",
84 "name": "string",
85 "type": "splunk",
86 "status": "active|paused|suspended",
87 "sink": {
88 "splunkDomain": "string",
89 "splunkToken": "string",
90 "splunkPort": "string",
91 "splunkSecure": "boolean"
92 }
93 },
94 {
95 "id": "string",
96 "name": "string",
97 "type": "sumo",
98 "status": "active|paused|suspended",
99 "sink": {
100 "sumoSourceAddress": "string"
101 }
102 },
103 {
104 "id": "string",
105 "name": "string",
106 "type": "datadog",
107 "status": "active|paused|suspended",
108 "sink": {
109 "datadogRegion": "string",
110 "datadogApiKey": "string"
111 }
112 }]
113 ```
114
115 Parameters
116 ----------
117 request_options : typing.Optional[RequestOptions]
118 Request-specific configuration.
119
120 Returns
121 -------
122 HttpResponse[typing.List[LogStreamResponseSchema]]
123 Returning log streams
124 """
125 _response = self._client_wrapper.httpx_client.request(
126 "log-streams",
127 method="GET",
128 request_options=request_options,
129 )
130 try:
131 if 200 <= _response.status_code < 300:
132 _data = typing.cast(
133 typing.List[LogStreamResponseSchema],
134 parse_obj_as(
135 type_=typing.List[LogStreamResponseSchema], # type: ignore
136 object_=_response.json(),
137 ),
138 )
139 return HttpResponse(response=_response, data=_data)
140 if _response.status_code == 401:
141 raise UnauthorizedError(
142 headers=dict(_response.headers),
143 body=typing.cast(
144 typing.Any,
145 parse_obj_as(
146 type_=typing.Any, # type: ignore
147 object_=_response.json(),
148 ),
149 ),
150 )
151 if _response.status_code == 403:
152 raise ForbiddenError(
153 headers=dict(_response.headers),
154 body=typing.cast(
155 typing.Any,
156 parse_obj_as(
157 type_=typing.Any, # type: ignore
158 object_=_response.json(),
159 ),
160 ),
161 )
162 if _response.status_code == 404:
163 raise NotFoundError(
164 headers=dict(_response.headers),
165 body=typing.cast(
166 typing.Any,
167 parse_obj_as(
168 type_=typing.Any, # type: ignore
169 object_=_response.json(),
170 ),
171 ),
172 )
173 if _response.status_code == 429:
174 raise TooManyRequestsError(
175 headers=dict(_response.headers),
176 body=typing.cast(
177 typing.Any,
178 parse_obj_as(
179 type_=typing.Any, # type: ignore
180 object_=_response.json(),
181 ),
182 ),
183 )
184 _response_json = _response.json()
185 except JSONDecodeError:
186 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
187 except ValidationError as e:
188 raise ParsingError(
189 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
190 )
191 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
192
193 def create(
194 self, *, request: CreateLogStreamRequestContent, request_options: typing.Optional[RequestOptions] = None
195 ) -> HttpResponse[CreateLogStreamResponseContent]:
196 """
197 Create a log stream.
198
199 **Log Stream Types**
200
201 The `type` of log stream being created determines the properties required in the `sink` payload.
202
203 **HTTP Stream**
204
205 For an `http` Stream, the `sink` properties are listed in the payload below.
206
207 **Request:**
208 ```json
209 {
210 "name": "string",
211 "type": "http",
212 "sink": {
213 "httpEndpoint": "string",
214 "httpContentType": "string",
215 "httpContentFormat": "JSONLINES|JSONARRAY",
216 "httpAuthorization": "string"
217 }
218 }
219 ```
220
221 **Response:**
222 ```json
223 {
224 "id": "string",
225 "name": "string",
226 "type": "http",
227 "status": "active",
228 "sink": {
229 "httpEndpoint": "string",
230 "httpContentType": "string",
231 "httpContentFormat": "JSONLINES|JSONARRAY",
232 "httpAuthorization": "string"
233 }
234 }
235 ```
236
237 **Amazon EventBridge Stream**
238
239 For an `eventbridge` Stream, the `sink` properties are listed in the payload below.
240
241 **Request:**
242 ```json
243 {
244 "name": "string",
245 "type": "eventbridge",
246 "sink": {
247 "awsRegion": "string",
248 "awsAccountId": "string"
249 }
250 }
251 ```
252
253 The response will include an additional field `awsPartnerEventSource` in the `sink`:
254
255 **Response:**
256 ```json
257 {
258 "id": "string",
259 "name": "string",
260 "type": "eventbridge",
261 "status": "active",
262 "sink": {
263 "awsAccountId": "string",
264 "awsRegion": "string",
265 "awsPartnerEventSource": "string"
266 }
267 }
268 ```
269
270 **Azure Event Grid Stream**
271
272 For an `Azure Event Grid` Stream, the `sink` properties are listed in the payload below.
273
274 **Request:**
275 ```json
276 {
277 "name": "string",
278 "type": "eventgrid",
279 "sink": {
280 "azureSubscriptionId": "string",
281 "azureResourceGroup": "string",
282 "azureRegion": "string"
283 }
284 }
285 ```
286
287 **Response:**
288 ```json
289 {
290 "id": "string",
291 "name": "string",
292 "type": "http",
293 "status": "active",
294 "sink": {
295 "azureSubscriptionId": "string",
296 "azureResourceGroup": "string",
297 "azureRegion": "string",
298 "azurePartnerTopic": "string"
299 }
300 }
301 ```
302
303 **Datadog Stream**
304
305 For a `Datadog` Stream, the `sink` properties are listed in the payload below.
306
307 **Request:**
308 ```json
309 {
310 "name": "string",
311 "type": "datadog",
312 "sink": {
313 "datadogRegion": "string",
314 "datadogApiKey": "string"
315 }
316 }
317 ```
318
319 **Response:**
320 ```json
321 {
322 "id": "string",
323 "name": "string",
324 "type": "datadog",
325 "status": "active",
326 "sink": {
327 "datadogRegion": "string",
328 "datadogApiKey": "string"
329 }
330 }
331 ```
332
333 **Splunk Stream**
334
335 For a `Splunk` Stream, the `sink` properties are listed in the payload below.
336
337 **Request:**
338 ```json
339 {
340 "name": "string",
341 "type": "splunk",
342 "sink": {
343 "splunkDomain": "string",
344 "splunkToken": "string",
345 "splunkPort": "string",
346 "splunkSecure": "boolean"
347 }
348 }
349 ```
350
351 **Response:**
352 ```json
353 {
354 "id": "string",
355 "name": "string",
356 "type": "splunk",
357 "status": "active",
358 "sink": {
359 "splunkDomain": "string",
360 "splunkToken": "string",
361 "splunkPort": "string",
362 "splunkSecure": "boolean"
363 }
364 }
365 ```
366
367 **Sumo Logic Stream**
368
369 For a `Sumo Logic` Stream, the `sink` properties are listed in the payload below.
370
371 **Request:**
372 ```json
373 {
374 "name": "string",
375 "type": "sumo",
376 "sink": {
377 "sumoSourceAddress": "string"
378 }
379 }
380 ```
381
382 **Response:**
383 ```json
384 {
385 "id": "string",
386 "name": "string",
387 "type": "sumo",
388 "status": "active",
389 "sink": {
390 "sumoSourceAddress": "string"
391 }
392 }
393 ```
394
395 Parameters
396 ----------
397 request : CreateLogStreamRequestContent
398
399 request_options : typing.Optional[RequestOptions]
400 Request-specific configuration.
401
402 Returns
403 -------
404 HttpResponse[CreateLogStreamResponseContent]
405 Log stream created
406 """
407 _response = self._client_wrapper.httpx_client.request(
408 "log-streams",
409 method="POST",
410 json=convert_and_respect_annotation_metadata(
411 object_=request, annotation=CreateLogStreamRequestContent, direction="write"
412 ),
413 request_options=request_options,
414 omit=OMIT,
415 )
416 try:
417 if 200 <= _response.status_code < 300:
418 _data = typing.cast(
419 CreateLogStreamResponseContent,
420 parse_obj_as(
421 type_=CreateLogStreamResponseContent, # type: ignore
422 object_=_response.json(),
423 ),
424 )
425 return HttpResponse(response=_response, data=_data)
426 if _response.status_code == 400:
427 raise BadRequestError(
428 headers=dict(_response.headers),
429 body=typing.cast(
430 typing.Any,
431 parse_obj_as(
432 type_=typing.Any, # type: ignore
433 object_=_response.json(),
434 ),
435 ),
436 )
437 if _response.status_code == 401:
438 raise UnauthorizedError(
439 headers=dict(_response.headers),
440 body=typing.cast(
441 typing.Any,
442 parse_obj_as(
443 type_=typing.Any, # type: ignore
444 object_=_response.json(),
445 ),
446 ),
447 )
448 if _response.status_code == 403:
449 raise ForbiddenError(
450 headers=dict(_response.headers),
451 body=typing.cast(
452 typing.Any,
453 parse_obj_as(
454 type_=typing.Any, # type: ignore
455 object_=_response.json(),
456 ),
457 ),
458 )
459 if _response.status_code == 409:
460 raise ConflictError(
461 headers=dict(_response.headers),
462 body=typing.cast(
463 typing.Any,
464 parse_obj_as(
465 type_=typing.Any, # type: ignore
466 object_=_response.json(),
467 ),
468 ),
469 )
470 if _response.status_code == 429:
471 raise TooManyRequestsError(
472 headers=dict(_response.headers),
473 body=typing.cast(
474 typing.Any,
475 parse_obj_as(
476 type_=typing.Any, # type: ignore
477 object_=_response.json(),
478 ),
479 ),
480 )
481 _response_json = _response.json()
482 except JSONDecodeError:
483 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
484 except ValidationError as e:
485 raise ParsingError(
486 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
487 )
488 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
489
490 def get(
491 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
492 ) -> HttpResponse[GetLogStreamResponseContent]:
493 """
494 Retrieve a log stream configuration and status.
495
496 **Sample responses**
497
498 **Amazon EventBridge Log Stream**
499
500 ```json
501 {
502 "id": "string",
503 "name": "string",
504 "type": "eventbridge",
505 "status": "active|paused|suspended",
506 "sink": {
507 "awsAccountId": "string",
508 "awsRegion": "string",
509 "awsPartnerEventSource": "string"
510 }
511 }
512 ```
513
514 **HTTP Log Stream**
515
516 ```json
517 {
518 "id": "string",
519 "name": "string",
520 "type": "http",
521 "status": "active|paused|suspended",
522 "sink": {
523 "httpContentFormat": "JSONLINES|JSONARRAY",
524 "httpContentType": "string",
525 "httpEndpoint": "string",
526 "httpAuthorization": "string"
527 }
528 }
529 ```
530
531 **Datadog Log Stream**
532
533 ```json
534 {
535 "id": "string",
536 "name": "string",
537 "type": "datadog",
538 "status": "active|paused|suspended",
539 "sink": {
540 "datadogRegion": "string",
541 "datadogApiKey": "string"
542 }
543 }
544 ```
545
546 **Mixpanel**
547
548 **Request:**
549
550 ```json
551 {
552 "name": "string",
553 "type": "mixpanel",
554 "sink": {
555 "mixpanelRegion": "string",
556 "mixpanelProjectId": "string",
557 "mixpanelServiceAccountUsername": "string",
558 "mixpanelServiceAccountPassword": "string"
559 }
560 }
561 ```
562
563 **Response:**
564
565 ```json
566 {
567 "id": "string",
568 "name": "string",
569 "type": "mixpanel",
570 "status": "active",
571 "sink": {
572 "mixpanelRegion": "string",
573 "mixpanelProjectId": "string",
574 "mixpanelServiceAccountUsername": "string",
575 "mixpanelServiceAccountPassword": "string"
576 }
577 }
578 ```
579
580 **Segment**
581
582 **Request:**
583
584 ```json
585 {
586 "name": "string",
587 "type": "segment",
588 "sink": {
589 "segmentWriteKey": "string"
590 }
591 }
592 ```
593
594 **Response:**
595
596 ```json
597 {
598 "id": "string",
599 "name": "string",
600 "type": "segment",
601 "status": "active",
602 "sink": {
603 "segmentWriteKey": "string"
604 }
605 }
606 ```
607
608 **Splunk Log Stream**
609
610 ```json
611 {
612 "id": "string",
613 "name": "string",
614 "type": "splunk",
615 "status": "active|paused|suspended",
616 "sink": {
617 "splunkDomain": "string",
618 "splunkToken": "string",
619 "splunkPort": "string",
620 "splunkSecure": "boolean"
621 }
622 }
623 ```
624
625 **Sumo Logic Log Stream**
626
627 ```json
628 {
629 "id": "string",
630 "name": "string",
631 "type": "sumo",
632 "status": "active|paused|suspended",
633 "sink": {
634 "sumoSourceAddress": "string"
635 }
636 }
637 ```
638
639 **Status**
640
641 The `status` of a log stream maybe any of the following:
642
643 1. `active` - Stream is currently enabled.
644 2. `paused` - Stream is currently user disabled and will not attempt log delivery.
645 3. `suspended` - Stream is currently disabled because of errors and will not attempt log delivery.
646
647 Parameters
648 ----------
649 id : str
650 The id of the log stream to get
651
652 request_options : typing.Optional[RequestOptions]
653 Request-specific configuration.
654
655 Returns
656 -------
657 HttpResponse[GetLogStreamResponseContent]
658 Returning log stream.
659 """
660 _response = self._client_wrapper.httpx_client.request(
661 f"log-streams/{encode_path_param(id)}",
662 method="GET",
663 request_options=request_options,
664 )
665 try:
666 if 200 <= _response.status_code < 300:
667 _data = typing.cast(
668 GetLogStreamResponseContent,
669 parse_obj_as(
670 type_=GetLogStreamResponseContent, # type: ignore
671 object_=_response.json(),
672 ),
673 )
674 return HttpResponse(response=_response, data=_data)
675 if _response.status_code == 401:
676 raise UnauthorizedError(
677 headers=dict(_response.headers),
678 body=typing.cast(
679 typing.Any,
680 parse_obj_as(
681 type_=typing.Any, # type: ignore
682 object_=_response.json(),
683 ),
684 ),
685 )
686 if _response.status_code == 403:
687 raise ForbiddenError(
688 headers=dict(_response.headers),
689 body=typing.cast(
690 typing.Any,
691 parse_obj_as(
692 type_=typing.Any, # type: ignore
693 object_=_response.json(),
694 ),
695 ),
696 )
697 if _response.status_code == 404:
698 raise NotFoundError(
699 headers=dict(_response.headers),
700 body=typing.cast(
701 typing.Any,
702 parse_obj_as(
703 type_=typing.Any, # type: ignore
704 object_=_response.json(),
705 ),
706 ),
707 )
708 if _response.status_code == 429:
709 raise TooManyRequestsError(
710 headers=dict(_response.headers),
711 body=typing.cast(
712 typing.Any,
713 parse_obj_as(
714 type_=typing.Any, # type: ignore
715 object_=_response.json(),
716 ),
717 ),
718 )
719 _response_json = _response.json()
720 except JSONDecodeError:
721 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
722 except ValidationError as e:
723 raise ParsingError(
724 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
725 )
726 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
727
728 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
729 """
730 Delete a log stream.
731
732 Parameters
733 ----------
734 id : str
735 The id of the log stream to delete
736
737 request_options : typing.Optional[RequestOptions]
738 Request-specific configuration.
739
740 Returns
741 -------
742 HttpResponse[None]
743 """
744 _response = self._client_wrapper.httpx_client.request(
745 f"log-streams/{encode_path_param(id)}",
746 method="DELETE",
747 request_options=request_options,
748 )
749 try:
750 if 200 <= _response.status_code < 300:
751 return HttpResponse(response=_response, data=None)
752 if _response.status_code == 400:
753 raise BadRequestError(
754 headers=dict(_response.headers),
755 body=typing.cast(
756 typing.Any,
757 parse_obj_as(
758 type_=typing.Any, # type: ignore
759 object_=_response.json(),
760 ),
761 ),
762 )
763 if _response.status_code == 401:
764 raise UnauthorizedError(
765 headers=dict(_response.headers),
766 body=typing.cast(
767 typing.Any,
768 parse_obj_as(
769 type_=typing.Any, # type: ignore
770 object_=_response.json(),
771 ),
772 ),
773 )
774 if _response.status_code == 403:
775 raise ForbiddenError(
776 headers=dict(_response.headers),
777 body=typing.cast(
778 typing.Any,
779 parse_obj_as(
780 type_=typing.Any, # type: ignore
781 object_=_response.json(),
782 ),
783 ),
784 )
785 if _response.status_code == 404:
786 raise NotFoundError(
787 headers=dict(_response.headers),
788 body=typing.cast(
789 typing.Any,
790 parse_obj_as(
791 type_=typing.Any, # type: ignore
792 object_=_response.json(),
793 ),
794 ),
795 )
796 if _response.status_code == 429:
797 raise TooManyRequestsError(
798 headers=dict(_response.headers),
799 body=typing.cast(
800 typing.Any,
801 parse_obj_as(
802 type_=typing.Any, # type: ignore
803 object_=_response.json(),
804 ),
805 ),
806 )
807 _response_json = _response.json()
808 except JSONDecodeError:
809 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
810 except ValidationError as e:
811 raise ParsingError(
812 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
813 )
814 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
815
816 def update(
817 self,
818 id: str,
819 *,
820 name: typing.Optional[str] = OMIT,
821 status: typing.Optional[LogStreamStatusEnum] = OMIT,
822 is_priority: typing.Optional[bool] = OMIT,
823 filters: typing.Optional[typing.Sequence[LogStreamFilter]] = OMIT,
824 pii_config: typing.Optional[LogStreamPiiConfig] = OMIT,
825 sink: typing.Optional[LogStreamSinkPatch] = OMIT,
826 request_options: typing.Optional[RequestOptions] = None,
827 ) -> HttpResponse[UpdateLogStreamResponseContent]:
828 """
829 Update a log stream.
830
831 **Examples of how to use the PATCH endpoint.**
832
833 The following fields may be updated in a PATCH operation:
834
835 - name
836 - status
837 - sink
838
839 Note: For log streams of type `eventbridge` and `eventgrid`, updating the `sink` is not permitted.
840
841 **Update the status of a log stream**
842
843 ```json
844 {
845 "status": "active|paused"
846 }
847 ```
848
849 **Update the name of a log stream**
850
851 ```json
852 {
853 "name": "string"
854 }
855 ```
856
857 **Update the sink properties of a stream of type `http`**
858
859 ```json
860 {
861 "sink": {
862 "httpEndpoint": "string",
863 "httpContentType": "string",
864 "httpContentFormat": "JSONARRAY|JSONLINES",
865 "httpAuthorization": "string"
866 }
867 }
868 ```
869
870 **Update the sink properties of a stream of type `datadog`**
871
872 ```json
873 {
874 "sink": {
875 "datadogRegion": "string",
876 "datadogApiKey": "string"
877 }
878 }
879 ```
880
881 **Update the sink properties of a stream of type `splunk`**
882
883 ```json
884 {
885 "sink": {
886 "splunkDomain": "string",
887 "splunkToken": "string",
888 "splunkPort": "string",
889 "splunkSecure": "boolean"
890 }
891 }
892 ```
893
894 **Update the sink properties of a stream of type `sumo`**
895
896 ```json
897 {
898 "sink": {
899 "sumoSourceAddress": "string"
900 }
901 }
902 ```
903
904 Parameters
905 ----------
906 id : str
907 The id of the log stream to get
908
909 name : typing.Optional[str]
910 log stream name
911
912 status : typing.Optional[LogStreamStatusEnum]
913
914 is_priority : typing.Optional[bool]
915 True for priority log streams, false for non-priority
916
917 filters : typing.Optional[typing.Sequence[LogStreamFilter]]
918 Only logs events matching these filters will be delivered by the stream. If omitted or empty, all events will be delivered.
919
920 pii_config : typing.Optional[LogStreamPiiConfig]
921
922 sink : typing.Optional[LogStreamSinkPatch]
923
924 request_options : typing.Optional[RequestOptions]
925 Request-specific configuration.
926
927 Returns
928 -------
929 HttpResponse[UpdateLogStreamResponseContent]
930 Log stream updated
931 """
932 _response = self._client_wrapper.httpx_client.request(
933 f"log-streams/{encode_path_param(id)}",
934 method="PATCH",
935 json={
936 "name": name,
937 "status": status,
938 "isPriority": is_priority,
939 "filters": convert_and_respect_annotation_metadata(
940 object_=filters, annotation=typing.Sequence[LogStreamFilter], direction="write"
941 ),
942 "pii_config": convert_and_respect_annotation_metadata(
943 object_=pii_config, annotation=LogStreamPiiConfig, direction="write"
944 ),
945 "sink": convert_and_respect_annotation_metadata(
946 object_=sink, annotation=LogStreamSinkPatch, direction="write"
947 ),
948 },
949 headers={
950 "content-type": "application/json",
951 },
952 request_options=request_options,
953 omit=OMIT,
954 )
955 try:
956 if 200 <= _response.status_code < 300:
957 _data = typing.cast(
958 UpdateLogStreamResponseContent,
959 parse_obj_as(
960 type_=UpdateLogStreamResponseContent, # type: ignore
961 object_=_response.json(),
962 ),
963 )
964 return HttpResponse(response=_response, data=_data)
965 if _response.status_code == 400:
966 raise BadRequestError(
967 headers=dict(_response.headers),
968 body=typing.cast(
969 typing.Any,
970 parse_obj_as(
971 type_=typing.Any, # type: ignore
972 object_=_response.json(),
973 ),
974 ),
975 )
976 if _response.status_code == 401:
977 raise UnauthorizedError(
978 headers=dict(_response.headers),
979 body=typing.cast(
980 typing.Any,
981 parse_obj_as(
982 type_=typing.Any, # type: ignore
983 object_=_response.json(),
984 ),
985 ),
986 )
987 if _response.status_code == 403:
988 raise ForbiddenError(
989 headers=dict(_response.headers),
990 body=typing.cast(
991 typing.Any,
992 parse_obj_as(
993 type_=typing.Any, # type: ignore
994 object_=_response.json(),
995 ),
996 ),
997 )
998 if _response.status_code == 429:
999 raise TooManyRequestsError(
1000 headers=dict(_response.headers),
1001 body=typing.cast(
1002 typing.Any,
1003 parse_obj_as(
1004 type_=typing.Any, # type: ignore
1005 object_=_response.json(),
1006 ),
1007 ),
1008 )
1009 _response_json = _response.json()
1010 except JSONDecodeError:
1011 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1012 except ValidationError as e:
1013 raise ParsingError(
1014 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1015 )
1016 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1017
1018
1019 class AsyncRawLogStreamsClient:
1020 def __init__(self, *, client_wrapper: AsyncClientWrapper):
1021 self._client_wrapper = client_wrapper
1022
1023 async def list(
1024 self, *, request_options: typing.Optional[RequestOptions] = None
1025 ) -> AsyncHttpResponse[typing.List[LogStreamResponseSchema]]:
1026 """
1027 Retrieve details on [log streams](https://auth0.com/docs/logs/streams).
1028
1029 **Sample Response**
1030
1031 ```json
1032 [{
1033 "id": "string",
1034 "name": "string",
1035 "type": "eventbridge",
1036 "status": "active|paused|suspended",
1037 "sink": {
1038 "awsAccountId": "string",
1039 "awsRegion": "string",
1040 "awsPartnerEventSource": "string"
1041 }
1042 }, {
1043 "id": "string",
1044 "name": "string",
1045 "type": "http",
1046 "status": "active|paused|suspended",
1047 "sink": {
1048 "httpContentFormat": "JSONLINES|JSONARRAY",
1049 "httpContentType": "string",
1050 "httpEndpoint": "string",
1051 "httpAuthorization": "string"
1052 }
1053 },
1054 {
1055 "id": "string",
1056 "name": "string",
1057 "type": "eventgrid",
1058 "status": "active|paused|suspended",
1059 "sink": {
1060 "azureSubscriptionId": "string",
1061 "azureResourceGroup": "string",
1062 "azureRegion": "string",
1063 "azurePartnerTopic": "string"
1064 }
1065 },
1066 {
1067 "id": "string",
1068 "name": "string",
1069 "type": "splunk",
1070 "status": "active|paused|suspended",
1071 "sink": {
1072 "splunkDomain": "string",
1073 "splunkToken": "string",
1074 "splunkPort": "string",
1075 "splunkSecure": "boolean"
1076 }
1077 },
1078 {
1079 "id": "string",
1080 "name": "string",
1081 "type": "sumo",
1082 "status": "active|paused|suspended",
1083 "sink": {
1084 "sumoSourceAddress": "string"
1085 }
1086 },
1087 {
1088 "id": "string",
1089 "name": "string",
1090 "type": "datadog",
1091 "status": "active|paused|suspended",
1092 "sink": {
1093 "datadogRegion": "string",
1094 "datadogApiKey": "string"
1095 }
1096 }]
1097 ```
1098
1099 Parameters
1100 ----------
1101 request_options : typing.Optional[RequestOptions]
1102 Request-specific configuration.
1103
1104 Returns
1105 -------
1106 AsyncHttpResponse[typing.List[LogStreamResponseSchema]]
1107 Returning log streams
1108 """
1109 _response = await self._client_wrapper.httpx_client.request(
1110 "log-streams",
1111 method="GET",
1112 request_options=request_options,
1113 )
1114 try:
1115 if 200 <= _response.status_code < 300:
1116 _data = typing.cast(
1117 typing.List[LogStreamResponseSchema],
1118 parse_obj_as(
1119 type_=typing.List[LogStreamResponseSchema], # type: ignore
1120 object_=_response.json(),
1121 ),
1122 )
1123 return AsyncHttpResponse(response=_response, data=_data)
1124 if _response.status_code == 401:
1125 raise UnauthorizedError(
1126 headers=dict(_response.headers),
1127 body=typing.cast(
1128 typing.Any,
1129 parse_obj_as(
1130 type_=typing.Any, # type: ignore
1131 object_=_response.json(),
1132 ),
1133 ),
1134 )
1135 if _response.status_code == 403:
1136 raise ForbiddenError(
1137 headers=dict(_response.headers),
1138 body=typing.cast(
1139 typing.Any,
1140 parse_obj_as(
1141 type_=typing.Any, # type: ignore
1142 object_=_response.json(),
1143 ),
1144 ),
1145 )
1146 if _response.status_code == 404:
1147 raise NotFoundError(
1148 headers=dict(_response.headers),
1149 body=typing.cast(
1150 typing.Any,
1151 parse_obj_as(
1152 type_=typing.Any, # type: ignore
1153 object_=_response.json(),
1154 ),
1155 ),
1156 )
1157 if _response.status_code == 429:
1158 raise TooManyRequestsError(
1159 headers=dict(_response.headers),
1160 body=typing.cast(
1161 typing.Any,
1162 parse_obj_as(
1163 type_=typing.Any, # type: ignore
1164 object_=_response.json(),
1165 ),
1166 ),
1167 )
1168 _response_json = _response.json()
1169 except JSONDecodeError:
1170 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1171 except ValidationError as e:
1172 raise ParsingError(
1173 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1174 )
1175 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1176
1177 async def create(
1178 self, *, request: CreateLogStreamRequestContent, request_options: typing.Optional[RequestOptions] = None
1179 ) -> AsyncHttpResponse[CreateLogStreamResponseContent]:
1180 """
1181 Create a log stream.
1182
1183 **Log Stream Types**
1184
1185 The `type` of log stream being created determines the properties required in the `sink` payload.
1186
1187 **HTTP Stream**
1188
1189 For an `http` Stream, the `sink` properties are listed in the payload below.
1190
1191 **Request:**
1192 ```json
1193 {
1194 "name": "string",
1195 "type": "http",
1196 "sink": {
1197 "httpEndpoint": "string",
1198 "httpContentType": "string",
1199 "httpContentFormat": "JSONLINES|JSONARRAY",
1200 "httpAuthorization": "string"
1201 }
1202 }
1203 ```
1204
1205 **Response:**
1206 ```json
1207 {
1208 "id": "string",
1209 "name": "string",
1210 "type": "http",
1211 "status": "active",
1212 "sink": {
1213 "httpEndpoint": "string",
1214 "httpContentType": "string",
1215 "httpContentFormat": "JSONLINES|JSONARRAY",
1216 "httpAuthorization": "string"
1217 }
1218 }
1219 ```
1220
1221 **Amazon EventBridge Stream**
1222
1223 For an `eventbridge` Stream, the `sink` properties are listed in the payload below.
1224
1225 **Request:**
1226 ```json
1227 {
1228 "name": "string",
1229 "type": "eventbridge",
1230 "sink": {
1231 "awsRegion": "string",
1232 "awsAccountId": "string"
1233 }
1234 }
1235 ```
1236
1237 The response will include an additional field `awsPartnerEventSource` in the `sink`:
1238
1239 **Response:**
1240 ```json
1241 {
1242 "id": "string",
1243 "name": "string",
1244 "type": "eventbridge",
1245 "status": "active",
1246 "sink": {
1247 "awsAccountId": "string",
1248 "awsRegion": "string",
1249 "awsPartnerEventSource": "string"
1250 }
1251 }
1252 ```
1253
1254 **Azure Event Grid Stream**
1255
1256 For an `Azure Event Grid` Stream, the `sink` properties are listed in the payload below.
1257
1258 **Request:**
1259 ```json
1260 {
1261 "name": "string",
1262 "type": "eventgrid",
1263 "sink": {
1264 "azureSubscriptionId": "string",
1265 "azureResourceGroup": "string",
1266 "azureRegion": "string"
1267 }
1268 }
1269 ```
1270
1271 **Response:**
1272 ```json
1273 {
1274 "id": "string",
1275 "name": "string",
1276 "type": "http",
1277 "status": "active",
1278 "sink": {
1279 "azureSubscriptionId": "string",
1280 "azureResourceGroup": "string",
1281 "azureRegion": "string",
1282 "azurePartnerTopic": "string"
1283 }
1284 }
1285 ```
1286
1287 **Datadog Stream**
1288
1289 For a `Datadog` Stream, the `sink` properties are listed in the payload below.
1290
1291 **Request:**
1292 ```json
1293 {
1294 "name": "string",
1295 "type": "datadog",
1296 "sink": {
1297 "datadogRegion": "string",
1298 "datadogApiKey": "string"
1299 }
1300 }
1301 ```
1302
1303 **Response:**
1304 ```json
1305 {
1306 "id": "string",
1307 "name": "string",
1308 "type": "datadog",
1309 "status": "active",
1310 "sink": {
1311 "datadogRegion": "string",
1312 "datadogApiKey": "string"
1313 }
1314 }
1315 ```
1316
1317 **Splunk Stream**
1318
1319 For a `Splunk` Stream, the `sink` properties are listed in the payload below.
1320
1321 **Request:**
1322 ```json
1323 {
1324 "name": "string",
1325 "type": "splunk",
1326 "sink": {
1327 "splunkDomain": "string",
1328 "splunkToken": "string",
1329 "splunkPort": "string",
1330 "splunkSecure": "boolean"
1331 }
1332 }
1333 ```
1334
1335 **Response:**
1336 ```json
1337 {
1338 "id": "string",
1339 "name": "string",
1340 "type": "splunk",
1341 "status": "active",
1342 "sink": {
1343 "splunkDomain": "string",
1344 "splunkToken": "string",
1345 "splunkPort": "string",
1346 "splunkSecure": "boolean"
1347 }
1348 }
1349 ```
1350
1351 **Sumo Logic Stream**
1352
1353 For a `Sumo Logic` Stream, the `sink` properties are listed in the payload below.
1354
1355 **Request:**
1356 ```json
1357 {
1358 "name": "string",
1359 "type": "sumo",
1360 "sink": {
1361 "sumoSourceAddress": "string"
1362 }
1363 }
1364 ```
1365
1366 **Response:**
1367 ```json
1368 {
1369 "id": "string",
1370 "name": "string",
1371 "type": "sumo",
1372 "status": "active",
1373 "sink": {
1374 "sumoSourceAddress": "string"
1375 }
1376 }
1377 ```
1378
1379 Parameters
1380 ----------
1381 request : CreateLogStreamRequestContent
1382
1383 request_options : typing.Optional[RequestOptions]
1384 Request-specific configuration.
1385
1386 Returns
1387 -------
1388 AsyncHttpResponse[CreateLogStreamResponseContent]
1389 Log stream created
1390 """
1391 _response = await self._client_wrapper.httpx_client.request(
1392 "log-streams",
1393 method="POST",
1394 json=convert_and_respect_annotation_metadata(
1395 object_=request, annotation=CreateLogStreamRequestContent, direction="write"
1396 ),
1397 request_options=request_options,
1398 omit=OMIT,
1399 )
1400 try:
1401 if 200 <= _response.status_code < 300:
1402 _data = typing.cast(
1403 CreateLogStreamResponseContent,
1404 parse_obj_as(
1405 type_=CreateLogStreamResponseContent, # type: ignore
1406 object_=_response.json(),
1407 ),
1408 )
1409 return AsyncHttpResponse(response=_response, data=_data)
1410 if _response.status_code == 400:
1411 raise BadRequestError(
1412 headers=dict(_response.headers),
1413 body=typing.cast(
1414 typing.Any,
1415 parse_obj_as(
1416 type_=typing.Any, # type: ignore
1417 object_=_response.json(),
1418 ),
1419 ),
1420 )
1421 if _response.status_code == 401:
1422 raise UnauthorizedError(
1423 headers=dict(_response.headers),
1424 body=typing.cast(
1425 typing.Any,
1426 parse_obj_as(
1427 type_=typing.Any, # type: ignore
1428 object_=_response.json(),
1429 ),
1430 ),
1431 )
1432 if _response.status_code == 403:
1433 raise ForbiddenError(
1434 headers=dict(_response.headers),
1435 body=typing.cast(
1436 typing.Any,
1437 parse_obj_as(
1438 type_=typing.Any, # type: ignore
1439 object_=_response.json(),
1440 ),
1441 ),
1442 )
1443 if _response.status_code == 409:
1444 raise ConflictError(
1445 headers=dict(_response.headers),
1446 body=typing.cast(
1447 typing.Any,
1448 parse_obj_as(
1449 type_=typing.Any, # type: ignore
1450 object_=_response.json(),
1451 ),
1452 ),
1453 )
1454 if _response.status_code == 429:
1455 raise TooManyRequestsError(
1456 headers=dict(_response.headers),
1457 body=typing.cast(
1458 typing.Any,
1459 parse_obj_as(
1460 type_=typing.Any, # type: ignore
1461 object_=_response.json(),
1462 ),
1463 ),
1464 )
1465 _response_json = _response.json()
1466 except JSONDecodeError:
1467 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1468 except ValidationError as e:
1469 raise ParsingError(
1470 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1471 )
1472 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1473
1474 async def get(
1475 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1476 ) -> AsyncHttpResponse[GetLogStreamResponseContent]:
1477 """
1478 Retrieve a log stream configuration and status.
1479
1480 **Sample responses**
1481
1482 **Amazon EventBridge Log Stream**
1483
1484 ```json
1485 {
1486 "id": "string",
1487 "name": "string",
1488 "type": "eventbridge",
1489 "status": "active|paused|suspended",
1490 "sink": {
1491 "awsAccountId": "string",
1492 "awsRegion": "string",
1493 "awsPartnerEventSource": "string"
1494 }
1495 }
1496 ```
1497
1498 **HTTP Log Stream**
1499
1500 ```json
1501 {
1502 "id": "string",
1503 "name": "string",
1504 "type": "http",
1505 "status": "active|paused|suspended",
1506 "sink": {
1507 "httpContentFormat": "JSONLINES|JSONARRAY",
1508 "httpContentType": "string",
1509 "httpEndpoint": "string",
1510 "httpAuthorization": "string"
1511 }
1512 }
1513 ```
1514
1515 **Datadog Log Stream**
1516
1517 ```json
1518 {
1519 "id": "string",
1520 "name": "string",
1521 "type": "datadog",
1522 "status": "active|paused|suspended",
1523 "sink": {
1524 "datadogRegion": "string",
1525 "datadogApiKey": "string"
1526 }
1527 }
1528 ```
1529
1530 **Mixpanel**
1531
1532 **Request:**
1533
1534 ```json
1535 {
1536 "name": "string",
1537 "type": "mixpanel",
1538 "sink": {
1539 "mixpanelRegion": "string",
1540 "mixpanelProjectId": "string",
1541 "mixpanelServiceAccountUsername": "string",
1542 "mixpanelServiceAccountPassword": "string"
1543 }
1544 }
1545 ```
1546
1547 **Response:**
1548
1549 ```json
1550 {
1551 "id": "string",
1552 "name": "string",
1553 "type": "mixpanel",
1554 "status": "active",
1555 "sink": {
1556 "mixpanelRegion": "string",
1557 "mixpanelProjectId": "string",
1558 "mixpanelServiceAccountUsername": "string",
1559 "mixpanelServiceAccountPassword": "string"
1560 }
1561 }
1562 ```
1563
1564 **Segment**
1565
1566 **Request:**
1567
1568 ```json
1569 {
1570 "name": "string",
1571 "type": "segment",
1572 "sink": {
1573 "segmentWriteKey": "string"
1574 }
1575 }
1576 ```
1577
1578 **Response:**
1579
1580 ```json
1581 {
1582 "id": "string",
1583 "name": "string",
1584 "type": "segment",
1585 "status": "active",
1586 "sink": {
1587 "segmentWriteKey": "string"
1588 }
1589 }
1590 ```
1591
1592 **Splunk Log Stream**
1593
1594 ```json
1595 {
1596 "id": "string",
1597 "name": "string",
1598 "type": "splunk",
1599 "status": "active|paused|suspended",
1600 "sink": {
1601 "splunkDomain": "string",
1602 "splunkToken": "string",
1603 "splunkPort": "string",
1604 "splunkSecure": "boolean"
1605 }
1606 }
1607 ```
1608
1609 **Sumo Logic Log Stream**
1610
1611 ```json
1612 {
1613 "id": "string",
1614 "name": "string",
1615 "type": "sumo",
1616 "status": "active|paused|suspended",
1617 "sink": {
1618 "sumoSourceAddress": "string"
1619 }
1620 }
1621 ```
1622
1623 **Status**
1624
1625 The `status` of a log stream maybe any of the following:
1626
1627 1. `active` - Stream is currently enabled.
1628 2. `paused` - Stream is currently user disabled and will not attempt log delivery.
1629 3. `suspended` - Stream is currently disabled because of errors and will not attempt log delivery.
1630
1631 Parameters
1632 ----------
1633 id : str
1634 The id of the log stream to get
1635
1636 request_options : typing.Optional[RequestOptions]
1637 Request-specific configuration.
1638
1639 Returns
1640 -------
1641 AsyncHttpResponse[GetLogStreamResponseContent]
1642 Returning log stream.
1643 """
1644 _response = await self._client_wrapper.httpx_client.request(
1645 f"log-streams/{encode_path_param(id)}",
1646 method="GET",
1647 request_options=request_options,
1648 )
1649 try:
1650 if 200 <= _response.status_code < 300:
1651 _data = typing.cast(
1652 GetLogStreamResponseContent,
1653 parse_obj_as(
1654 type_=GetLogStreamResponseContent, # type: ignore
1655 object_=_response.json(),
1656 ),
1657 )
1658 return AsyncHttpResponse(response=_response, data=_data)
1659 if _response.status_code == 401:
1660 raise UnauthorizedError(
1661 headers=dict(_response.headers),
1662 body=typing.cast(
1663 typing.Any,
1664 parse_obj_as(
1665 type_=typing.Any, # type: ignore
1666 object_=_response.json(),
1667 ),
1668 ),
1669 )
1670 if _response.status_code == 403:
1671 raise ForbiddenError(
1672 headers=dict(_response.headers),
1673 body=typing.cast(
1674 typing.Any,
1675 parse_obj_as(
1676 type_=typing.Any, # type: ignore
1677 object_=_response.json(),
1678 ),
1679 ),
1680 )
1681 if _response.status_code == 404:
1682 raise NotFoundError(
1683 headers=dict(_response.headers),
1684 body=typing.cast(
1685 typing.Any,
1686 parse_obj_as(
1687 type_=typing.Any, # type: ignore
1688 object_=_response.json(),
1689 ),
1690 ),
1691 )
1692 if _response.status_code == 429:
1693 raise TooManyRequestsError(
1694 headers=dict(_response.headers),
1695 body=typing.cast(
1696 typing.Any,
1697 parse_obj_as(
1698 type_=typing.Any, # type: ignore
1699 object_=_response.json(),
1700 ),
1701 ),
1702 )
1703 _response_json = _response.json()
1704 except JSONDecodeError:
1705 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1706 except ValidationError as e:
1707 raise ParsingError(
1708 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1709 )
1710 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1711
1712 async def delete(
1713 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1714 ) -> AsyncHttpResponse[None]:
1715 """
1716 Delete a log stream.
1717
1718 Parameters
1719 ----------
1720 id : str
1721 The id of the log stream to delete
1722
1723 request_options : typing.Optional[RequestOptions]
1724 Request-specific configuration.
1725
1726 Returns
1727 -------
1728 AsyncHttpResponse[None]
1729 """
1730 _response = await self._client_wrapper.httpx_client.request(
1731 f"log-streams/{encode_path_param(id)}",
1732 method="DELETE",
1733 request_options=request_options,
1734 )
1735 try:
1736 if 200 <= _response.status_code < 300:
1737 return AsyncHttpResponse(response=_response, data=None)
1738 if _response.status_code == 400:
1739 raise BadRequestError(
1740 headers=dict(_response.headers),
1741 body=typing.cast(
1742 typing.Any,
1743 parse_obj_as(
1744 type_=typing.Any, # type: ignore
1745 object_=_response.json(),
1746 ),
1747 ),
1748 )
1749 if _response.status_code == 401:
1750 raise UnauthorizedError(
1751 headers=dict(_response.headers),
1752 body=typing.cast(
1753 typing.Any,
1754 parse_obj_as(
1755 type_=typing.Any, # type: ignore
1756 object_=_response.json(),
1757 ),
1758 ),
1759 )
1760 if _response.status_code == 403:
1761 raise ForbiddenError(
1762 headers=dict(_response.headers),
1763 body=typing.cast(
1764 typing.Any,
1765 parse_obj_as(
1766 type_=typing.Any, # type: ignore
1767 object_=_response.json(),
1768 ),
1769 ),
1770 )
1771 if _response.status_code == 404:
1772 raise NotFoundError(
1773 headers=dict(_response.headers),
1774 body=typing.cast(
1775 typing.Any,
1776 parse_obj_as(
1777 type_=typing.Any, # type: ignore
1778 object_=_response.json(),
1779 ),
1780 ),
1781 )
1782 if _response.status_code == 429:
1783 raise TooManyRequestsError(
1784 headers=dict(_response.headers),
1785 body=typing.cast(
1786 typing.Any,
1787 parse_obj_as(
1788 type_=typing.Any, # type: ignore
1789 object_=_response.json(),
1790 ),
1791 ),
1792 )
1793 _response_json = _response.json()
1794 except JSONDecodeError:
1795 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1796 except ValidationError as e:
1797 raise ParsingError(
1798 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1799 )
1800 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1801
1802 async def update(
1803 self,
1804 id: str,
1805 *,
1806 name: typing.Optional[str] = OMIT,
1807 status: typing.Optional[LogStreamStatusEnum] = OMIT,
1808 is_priority: typing.Optional[bool] = OMIT,
1809 filters: typing.Optional[typing.Sequence[LogStreamFilter]] = OMIT,
1810 pii_config: typing.Optional[LogStreamPiiConfig] = OMIT,
1811 sink: typing.Optional[LogStreamSinkPatch] = OMIT,
1812 request_options: typing.Optional[RequestOptions] = None,
1813 ) -> AsyncHttpResponse[UpdateLogStreamResponseContent]:
1814 """
1815 Update a log stream.
1816
1817 **Examples of how to use the PATCH endpoint.**
1818
1819 The following fields may be updated in a PATCH operation:
1820
1821 - name
1822 - status
1823 - sink
1824
1825 Note: For log streams of type `eventbridge` and `eventgrid`, updating the `sink` is not permitted.
1826
1827 **Update the status of a log stream**
1828
1829 ```json
1830 {
1831 "status": "active|paused"
1832 }
1833 ```
1834
1835 **Update the name of a log stream**
1836
1837 ```json
1838 {
1839 "name": "string"
1840 }
1841 ```
1842
1843 **Update the sink properties of a stream of type `http`**
1844
1845 ```json
1846 {
1847 "sink": {
1848 "httpEndpoint": "string",
1849 "httpContentType": "string",
1850 "httpContentFormat": "JSONARRAY|JSONLINES",
1851 "httpAuthorization": "string"
1852 }
1853 }
1854 ```
1855
1856 **Update the sink properties of a stream of type `datadog`**
1857
1858 ```json
1859 {
1860 "sink": {
1861 "datadogRegion": "string",
1862 "datadogApiKey": "string"
1863 }
1864 }
1865 ```
1866
1867 **Update the sink properties of a stream of type `splunk`**
1868
1869 ```json
1870 {
1871 "sink": {
1872 "splunkDomain": "string",
1873 "splunkToken": "string",
1874 "splunkPort": "string",
1875 "splunkSecure": "boolean"
1876 }
1877 }
1878 ```
1879
1880 **Update the sink properties of a stream of type `sumo`**
1881
1882 ```json
1883 {
1884 "sink": {
1885 "sumoSourceAddress": "string"
1886 }
1887 }
1888 ```
1889
1890 Parameters
1891 ----------
1892 id : str
1893 The id of the log stream to get
1894
1895 name : typing.Optional[str]
1896 log stream name
1897
1898 status : typing.Optional[LogStreamStatusEnum]
1899
1900 is_priority : typing.Optional[bool]
1901 True for priority log streams, false for non-priority
1902
1903 filters : typing.Optional[typing.Sequence[LogStreamFilter]]
1904 Only logs events matching these filters will be delivered by the stream. If omitted or empty, all events will be delivered.
1905
1906 pii_config : typing.Optional[LogStreamPiiConfig]
1907
1908 sink : typing.Optional[LogStreamSinkPatch]
1909
1910 request_options : typing.Optional[RequestOptions]
1911 Request-specific configuration.
1912
1913 Returns
1914 -------
1915 AsyncHttpResponse[UpdateLogStreamResponseContent]
1916 Log stream updated
1917 """
1918 _response = await self._client_wrapper.httpx_client.request(
1919 f"log-streams/{encode_path_param(id)}",
1920 method="PATCH",
1921 json={
1922 "name": name,
1923 "status": status,
1924 "isPriority": is_priority,
1925 "filters": convert_and_respect_annotation_metadata(
1926 object_=filters, annotation=typing.Sequence[LogStreamFilter], direction="write"
1927 ),
1928 "pii_config": convert_and_respect_annotation_metadata(
1929 object_=pii_config, annotation=LogStreamPiiConfig, direction="write"
1930 ),
1931 "sink": convert_and_respect_annotation_metadata(
1932 object_=sink, annotation=LogStreamSinkPatch, direction="write"
1933 ),
1934 },
1935 headers={
1936 "content-type": "application/json",
1937 },
1938 request_options=request_options,
1939 omit=OMIT,
1940 )
1941 try:
1942 if 200 <= _response.status_code < 300:
1943 _data = typing.cast(
1944 UpdateLogStreamResponseContent,
1945 parse_obj_as(
1946 type_=UpdateLogStreamResponseContent, # type: ignore
1947 object_=_response.json(),
1948 ),
1949 )
1950 return AsyncHttpResponse(response=_response, data=_data)
1951 if _response.status_code == 400:
1952 raise BadRequestError(
1953 headers=dict(_response.headers),
1954 body=typing.cast(
1955 typing.Any,
1956 parse_obj_as(
1957 type_=typing.Any, # type: ignore
1958 object_=_response.json(),
1959 ),
1960 ),
1961 )
1962 if _response.status_code == 401:
1963 raise UnauthorizedError(
1964 headers=dict(_response.headers),
1965 body=typing.cast(
1966 typing.Any,
1967 parse_obj_as(
1968 type_=typing.Any, # type: ignore
1969 object_=_response.json(),
1970 ),
1971 ),
1972 )
1973 if _response.status_code == 403:
1974 raise ForbiddenError(
1975 headers=dict(_response.headers),
1976 body=typing.cast(
1977 typing.Any,
1978 parse_obj_as(
1979 type_=typing.Any, # type: ignore
1980 object_=_response.json(),
1981 ),
1982 ),
1983 )
1984 if _response.status_code == 429:
1985 raise TooManyRequestsError(
1986 headers=dict(_response.headers),
1987 body=typing.cast(
1988 typing.Any,
1989 parse_obj_as(
1990 type_=typing.Any, # type: ignore
1991 object_=_response.json(),
1992 ),
1993 ),
1994 )
1995 _response_json = _response.json()
1996 except JSONDecodeError:
1997 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1998 except ValidationError as e:
1999 raise ParsingError(
2000 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
2001 )
2002 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)