dynamo_async_openai/
audit_logs.rs

1// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Based on https://github.com/64bit/async-openai/ by Himanshu Neema
5// Original Copyright (c) 2022 Himanshu Neema
6// Licensed under MIT License (see ATTRIBUTIONS-Rust.md)
7//
8// Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
9// Licensed under Apache 2.0
10
11use serde::Serialize;
12
13use crate::{config::Config, error::OpenAIError, types::ListAuditLogsResponse, Client};
14
15/// Logs of user actions and configuration changes within this organization.
16/// To log events, you must activate logging in the [Organization Settings](https://platform.openai.com/settings/organization/general).
17/// Once activated, for security reasons, logging cannot be deactivated.
18pub struct AuditLogs<'c, C: Config> {
19    client: &'c Client<C>,
20}
21
22impl<'c, C: Config> AuditLogs<'c, C> {
23    pub fn new(client: &'c Client<C>) -> Self {
24        Self { client }
25    }
26
27    /// List user actions and configuration changes within this organization.
28    #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
29    pub async fn get<Q>(&self, query: &Q) -> Result<ListAuditLogsResponse, OpenAIError>
30    where
31        Q: Serialize + ?Sized,
32    {
33        self.client
34            .get_with_query("/organization/audit_logs", &query)
35            .await
36    }
37}