+15
-8
@@ -182,17 +182,24 @@ export function deleteUserApiKeys(
|
||||
|
||||
// ---- 审计日志 ----
|
||||
/** 批式懒加载查询审计事件:cursor 空自当前时刻首查,
|
||||
* 非空从上次响应游标向更早续取一批(~100 条,服务端分窗回溯) */
|
||||
* 非空从上次响应游标向更早续取一批(~200 条,服务端分窗回溯);
|
||||
* q 为服务端全文检索关键字,仅首查生效(续查沿用游标内嵌关键字) */
|
||||
export function listAuditEvents(
|
||||
id: number,
|
||||
opts: { region?: string; cursor?: string; limit?: number } = {},
|
||||
opts: { region?: string; cursor?: string; limit?: number; q?: string } = {},
|
||||
): Promise<AuditEventsResult> {
|
||||
// mock:首批带游标,续查一批后到尽头,演示懒加载链路
|
||||
if (mockOn)
|
||||
return mocked(
|
||||
{ items: mockAuditEvents, cursor: opts.cursor ? undefined : 'mock-cursor', exhausted: !!opts.cursor },
|
||||
300,
|
||||
)
|
||||
// mock:首批带游标,续查一批后到尽头,演示懒加载链路;q 演示不区分大小写的包含匹配
|
||||
if (mockOn) {
|
||||
const kw = (opts.q ?? '').replace(/\*/g, '').toLowerCase()
|
||||
const items = kw
|
||||
? mockAuditEvents.filter((e) =>
|
||||
[e.eventName, e.resourceName, e.principalName, e.ipAddress, e.source].some((v) =>
|
||||
(v ?? '').toLowerCase().includes(kw),
|
||||
),
|
||||
)
|
||||
: mockAuditEvents
|
||||
return mocked({ items, cursor: opts.cursor ? undefined : 'mock-cursor', exhausted: !!opts.cursor }, 300)
|
||||
}
|
||||
return request(`/oci-configs/${id}/audit-events`, { query: { ...opts } })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user