# This file was auto-generated by Fern from our API Definition.

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.workspace_audit_logs_page_response import WorkspaceAuditLogsPageResponse
from .raw_client import AsyncRawAuditLogsClient, RawAuditLogsClient


class AuditLogsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAuditLogsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawAuditLogsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawAuditLogsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        time_from_unix_ms: typing.Optional[int] = None,
        time_to_unix_ms: typing.Optional[int] = None,
        actor_uid: typing.Optional[str] = None,
        class_name: typing.Optional[str] = None,
        activity_name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceAuditLogsPageResponse:
        """
        Returns the audit log for the workspace. Requires enterprise tier and the audit_log_read permission.

        Parameters
        ----------
        limit : typing.Optional[int]
            Maximum number of entries per page

        cursor : typing.Optional[str]
            Cursor for the next page (from previous response)

        time_from_unix_ms : typing.Optional[int]
            Only include entries at or after this time (ms since epoch)

        time_to_unix_ms : typing.Optional[int]
            Only include entries at or before this time (ms since epoch)

        actor_uid : typing.Optional[str]
            Filter by actor user ID

        class_name : typing.Optional[str]
            Filter by OCSF event class name (e.g. Account Change)

        activity_name : typing.Optional[str]
            Filter by audit activity name (e.g. Subscription Creation)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkspaceAuditLogsPageResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.audit_logs.list(
            limit=1,
            cursor="cursor",
            time_from_unix_ms=1,
            time_to_unix_ms=1,
            actor_uid="actor_uid",
            class_name="class_name",
            activity_name="activity_name",
        )
        """
        _response = self._raw_client.list(
            limit=limit,
            cursor=cursor,
            time_from_unix_ms=time_from_unix_ms,
            time_to_unix_ms=time_to_unix_ms,
            actor_uid=actor_uid,
            class_name=class_name,
            activity_name=activity_name,
            request_options=request_options,
        )
        return _response.data


class AsyncAuditLogsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAuditLogsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawAuditLogsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawAuditLogsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        time_from_unix_ms: typing.Optional[int] = None,
        time_to_unix_ms: typing.Optional[int] = None,
        actor_uid: typing.Optional[str] = None,
        class_name: typing.Optional[str] = None,
        activity_name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceAuditLogsPageResponse:
        """
        Returns the audit log for the workspace. Requires enterprise tier and the audit_log_read permission.

        Parameters
        ----------
        limit : typing.Optional[int]
            Maximum number of entries per page

        cursor : typing.Optional[str]
            Cursor for the next page (from previous response)

        time_from_unix_ms : typing.Optional[int]
            Only include entries at or after this time (ms since epoch)

        time_to_unix_ms : typing.Optional[int]
            Only include entries at or before this time (ms since epoch)

        actor_uid : typing.Optional[str]
            Filter by actor user ID

        class_name : typing.Optional[str]
            Filter by OCSF event class name (e.g. Account Change)

        activity_name : typing.Optional[str]
            Filter by audit activity name (e.g. Subscription Creation)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkspaceAuditLogsPageResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspace.audit_logs.list(
                limit=1,
                cursor="cursor",
                time_from_unix_ms=1,
                time_to_unix_ms=1,
                actor_uid="actor_uid",
                class_name="class_name",
                activity_name="activity_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            limit=limit,
            cursor=cursor,
            time_from_unix_ms=time_from_unix_ms,
            time_to_unix_ms=time_to_unix_ms,
            actor_uid=actor_uid,
            class_name=class_name,
            activity_name=activity_name,
            request_options=request_options,
        )
        return _response.data
