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

import typing

from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.languages import Languages
from ..types.orchestrator_pipeline_call_result import OrchestratorPipelineCallResult
from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
from ..types.transcription_result import TranscriptionResult
from .raw_client import AsyncRawTranscriptionClient, RawTranscriptionClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class TranscriptionClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTranscriptionClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTranscriptionClient
        """
        return self._raw_client

    def create_transcription(
        self,
        *,
        language: Languages,
        run_id: typing.Optional[int] = None,
        media_file: typing.Optional[core.File] = OMIT,
        media_url: typing.Optional[str] = OMIT,
        file: typing.Optional[core.File] = OMIT,
        audio_url: typing.Optional[str] = OMIT,
        project_name: typing.Optional[str] = OMIT,
        project_description: typing.Optional[str] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineCallResult:
        """
        Parameters
        ----------
        language : Languages
            Signed URL to audio file for transcription

        run_id : typing.Optional[int]

        media_file : typing.Optional[core.File]
            See core.File for more documentation

        media_url : typing.Optional[str]
            Signed URL to media file for transcription

        file : typing.Optional[core.File]
            See core.File for more documentation

        audio_url : typing.Optional[str]
            [DEPRECATED] Use 'audio_url' instead

        project_name : typing.Optional[str]

        project_description : typing.Optional[str]

        folder_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineCallResult
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.transcription.create_transcription(
            language=1,
        )
        """
        _response = self._raw_client.create_transcription(
            language=language,
            run_id=run_id,
            media_file=media_file,
            media_url=media_url,
            file=file,
            audio_url=audio_url,
            project_name=project_name,
            project_description=project_description,
            folder_id=folder_id,
            request_options=request_options,
        )
        return _response.data

    def get_transcription_task_status(
        self,
        task_id: str,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineResult:
        """
        Parameters
        ----------
        task_id : str

        run_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineResult
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.transcription.get_transcription_task_status(
            task_id="task_id",
        )
        """
        _response = self._raw_client.get_transcription_task_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

    def get_transcription_result(
        self,
        run_id: typing.Optional[int],
        *,
        word_level_timestamps: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TranscriptionResult:
        """
        NOTE: This endpoint should be called only by the users to get values for their runs via API.
        Further we need to validate if the user has access to the run_id, otherwise we should not return the output urls.

        Parameters
        ----------
        run_id : typing.Optional[int]

        word_level_timestamps : typing.Optional[bool]

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

        Returns
        -------
        TranscriptionResult
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.transcription.get_transcription_result(
            run_id=1,
        )
        """
        _response = self._raw_client.get_transcription_result(
            run_id, word_level_timestamps=word_level_timestamps, request_options=request_options
        )
        return _response.data

    def get_transcription_results(
        self,
        *,
        run_ids: typing.Sequence[int],
        run_id: typing.Optional[int] = None,
        traceparent: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, TranscriptionResult]:
        """
        Parameters
        ----------
        run_ids : typing.Sequence[int]

        run_id : typing.Optional[int]

        traceparent : typing.Optional[str]

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

        Returns
        -------
        typing.Dict[str, TranscriptionResult]
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.transcription.get_transcription_results(
            run_ids=[1],
        )
        """
        _response = self._raw_client.get_transcription_results(
            run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
        )
        return _response.data


class AsyncTranscriptionClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTranscriptionClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTranscriptionClient
        """
        return self._raw_client

    async def create_transcription(
        self,
        *,
        language: Languages,
        run_id: typing.Optional[int] = None,
        media_file: typing.Optional[core.File] = OMIT,
        media_url: typing.Optional[str] = OMIT,
        file: typing.Optional[core.File] = OMIT,
        audio_url: typing.Optional[str] = OMIT,
        project_name: typing.Optional[str] = OMIT,
        project_description: typing.Optional[str] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineCallResult:
        """
        Parameters
        ----------
        language : Languages
            Signed URL to audio file for transcription

        run_id : typing.Optional[int]

        media_file : typing.Optional[core.File]
            See core.File for more documentation

        media_url : typing.Optional[str]
            Signed URL to media file for transcription

        file : typing.Optional[core.File]
            See core.File for more documentation

        audio_url : typing.Optional[str]
            [DEPRECATED] Use 'audio_url' instead

        project_name : typing.Optional[str]

        project_description : typing.Optional[str]

        folder_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineCallResult
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.transcription.create_transcription(
                language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_transcription(
            language=language,
            run_id=run_id,
            media_file=media_file,
            media_url=media_url,
            file=file,
            audio_url=audio_url,
            project_name=project_name,
            project_description=project_description,
            folder_id=folder_id,
            request_options=request_options,
        )
        return _response.data

    async def get_transcription_task_status(
        self,
        task_id: str,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineResult:
        """
        Parameters
        ----------
        task_id : str

        run_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineResult
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.transcription.get_transcription_task_status(
                task_id="task_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_transcription_task_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

    async def get_transcription_result(
        self,
        run_id: typing.Optional[int],
        *,
        word_level_timestamps: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TranscriptionResult:
        """
        NOTE: This endpoint should be called only by the users to get values for their runs via API.
        Further we need to validate if the user has access to the run_id, otherwise we should not return the output urls.

        Parameters
        ----------
        run_id : typing.Optional[int]

        word_level_timestamps : typing.Optional[bool]

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

        Returns
        -------
        TranscriptionResult
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.transcription.get_transcription_result(
                run_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_transcription_result(
            run_id, word_level_timestamps=word_level_timestamps, request_options=request_options
        )
        return _response.data

    async def get_transcription_results(
        self,
        *,
        run_ids: typing.Sequence[int],
        run_id: typing.Optional[int] = None,
        traceparent: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, TranscriptionResult]:
        """
        Parameters
        ----------
        run_ids : typing.Sequence[int]

        run_id : typing.Optional[int]

        traceparent : typing.Optional[str]

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

        Returns
        -------
        typing.Dict[str, TranscriptionResult]
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.transcription.get_transcription_results(
                run_ids=[1],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_transcription_results(
            run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
        )
        return _response.data
