taolib.testing.config_center.repository.audit_repo#

审计日志 Repository 模块。

提供审计日志文档的 MongoDB 操作实现。

Classes#

AuditLogRepository

审计日志 Repository 实现。

Module Contents#

class taolib.testing.config_center.repository.audit_repo.AuditLogRepository(collection: motor.motor_asyncio.AsyncIOMotorCollection)#

Bases: taolib.testing.config_center.repository.base.AsyncRepository[taolib.testing.config_center.models.audit.AuditLogDocument]

审计日志 Repository 实现。

async create_log(document: dict[str, Any]) taolib.testing.config_center.models.audit.AuditLogDocument#

创建审计日志。

参数:

document -- 日志文档数据

返回:

创建的审计日志实例

async query_logs(resource_type: str | None = None, resource_id: str | None = None, actor_id: str | None = None, action: str | None = None, time_from: datetime.datetime | None = None, time_to: datetime.datetime | None = None, skip: int = 0, limit: int = 100) list[taolib.testing.config_center.models.audit.AuditLogDocument]#

查询审计日志。

参数:
  • resource_type -- 资源类型过滤

  • resource_id -- 资源 ID 过滤

  • actor_id -- 操作人 ID 过滤

  • action -- 操作类型过滤

  • time_from -- 起始时间

  • time_to -- 结束时间

  • skip -- 跳过记录数

  • limit -- 限制记录数

返回:

审计日志列表

async create_indexes() None#

创建索引(含 TTL)。