44
55from typing import Union
66from datetime import datetime
7+ from typing_extensions import Literal
78
89import httpx
910
10- from ..types import audit_log_list_params
11+ from ..types import audit_log_list_params , audit_log_export_chunk_params
1112from .._types import Body , Omit , Query , Headers , NotGiven , SequenceNotStr , omit , not_given
12- from .._utils import maybe_transform
13+ from .._utils import maybe_transform , async_maybe_transform
1314from .._compat import cached_property
1415from .._resource import SyncAPIResource , AsyncAPIResource
1516from .._response import (
17+ BinaryAPIResponse ,
18+ AsyncBinaryAPIResponse ,
19+ StreamedBinaryAPIResponse ,
20+ AsyncStreamedBinaryAPIResponse ,
1621 to_raw_response_wrapper ,
1722 to_streamed_response_wrapper ,
1823 async_to_raw_response_wrapper ,
24+ to_custom_raw_response_wrapper ,
1925 async_to_streamed_response_wrapper ,
26+ to_custom_streamed_response_wrapper ,
27+ async_to_custom_raw_response_wrapper ,
28+ async_to_custom_streamed_response_wrapper ,
2029)
2130from ..pagination import SyncPageTokenPagination , AsyncPageTokenPagination
2231from .._base_client import AsyncPaginator , make_request_options
@@ -128,6 +137,91 @@ def list(
128137 model = AuditLogEntry ,
129138 )
130139
140+ def export_chunk (
141+ self ,
142+ * ,
143+ end : Union [str , datetime ],
144+ start : Union [str , datetime ],
145+ auth_strategy : str | Omit = omit ,
146+ cursor : str | Omit = omit ,
147+ exclude_method : str | Omit = omit ,
148+ format : Literal ["jsonl" , "jsonl.gz" ] | Omit = omit ,
149+ limit : int | Omit = omit ,
150+ method : str | Omit = omit ,
151+ search : str | Omit = omit ,
152+ search_user_id : SequenceNotStr [str ] | Omit = omit ,
153+ service : str | Omit = omit ,
154+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
155+ # The extra values given here take precedence over values defined on the client or passed to this method.
156+ extra_headers : Headers | None = None ,
157+ extra_query : Query | None = None ,
158+ extra_body : Body | None = None ,
159+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
160+ ) -> BinaryAPIResponse :
161+ """
162+ Download an organization's audit log records for a time range as a file, for
163+ archival, compliance, or offline analysis. For interactive browsing, use GET
164+ /audit-logs.
165+
166+ Args:
167+ end: Upper bound (exclusive) for the audit record timestamp.
168+
169+ start: Lower bound (inclusive) for the audit record timestamp.
170+
171+ auth_strategy: Filter by authentication strategy.
172+
173+ cursor: Opaque cursor from X-Next-Cursor for the next chunk of older records.
174+
175+ exclude_method: Filter out results by HTTP method.
176+
177+ format: Encoding for the returned chunk.
178+
179+ limit: Maximum number of records to return in this chunk.
180+
181+ method: Filter by HTTP method.
182+
183+ search: Free-text search over path, user ID, email, client IP, and status.
184+
185+ search_user_id: Additional user IDs to OR into free-text search.
186+
187+ service: Filter by service name.
188+
189+ extra_headers: Send extra headers
190+
191+ extra_query: Add additional query parameters to the request
192+
193+ extra_body: Add additional JSON properties to the request
194+
195+ timeout: Override the client-level default timeout for this request, in seconds
196+ """
197+ extra_headers = {"Accept" : "application/octet-stream" , ** (extra_headers or {})}
198+ return self ._get (
199+ "/audit-logs/export/chunk" ,
200+ options = make_request_options (
201+ extra_headers = extra_headers ,
202+ extra_query = extra_query ,
203+ extra_body = extra_body ,
204+ timeout = timeout ,
205+ query = maybe_transform (
206+ {
207+ "end" : end ,
208+ "start" : start ,
209+ "auth_strategy" : auth_strategy ,
210+ "cursor" : cursor ,
211+ "exclude_method" : exclude_method ,
212+ "format" : format ,
213+ "limit" : limit ,
214+ "method" : method ,
215+ "search" : search ,
216+ "search_user_id" : search_user_id ,
217+ "service" : service ,
218+ },
219+ audit_log_export_chunk_params .AuditLogExportChunkParams ,
220+ ),
221+ ),
222+ cast_to = BinaryAPIResponse ,
223+ )
224+
131225
132226class AsyncAuditLogsResource (AsyncAPIResource ):
133227 """Read audit log records for the authenticated organization."""
@@ -232,6 +326,91 @@ def list(
232326 model = AuditLogEntry ,
233327 )
234328
329+ async def export_chunk (
330+ self ,
331+ * ,
332+ end : Union [str , datetime ],
333+ start : Union [str , datetime ],
334+ auth_strategy : str | Omit = omit ,
335+ cursor : str | Omit = omit ,
336+ exclude_method : str | Omit = omit ,
337+ format : Literal ["jsonl" , "jsonl.gz" ] | Omit = omit ,
338+ limit : int | Omit = omit ,
339+ method : str | Omit = omit ,
340+ search : str | Omit = omit ,
341+ search_user_id : SequenceNotStr [str ] | Omit = omit ,
342+ service : str | Omit = omit ,
343+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
344+ # The extra values given here take precedence over values defined on the client or passed to this method.
345+ extra_headers : Headers | None = None ,
346+ extra_query : Query | None = None ,
347+ extra_body : Body | None = None ,
348+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
349+ ) -> AsyncBinaryAPIResponse :
350+ """
351+ Download an organization's audit log records for a time range as a file, for
352+ archival, compliance, or offline analysis. For interactive browsing, use GET
353+ /audit-logs.
354+
355+ Args:
356+ end: Upper bound (exclusive) for the audit record timestamp.
357+
358+ start: Lower bound (inclusive) for the audit record timestamp.
359+
360+ auth_strategy: Filter by authentication strategy.
361+
362+ cursor: Opaque cursor from X-Next-Cursor for the next chunk of older records.
363+
364+ exclude_method: Filter out results by HTTP method.
365+
366+ format: Encoding for the returned chunk.
367+
368+ limit: Maximum number of records to return in this chunk.
369+
370+ method: Filter by HTTP method.
371+
372+ search: Free-text search over path, user ID, email, client IP, and status.
373+
374+ search_user_id: Additional user IDs to OR into free-text search.
375+
376+ service: Filter by service name.
377+
378+ extra_headers: Send extra headers
379+
380+ extra_query: Add additional query parameters to the request
381+
382+ extra_body: Add additional JSON properties to the request
383+
384+ timeout: Override the client-level default timeout for this request, in seconds
385+ """
386+ extra_headers = {"Accept" : "application/octet-stream" , ** (extra_headers or {})}
387+ return await self ._get (
388+ "/audit-logs/export/chunk" ,
389+ options = make_request_options (
390+ extra_headers = extra_headers ,
391+ extra_query = extra_query ,
392+ extra_body = extra_body ,
393+ timeout = timeout ,
394+ query = await async_maybe_transform (
395+ {
396+ "end" : end ,
397+ "start" : start ,
398+ "auth_strategy" : auth_strategy ,
399+ "cursor" : cursor ,
400+ "exclude_method" : exclude_method ,
401+ "format" : format ,
402+ "limit" : limit ,
403+ "method" : method ,
404+ "search" : search ,
405+ "search_user_id" : search_user_id ,
406+ "service" : service ,
407+ },
408+ audit_log_export_chunk_params .AuditLogExportChunkParams ,
409+ ),
410+ ),
411+ cast_to = AsyncBinaryAPIResponse ,
412+ )
413+
235414
236415class AuditLogsResourceWithRawResponse :
237416 def __init__ (self , audit_logs : AuditLogsResource ) -> None :
@@ -240,6 +419,10 @@ def __init__(self, audit_logs: AuditLogsResource) -> None:
240419 self .list = to_raw_response_wrapper (
241420 audit_logs .list ,
242421 )
422+ self .export_chunk = to_custom_raw_response_wrapper (
423+ audit_logs .export_chunk ,
424+ BinaryAPIResponse ,
425+ )
243426
244427
245428class AsyncAuditLogsResourceWithRawResponse :
@@ -249,6 +432,10 @@ def __init__(self, audit_logs: AsyncAuditLogsResource) -> None:
249432 self .list = async_to_raw_response_wrapper (
250433 audit_logs .list ,
251434 )
435+ self .export_chunk = async_to_custom_raw_response_wrapper (
436+ audit_logs .export_chunk ,
437+ AsyncBinaryAPIResponse ,
438+ )
252439
253440
254441class AuditLogsResourceWithStreamingResponse :
@@ -258,6 +445,10 @@ def __init__(self, audit_logs: AuditLogsResource) -> None:
258445 self .list = to_streamed_response_wrapper (
259446 audit_logs .list ,
260447 )
448+ self .export_chunk = to_custom_streamed_response_wrapper (
449+ audit_logs .export_chunk ,
450+ StreamedBinaryAPIResponse ,
451+ )
261452
262453
263454class AsyncAuditLogsResourceWithStreamingResponse :
@@ -267,3 +458,7 @@ def __init__(self, audit_logs: AsyncAuditLogsResource) -> None:
267458 self .list = async_to_streamed_response_wrapper (
268459 audit_logs .list ,
269460 )
461+ self .export_chunk = async_to_custom_streamed_response_wrapper (
462+ audit_logs .export_chunk ,
463+ AsyncStreamedBinaryAPIResponse ,
464+ )
0 commit comments