# 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.languages import Languages
from ..types.orchestrator_pipeline_call_result import OrchestratorPipelineCallResult
from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
from ..types.transcript_data_type import TranscriptDataType
from ..types.transcript_file_format import TranscriptFileFormat
from .raw_client import AsyncRawDubClient, RawDubClient
from .types.dubbed_output_in_alt_format_request_payload_output_format import (
    DubbedOutputInAltFormatRequestPayloadOutputFormat,
)
from .types.get_dubbed_output_in_alt_format_dub_alt_format_run_id_language_post_response import (
    GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse,
)
from .types.get_dubbed_run_info_dub_result_run_id_get_response import GetDubbedRunInfoDubResultRunIdGetResponse
from .types.get_dubbing_runs_results_dubbing_results_post_response_value import (
    GetDubbingRunsResultsDubbingResultsPostResponseValue,
)

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


class DubClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDubClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDubClient
        """
        return self._raw_client

    def create_dub(
        self,
        *,
        video_url: str,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        project_name: typing.Optional[str] = OMIT,
        project_description: typing.Optional[str] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        target_language: typing.Optional[Languages] = OMIT,
        target_languages: typing.Optional[typing.Sequence[Languages]] = OMIT,
        selected_audio_tracks: typing.Optional[typing.Sequence[int]] = OMIT,
        add_output_as_an_audio_track: typing.Optional[bool] = OMIT,
        chosen_dictionaries: typing.Optional[typing.Sequence[int]] = OMIT,
        ai_optimization: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineCallResult:
        """
        Parameters
        ----------
        video_url : str

        source_language : Languages

        run_id : typing.Optional[int]

        project_name : typing.Optional[str]

        project_description : typing.Optional[str]

        folder_id : typing.Optional[int]

        target_language : typing.Optional[Languages]

        target_languages : typing.Optional[typing.Sequence[Languages]]

        selected_audio_tracks : typing.Optional[typing.Sequence[int]]

        add_output_as_an_audio_track : typing.Optional[bool]

        chosen_dictionaries : typing.Optional[typing.Sequence[int]]

        ai_optimization : typing.Optional[bool]

        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.dub.end_to_end_dubbing(
            video_url="video_url",
            source_language=1,
        )
        """
        _response = self._raw_client.end_to_end_dubbing(
            video_url=video_url,
            source_language=source_language,
            run_id=run_id,
            project_name=project_name,
            project_description=project_description,
            folder_id=folder_id,
            target_language=target_language,
            target_languages=target_languages,
            selected_audio_tracks=selected_audio_tracks,
            add_output_as_an_audio_track=add_output_as_an_audio_track,
            chosen_dictionaries=chosen_dictionaries,
            ai_optimization=ai_optimization,
            request_options=request_options,
        )
        return _response.data

    def get_dubbing_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.dub.get_dubbing_status(
            task_id="task_id",
        )
        """
        _response = self._raw_client.get_end_to_end_dubbing_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

    def get_dubbed_run_info(
        self, run_id: typing.Optional[int], *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetDubbedRunInfoDubResultRunIdGetResponse:
        """
        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]

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

        Returns
        -------
        GetDubbedRunInfoDubResultRunIdGetResponse
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dub.get_dubbed_run_info(
            run_id=1,
        )
        """
        _response = self._raw_client.get_dubbed_run_info(run_id, request_options=request_options)
        return _response.data

    def get_dubbed_runs_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, GetDubbingRunsResultsDubbingResultsPostResponseValue]:
        """
        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, GetDubbingRunsResultsDubbingResultsPostResponseValue]
            Successful Response

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

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

    def get_dubbed_run_transcript(
        self,
        run_id: typing.Optional[int],
        language: Languages,
        *,
        format_type: typing.Optional[TranscriptFileFormat] = None,
        data_type: typing.Optional[TranscriptDataType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, str]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        language : Languages

        format_type : typing.Optional[TranscriptFileFormat]
            Format to use for the transcription. Either `srt`, `vtt` or `txt`. Defaults to `txt`.

        data_type : typing.Optional[TranscriptDataType]
            Data type for the transcription being returned. Returns the raw data of the transcription or a presigned url for the file that holds the transcription data.

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

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

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dub.get_dubbed_run_transcript(
            run_id=1,
            language=1,
        )
        """
        _response = self._raw_client.get_dubbed_run_transcript(
            run_id, language, format_type=format_type, data_type=data_type, request_options=request_options
        )
        return _response.data

    def get_dubbed_output_in_alt_format(
        self,
        run_id: typing.Optional[int],
        language: Languages,
        *,
        output_format: DubbedOutputInAltFormatRequestPayloadOutputFormat,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        language : Languages

        output_format : DubbedOutputInAltFormatRequestPayloadOutputFormat

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

        Returns
        -------
        GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dub.get_dubbed_output_in_alt_format(
            run_id=1,
            language=1,
            output_format="flac",
        )
        """
        _response = self._raw_client.get_dubbed_output_in_alt_format(
            run_id, language, output_format=output_format, request_options=request_options
        )
        return _response.data

    def get_dubbed_output_in_alt_format_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.dub.get_dubbed_output_in_alt_format_status(
            task_id="task_id",
        )
        """
        _response = self._raw_client.get_dubbed_output_in_alt_format_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

class AsyncDubClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDubClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDubClient
        """
        return self._raw_client

    async def create_dub(
        self,
        *,
        video_url: str,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        project_name: typing.Optional[str] = OMIT,
        project_description: typing.Optional[str] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        target_language: typing.Optional[Languages] = OMIT,
        target_languages: typing.Optional[typing.Sequence[Languages]] = OMIT,
        selected_audio_tracks: typing.Optional[typing.Sequence[int]] = OMIT,
        add_output_as_an_audio_track: typing.Optional[bool] = OMIT,
        chosen_dictionaries: typing.Optional[typing.Sequence[int]] = OMIT,
        ai_optimization: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineCallResult:
        """
        Parameters
        ----------
        video_url : str

        source_language : Languages

        run_id : typing.Optional[int]

        project_name : typing.Optional[str]

        project_description : typing.Optional[str]

        folder_id : typing.Optional[int]

        target_language : typing.Optional[Languages]

        target_languages : typing.Optional[typing.Sequence[Languages]]

        selected_audio_tracks : typing.Optional[typing.Sequence[int]]

        add_output_as_an_audio_track : typing.Optional[bool]

        chosen_dictionaries : typing.Optional[typing.Sequence[int]]

        ai_optimization : typing.Optional[bool]

        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.dub.create_dub(
                video_url="video_url",
                source_language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.end_to_end_dubbing(
            video_url=video_url,
            source_language=source_language,
            run_id=run_id,
            project_name=project_name,
            project_description=project_description,
            folder_id=folder_id,
            target_language=target_language,
            target_languages=target_languages,
            selected_audio_tracks=selected_audio_tracks,
            add_output_as_an_audio_track=add_output_as_an_audio_track,
            chosen_dictionaries=chosen_dictionaries,
            ai_optimization=ai_optimization,
            request_options=request_options,
        )
        return _response.data

    async def get_dubbing_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.dub.get_dubbing_status(
                task_id="task_id",
            )


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

    async def get_dubbed_run_info(
        self, run_id: typing.Optional[int], *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetDubbedRunInfoDubResultRunIdGetResponse:
        """
        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]

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

        Returns
        -------
        GetDubbedRunInfoDubResultRunIdGetResponse
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


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


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

    async def get_dubbed_runs_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, GetDubbingRunsResultsDubbingResultsPostResponseValue]:
        """
        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, GetDubbingRunsResultsDubbingResultsPostResponseValue]
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


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


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

    async def get_dubbed_run_transcript(
        self,
        run_id: typing.Optional[int],
        language: Languages,
        *,
        format_type: typing.Optional[TranscriptFileFormat] = None,
        data_type: typing.Optional[TranscriptDataType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, str]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        language : Languages

        format_type : typing.Optional[TranscriptFileFormat]
            Format to use for the transcription. Either `srt`, `vtt` or `txt`. Defaults to `txt`.

        data_type : typing.Optional[TranscriptDataType]
            Data type for the transcription being returned. Returns the raw data of the transcription or a presigned url for the file that holds the transcription data.

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

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

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dub.get_dubbed_run_transcript(
                run_id=1,
                language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_dubbed_run_transcript(
            run_id, language, format_type=format_type, data_type=data_type, request_options=request_options
        )
        return _response.data

    async def get_dubbed_output_in_alt_format(
        self,
        run_id: typing.Optional[int],
        language: Languages,
        *,
        output_format: DubbedOutputInAltFormatRequestPayloadOutputFormat,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        language : Languages

        output_format : DubbedOutputInAltFormatRequestPayloadOutputFormat

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

        Returns
        -------
        GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dub.get_dubbed_output_in_alt_format(
                run_id=1,
                language=1,
                output_format="flac",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_dubbed_output_in_alt_format(
            run_id, language, output_format=output_format, request_options=request_options
        )
        return _response.data

    async def get_dubbed_output_in_alt_format_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.dub.get_dubbed_output_in_alt_format_status(
                task_id="task_id",
            )


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

    async def poll_discord_dub_task(
        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.dub.poll_discord_dub_task(
                task_id="task_id",
            )


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

    async def poll_twitter_dub_task(
        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.dub.poll_twitter_dub_task(
                task_id="task_id",
            )


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