Repository navigation
Expand file tree
/
Copy pathexport-destinations.ts
More file actions
262 lines (202 loc) · 7.74 KB
/
Copy pathexport-destinations.ts
File metadata and controls
262 lines (202 loc) · 7.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../core/pagination';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
/**
* Read audit log records for the authenticated organization.
*/
export class ExportDestinations extends APIResource {
/**
* Create a paused destination. Activate it with a status update once the
* destination test passes. Requires an active Enterprise plan.
*/
create(
body: ExportDestinationCreateParams,
options?: RequestOptions,
): APIPromise<AuditLogExportDestination> {
return this._client.post('/audit-logs/export/destinations', { body, ...options });
}
/**
* Retrieve details for a single audit log export destination by its ID.
*/
retrieve(id: string, options?: RequestOptions): APIPromise<AuditLogExportDestination> {
return this._client.get(path`/audit-logs/export/destinations/${id}`, options);
}
/**
* Apply a partial update to a destination. Requires an active Enterprise plan.
* Returns 409 when the destination was changed concurrently, because the merged
* configuration this request validated is no longer the one that would be stored;
* retry against fresh state. Pausing prevents new delivery attempts, but an S3
* upload already in progress may complete after the response.
*/
update(
id: string,
body: ExportDestinationUpdateParams,
options?: RequestOptions,
): APIPromise<AuditLogExportDestination> {
return this._client.patch(path`/audit-logs/export/destinations/${id}`, { body, ...options });
}
/**
* List audit log export destinations for the organization with pagination support.
*/
list(
query: ExportDestinationListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<AuditLogExportDestinationsOffsetPagination, AuditLogExportDestination> {
return this._client.getAPIList(
'/audit-logs/export/destinations',
OffsetPagination<AuditLogExportDestination>,
{ query, ...options },
);
}
/**
* Soft delete the destination and prevent new delivery attempts. An S3 upload
* already in progress may complete after the response.
*/
delete(id: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/audit-logs/export/destinations/${id}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Verify the destination is writable by assuming the configured role and uploading
* a temporary probe object with the same request metadata as a real delivery.
* Requires an active Enterprise plan.
*/
test(id: string, options?: RequestOptions): APIPromise<AuditLogExportDestinationTestResult> {
return this._client.post(path`/audit-logs/export/destinations/${id}/test`, options);
}
}
export type AuditLogExportDestinationsOffsetPagination = OffsetPagination<AuditLogExportDestination>;
/**
* An organization-scoped audit log export destination.
*
* Delivery is at-least-once for rows visible when their window is committed: a
* delivery that is retried rewrites the same object, and the same `event_id` can
* appear in more than one object, so consumers must deduplicate on `event_id`.
* Each event-time window is held for ten minutes before it commits; a row that
* becomes visible after its window is committed may not be delivered.
*
* Objects are written as
* `<prefix>/destination_id=<destination>/org_id=<org>/date=<YYYY-MM-DD>/hour=<HH>/<window>-<chunk>.jsonl.gz`,
* where `date` and `hour` are the UTC calendar hour that fully contains every row
* in the object, so the layout is safe to register as a Hive-partitioned table.
* The object name is derived from the rows it holds, so a retried delivery
* rewrites its own object.
*/
export interface AuditLogExportDestination {
id: string;
bucket: string;
consecutive_failures: number;
created_at: string;
external_id: string;
format: 'jsonl.gz';
/**
* The Kernel role that assumes `role_arn` in your account to deliver logs. Allow
* this role as the principal in your role's trust policy, and require
* `external_id` as the `sts:ExternalId` condition.
*
* Recreating a destination issues a new `external_id`, which the trust policy has
* to be updated to match.
*/
kernel_role_arn: string;
prefix: string;
region: string;
role_arn: string;
/**
* Pausing prevents new delivery attempts. An S3 upload already in progress may
* complete after the pause response; its rows can appear again after the
* destination is resumed.
*/
status: 'active' | 'paused';
type: 's3';
updated_at: string;
kms_key_id?: string;
/**
* Sanitized description of the most recent delivery failure.
*/
last_error?: string;
last_error_at?: string;
/**
* Opaque, versioned checkpoint for forward-only continuous export. This value is
* not compatible with audit-log list page tokens.
*
* Delivery starts at the moment the destination is activated, so events recorded
* before that are not delivered. Pausing stops delivery and resuming starts again
* from the time of the resume: events recorded while a destination was paused are
* never exported, and pausing is not a way to defer delivery.
*/
last_exported_cursor?: string;
last_success_at?: string;
next_attempt_at?: string;
}
export interface AuditLogExportDestinationTestResult {
stage: 'assume_role' | 'put_object' | 'complete';
success: boolean;
error?: AuditLogExportDestinationTestResult.Error;
}
export namespace AuditLogExportDestinationTestResult {
export interface Error {
code: 'assume_role_failed' | 'put_object_failed';
message: string;
}
}
export interface CreateAuditLogExportDestinationRequest {
bucket: string;
format: 'jsonl.gz';
prefix: string;
region: string;
role_arn: string;
type: 's3';
kms_key_id?: string;
}
export interface UpdateAuditLogExportDestinationRequest {
bucket?: string;
/**
* KMS key ID, alias, or ARN. Set to an empty string to remove the configured KMS
* key; omit or send null to leave unchanged.
*/
kms_key_id?: string;
prefix?: string;
region?: string;
role_arn?: string;
status?: 'active' | 'paused';
}
export interface ExportDestinationCreateParams {
bucket: string;
format: 'jsonl.gz';
prefix: string;
region: string;
role_arn: string;
type: 's3';
kms_key_id?: string;
}
export interface ExportDestinationUpdateParams {
bucket?: string;
/**
* KMS key ID, alias, or ARN. Set to an empty string to remove the configured KMS
* key; omit or send null to leave unchanged.
*/
kms_key_id?: string;
prefix?: string;
region?: string;
role_arn?: string;
status?: 'active' | 'paused';
}
export interface ExportDestinationListParams extends OffsetPaginationParams {}
export declare namespace ExportDestinations {
export {
type AuditLogExportDestination as AuditLogExportDestination,
type AuditLogExportDestinationTestResult as AuditLogExportDestinationTestResult,
type CreateAuditLogExportDestinationRequest as CreateAuditLogExportDestinationRequest,
type UpdateAuditLogExportDestinationRequest as UpdateAuditLogExportDestinationRequest,
type AuditLogExportDestinationsOffsetPagination as AuditLogExportDestinationsOffsetPagination,
type ExportDestinationCreateParams as ExportDestinationCreateParams,
type ExportDestinationUpdateParams as ExportDestinationUpdateParams,
type ExportDestinationListParams as ExportDestinationListParams,
};
}