# 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.activity_log_response import ActivityLogResponse
from .raw_client import AsyncRawActivityLogsClient, RawActivityLogsClient
from .types.list_activity_logs_request_method import ListActivityLogsRequestMethod


class ActivityLogsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawActivityLogsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawActivityLogsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        end_date: typing.Optional[str] = None,
        method: typing.Optional[ListActivityLogsRequestMethod] = None,
        ordering: typing.Optional[str] = None,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        project: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        start_date: typing.Optional[str] = None,
        user: typing.Optional[int] = None,
        workspace: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[ActivityLogResponse]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve activity logs filtered by workspace, project, user, HTTP method, date range or search query.

        Parameters
        ----------
        end_date : typing.Optional[str]
            End date/time (ISO-8601) for log filtering.

        method : typing.Optional[ListActivityLogsRequestMethod]
            HTTP request method used in the log.

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        page : typing.Optional[int]
            [or "start"] Current page index.

        page_size : typing.Optional[int]
            [or "length"] Logs per page, use -1 to obtain all logs (might be slow).

        project : typing.Optional[int]
            Project ID to filter logs.

        search : typing.Optional[str]
            Search expression using "AND"/"OR" to filter by request URL.

        start_date : typing.Optional[str]
            Start date/time (ISO-8601) for log filtering.

        user : typing.Optional[int]
            User ID to filter logs.

        workspace : typing.Optional[int]
            Workspace owner ID to filter logs.

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

        Returns
        -------
        typing.List[ActivityLogResponse]
            Activity logs

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.activity_logs.list()
        """
        _response = self._raw_client.list(
            end_date=end_date,
            method=method,
            ordering=ordering,
            page=page,
            page_size=page_size,
            project=project,
            search=search,
            start_date=start_date,
            user=user,
            workspace=workspace,
            request_options=request_options,
        )
        return _response.data


class AsyncActivityLogsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawActivityLogsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawActivityLogsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        end_date: typing.Optional[str] = None,
        method: typing.Optional[ListActivityLogsRequestMethod] = None,
        ordering: typing.Optional[str] = None,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        project: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        start_date: typing.Optional[str] = None,
        user: typing.Optional[int] = None,
        workspace: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[ActivityLogResponse]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Retrieve activity logs filtered by workspace, project, user, HTTP method, date range or search query.

        Parameters
        ----------
        end_date : typing.Optional[str]
            End date/time (ISO-8601) for log filtering.

        method : typing.Optional[ListActivityLogsRequestMethod]
            HTTP request method used in the log.

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

        page : typing.Optional[int]
            [or "start"] Current page index.

        page_size : typing.Optional[int]
            [or "length"] Logs per page, use -1 to obtain all logs (might be slow).

        project : typing.Optional[int]
            Project ID to filter logs.

        search : typing.Optional[str]
            Search expression using "AND"/"OR" to filter by request URL.

        start_date : typing.Optional[str]
            Start date/time (ISO-8601) for log filtering.

        user : typing.Optional[int]
            User ID to filter logs.

        workspace : typing.Optional[int]
            Workspace owner ID to filter logs.

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

        Returns
        -------
        typing.List[ActivityLogResponse]
            Activity logs

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.activity_logs.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            end_date=end_date,
            method=method,
            ordering=ordering,
            page=page,
            page_size=page_size,
            project=project,
            search=search,
            start_date=start_date,
            user=user,
            workspace=workspace,
            request_options=request_options,
        )
        return _response.data
