Skip to content

Commit 14db0ea

Browse files
feat: Add hidden audit-logs export endpoint
1 parent 567e806 commit 14db0ea

6 files changed

Lines changed: 99 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 124
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-4c243ff089133bd49322d98a6943647589972f71ecadc993fe9e5029972b3995.yml
3-
openapi_spec_hash: a2cb637a19a070d07a1a4343c75444ee
4-
config_hash: fb167e754ebb3a14649463725891c9d0
1+
configured_endpoints: 125
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-55409ab573762d8bc010fb34c885651ca858a97d4353b4776b7aafeaaa313257.yml
3+
openapi_spec_hash: 0cf678d80f2a2b73fb9ec82d05c8cc0a
4+
config_hash: 06186eb40e0058a2a87ac251fc07415d

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ Types:
404404
Methods:
405405

406406
- <code title="get /audit-logs">client.auditLogs.<a href="./src/resources/audit-logs.ts">list</a>({ ...params }) -> AuditLogEntriesPageTokenPagination</code>
407+
- <code title="get /audit-logs/export/chunk">client.auditLogs.<a href="./src/resources/audit-logs.ts">exportChunk</a>({ ...params }) -> Response</code>
407408

408409
# APIKeys
409410

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
import {
4646
AuditLogEntriesPageTokenPagination,
4747
AuditLogEntry,
48+
AuditLogExportChunkParams,
4849
AuditLogListParams,
4950
AuditLogs,
5051
} from './resources/audit-logs';
@@ -1192,6 +1193,7 @@ export declare namespace Kernel {
11921193
type AuditLogEntry as AuditLogEntry,
11931194
type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination,
11941195
type AuditLogListParams as AuditLogListParams,
1196+
type AuditLogExportChunkParams as AuditLogExportChunkParams,
11951197
};
11961198

11971199
export {

src/resources/audit-logs.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../core/resource';
4+
import { APIPromise } from '../core/api-promise';
45
import { PagePromise, PageTokenPagination, type PageTokenPaginationParams } from '../core/pagination';
6+
import { buildHeaders } from '../internal/headers';
57
import { RequestOptions } from '../internal/request-options';
68

79
/**
@@ -18,6 +20,20 @@ export class AuditLogs extends APIResource {
1820
): PagePromise<AuditLogEntriesPageTokenPagination, AuditLogEntry> {
1921
return this._client.getAPIList('/audit-logs', PageTokenPagination<AuditLogEntry>, { query, ...options });
2022
}
23+
24+
/**
25+
* Download an organization's audit log records for a time range as a file, for
26+
* archival, compliance, or offline analysis. For interactive browsing, use GET
27+
* /audit-logs.
28+
*/
29+
exportChunk(query: AuditLogExportChunkParams, options?: RequestOptions): APIPromise<Response> {
30+
return this._client.get('/audit-logs/export/chunk', {
31+
query,
32+
...options,
33+
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
34+
__binaryResponse: true,
35+
});
36+
}
2137
}
2238

2339
export type AuditLogEntriesPageTokenPagination = PageTokenPagination<AuditLogEntry>;
@@ -126,10 +142,68 @@ export interface AuditLogListParams extends PageTokenPaginationParams {
126142
service?: string;
127143
}
128144

145+
export interface AuditLogExportChunkParams {
146+
/**
147+
* Upper bound (exclusive) for the audit record timestamp.
148+
*/
149+
end: string;
150+
151+
/**
152+
* Lower bound (inclusive) for the audit record timestamp.
153+
*/
154+
start: string;
155+
156+
/**
157+
* Filter by authentication strategy.
158+
*/
159+
auth_strategy?: string;
160+
161+
/**
162+
* Opaque cursor from X-Next-Cursor for the next chunk of older records.
163+
*/
164+
cursor?: string;
165+
166+
/**
167+
* Filter out results by HTTP method.
168+
*/
169+
exclude_method?: string;
170+
171+
/**
172+
* Encoding for the returned chunk.
173+
*/
174+
format?: 'jsonl' | 'jsonl.gz';
175+
176+
/**
177+
* Maximum number of records to return in this chunk.
178+
*/
179+
limit?: number;
180+
181+
/**
182+
* Filter by HTTP method.
183+
*/
184+
method?: string;
185+
186+
/**
187+
* Free-text search over path, user ID, email, client IP, and status.
188+
*/
189+
search?: string;
190+
191+
/**
192+
* Additional user IDs to OR into free-text search.
193+
*/
194+
search_user_id?: Array<string>;
195+
196+
/**
197+
* Filter by service name.
198+
*/
199+
service?: string;
200+
}
201+
129202
export declare namespace AuditLogs {
130203
export {
131204
type AuditLogEntry as AuditLogEntry,
132205
type AuditLogEntriesPageTokenPagination as AuditLogEntriesPageTokenPagination,
133206
type AuditLogListParams as AuditLogListParams,
207+
type AuditLogExportChunkParams as AuditLogExportChunkParams,
134208
};
135209
}

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export {
2222
AuditLogs,
2323
type AuditLogEntry,
2424
type AuditLogListParams,
25+
type AuditLogExportChunkParams,
2526
type AuditLogEntriesPageTokenPagination,
2627
} from './audit-logs';
2728
export { Auth } from './auth/auth';

tests/api-resources/audit-logs.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,21 @@ describe('resource auditLogs', () => {
3838
service: 'service',
3939
});
4040
});
41+
42+
// Mock server tests are disabled
43+
test.skip('exportChunk: required and optional params', async () => {
44+
const response = await client.auditLogs.exportChunk({
45+
end: '2026-01-02T00:00:00Z',
46+
start: '2026-01-01T00:00:00Z',
47+
auth_strategy: 'auth_strategy',
48+
cursor: 'cursor',
49+
exclude_method: 'exclude_method',
50+
format: 'jsonl',
51+
limit: 1,
52+
method: 'method',
53+
search: 'search',
54+
search_user_id: ['string'],
55+
service: 'service',
56+
});
57+
});
4158
});

0 commit comments

Comments
 (0)