# 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.app_api_v1schemas_audit_log_v2audit_log_list_response import AppApiV1SchemasAuditLogV2AuditLogListResponse
from .raw_client import AsyncRawAuditLogV2Client, RawAuditLogV2Client


class AuditLogV2Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAuditLogV2Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAuditLogV2Client
        """
        return self._raw_client

    def query_audit_log(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        action_type: typing.Optional[str] = None,
        actor_id: typing.Optional[str] = None,
        target_id: typing.Optional[str] = None,
        department_id: typing.Optional[str] = None,
        from_date: typing.Optional[str] = None,
        to_date: typing.Optional[str] = None,
        search_term: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AppApiV1SchemasAuditLogV2AuditLogListResponse:
        """
        Query audit log entries with filters and pagination.

        Parameters
        ----------
        organization_id : str

        entity_type : typing.Optional[str]

        entity_id : typing.Optional[str]

        action_type : typing.Optional[str]

        actor_id : typing.Optional[str]

        target_id : typing.Optional[str]

        department_id : typing.Optional[str]

        from_date : typing.Optional[str]

        to_date : typing.Optional[str]

        search_term : typing.Optional[str]

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AppApiV1SchemasAuditLogV2AuditLogListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.audit_log_v2.query_audit_log(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.query_audit_log(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            action_type=action_type,
            actor_id=actor_id,
            target_id=target_id,
            department_id=department_id,
            from_date=from_date,
            to_date=to_date,
            search_term=search_term,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    def export_audit_log(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        action_type: typing.Optional[str] = None,
        actor_id: typing.Optional[str] = None,
        target_id: typing.Optional[str] = None,
        department_id: typing.Optional[str] = None,
        from_date: typing.Optional[str] = None,
        to_date: typing.Optional[str] = None,
        search_term: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Export audit log entries as CSV.

        Parameters
        ----------
        organization_id : str

        entity_type : typing.Optional[str]

        entity_id : typing.Optional[str]

        action_type : typing.Optional[str]

        actor_id : typing.Optional[str]

        target_id : typing.Optional[str]

        department_id : typing.Optional[str]

        from_date : typing.Optional[str]

        to_date : typing.Optional[str]

        search_term : typing.Optional[str]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.audit_log_v2.export_audit_log(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.export_audit_log(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            action_type=action_type,
            actor_id=actor_id,
            target_id=target_id,
            department_id=department_id,
            from_date=from_date,
            to_date=to_date,
            search_term=search_term,
            request_options=request_options,
        )
        return _response.data


class AsyncAuditLogV2Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAuditLogV2Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAuditLogV2Client
        """
        return self._raw_client

    async def query_audit_log(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        action_type: typing.Optional[str] = None,
        actor_id: typing.Optional[str] = None,
        target_id: typing.Optional[str] = None,
        department_id: typing.Optional[str] = None,
        from_date: typing.Optional[str] = None,
        to_date: typing.Optional[str] = None,
        search_term: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AppApiV1SchemasAuditLogV2AuditLogListResponse:
        """
        Query audit log entries with filters and pagination.

        Parameters
        ----------
        organization_id : str

        entity_type : typing.Optional[str]

        entity_id : typing.Optional[str]

        action_type : typing.Optional[str]

        actor_id : typing.Optional[str]

        target_id : typing.Optional[str]

        department_id : typing.Optional[str]

        from_date : typing.Optional[str]

        to_date : typing.Optional[str]

        search_term : typing.Optional[str]

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        AppApiV1SchemasAuditLogV2AuditLogListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.audit_log_v2.query_audit_log(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.query_audit_log(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            action_type=action_type,
            actor_id=actor_id,
            target_id=target_id,
            department_id=department_id,
            from_date=from_date,
            to_date=to_date,
            search_term=search_term,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    async def export_audit_log(
        self,
        organization_id: str,
        *,
        entity_type: typing.Optional[str] = None,
        entity_id: typing.Optional[str] = None,
        action_type: typing.Optional[str] = None,
        actor_id: typing.Optional[str] = None,
        target_id: typing.Optional[str] = None,
        department_id: typing.Optional[str] = None,
        from_date: typing.Optional[str] = None,
        to_date: typing.Optional[str] = None,
        search_term: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Export audit log entries as CSV.

        Parameters
        ----------
        organization_id : str

        entity_type : typing.Optional[str]

        entity_id : typing.Optional[str]

        action_type : typing.Optional[str]

        actor_id : typing.Optional[str]

        target_id : typing.Optional[str]

        department_id : typing.Optional[str]

        from_date : typing.Optional[str]

        to_date : typing.Optional[str]

        search_term : typing.Optional[str]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.audit_log_v2.export_audit_log(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.export_audit_log(
            organization_id,
            entity_type=entity_type,
            entity_id=entity_id,
            action_type=action_type,
            actor_id=actor_id,
            target_id=target_id,
            department_id=department_id,
            from_date=from_date,
            to_date=to_date,
            search_term=search_term,
            request_options=request_options,
        )
        return _response.data
