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

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.http_validation_error import HttpValidationError
from ..types.languages import Languages
from ..types.dub_srt_input import DubSRTInput
from ..types.dub_target_srt_input import DubTargetSRTInput
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 .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 RawDubClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def end_to_end_dubbing(
        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,
        transcription_mode: typing.Optional[typing.Literal["fast", "slow"]] = "fast",
        source_transcript: typing.Optional[typing.Union[DubSRTInput, typing.Dict[str, typing.Any]]] = OMIT,
        target_transcripts: typing.Optional[typing.Sequence[typing.Union[DubTargetSRTInput, typing.Dict[str, typing.Any]]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[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]

        transcription_mode : typing.Optional[typing.Literal["fast", "slow"]]
            Transcription mode: `fast` (default) or `slow`.

        source_transcript : typing.Optional[typing.Union[DubSRTInput, typing.Dict[str, typing.Any]]]
            Optional original-language SRT contents. The API validates parsing and size limits.

        target_transcripts : typing.Optional[typing.Sequence[typing.Union[DubTargetSRTInput, typing.Dict[str, typing.Any]]]]
            Optional translated SRT contents, one per requested target language.

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

        Returns
        -------
        HttpResponse[OrchestratorPipelineCallResult]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "dub",
            method="POST",
            params={
                "run_id": run_id,
            },
            json={
                "project_name": project_name,
                "project_description": project_description,
                "folder_id": folder_id,
                "video_url": video_url,
                "source_language": source_language,
                "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,
                "transcription_mode": transcription_mode,
                "source_transcript": source_transcript,
                "target_transcripts": target_transcripts,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineCallResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineCallResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        HttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_dubbed_run_info(
        self, run_id: typing.Optional[int], *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[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
        -------
        HttpResponse[GetDubbedRunInfoDubResultRunIdGetResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"dub-result/{jsonable_encoder(run_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetDubbedRunInfoDubResultRunIdGetResponse,
                    parse_obj_as(
                        type_=GetDubbedRunInfoDubResultRunIdGetResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_dubbing_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,
    ) -> HttpResponse[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
        -------
        HttpResponse[typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue]]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "dubbing-results",
            method="POST",
            params={
                "run_id": run_id,
            },
            json={
                "run_ids": run_ids,
            },
            headers={
                "content-type": "application/json",
                "traceparent": str(traceparent) if traceparent is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue],
                    parse_obj_as(
                        type_=typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[typing.Dict[str, str]]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"transcript/{jsonable_encoder(run_id)}/{jsonable_encoder(language)}",
            method="GET",
            params={
                "format_type": format_type,
                "data_type": data_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Dict[str, str],
                    parse_obj_as(
                        type_=typing.Dict[str, str],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        language : Languages

        output_format : DubbedOutputInAltFormatRequestPayloadOutputFormat

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

        Returns
        -------
        HttpResponse[GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"dub-alt-format/{jsonable_encoder(run_id)}/{jsonable_encoder(language)}",
            method="POST",
            json={
                "output_format": convert_and_respect_annotation_metadata(
                    object_=output_format,
                    annotation=DubbedOutputInAltFormatRequestPayloadOutputFormat,
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse,
                    parse_obj_as(
                        type_=GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        HttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"dub-alt-format/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        HttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"discord/dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        HttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"twitter/dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


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

    async def end_to_end_dubbing(
        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,
        transcription_mode: typing.Optional[typing.Literal["fast", "slow"]] = "fast",
        source_transcript: typing.Optional[typing.Union[DubSRTInput, typing.Dict[str, typing.Any]]] = OMIT,
        target_transcripts: typing.Optional[typing.Sequence[typing.Union[DubTargetSRTInput, typing.Dict[str, typing.Any]]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[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]

        transcription_mode : typing.Optional[typing.Literal["fast", "slow"]]
            Transcription mode: `fast` (default) or `slow`.

        source_transcript : typing.Optional[typing.Union[DubSRTInput, typing.Dict[str, typing.Any]]]
            Optional original-language SRT contents. The API validates parsing and size limits.

        target_transcripts : typing.Optional[typing.Sequence[typing.Union[DubTargetSRTInput, typing.Dict[str, typing.Any]]]]
            Optional translated SRT contents, one per requested target language.

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

        Returns
        -------
        AsyncHttpResponse[OrchestratorPipelineCallResult]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "dub",
            method="POST",
            params={
                "run_id": run_id,
            },
            json={
                "project_name": project_name,
                "project_description": project_description,
                "folder_id": folder_id,
                "video_url": video_url,
                "source_language": source_language,
                "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,
                "transcription_mode": transcription_mode,
                "source_transcript": source_transcript,
                "target_transcripts": target_transcripts,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineCallResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineCallResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        AsyncHttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_dubbed_run_info(
        self, run_id: typing.Optional[int], *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[GetDubbedRunInfoDubResultRunIdGetResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"dub-result/{jsonable_encoder(run_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetDubbedRunInfoDubResultRunIdGetResponse,
                    parse_obj_as(
                        type_=GetDubbedRunInfoDubResultRunIdGetResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_dubbing_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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue]]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "dubbing-results",
            method="POST",
            params={
                "run_id": run_id,
            },
            json={
                "run_ids": run_ids,
            },
            headers={
                "content-type": "application/json",
                "traceparent": str(traceparent) if traceparent is not None else None,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue],
                    parse_obj_as(
                        type_=typing.Dict[str, GetDubbingRunsResultsDubbingResultsPostResponseValue],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[typing.Dict[str, str]]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"transcript/{jsonable_encoder(run_id)}/{jsonable_encoder(language)}",
            method="GET",
            params={
                "format_type": format_type,
                "data_type": data_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Dict[str, str],
                    parse_obj_as(
                        type_=typing.Dict[str, str],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        language : Languages

        output_format : DubbedOutputInAltFormatRequestPayloadOutputFormat

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

        Returns
        -------
        AsyncHttpResponse[GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"dub-alt-format/{jsonable_encoder(run_id)}/{jsonable_encoder(language)}",
            method="POST",
            json={
                "output_format": convert_and_respect_annotation_metadata(
                    object_=output_format,
                    annotation=DubbedOutputInAltFormatRequestPayloadOutputFormat,
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse,
                    parse_obj_as(
                        type_=GetDubbedOutputInAltFormatDubAltFormatRunIdLanguagePostResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[OrchestratorPipelineResult]:
        """
        Parameters
        ----------
        task_id : str

        run_id : typing.Optional[int]

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

        Returns
        -------
        AsyncHttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"dub-alt-format/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        AsyncHttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"discord/dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

        run_id : typing.Optional[int]

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

        Returns
        -------
        AsyncHttpResponse[OrchestratorPipelineResult]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"twitter/dub/{jsonable_encoder(task_id)}",
            method="GET",
            params={
                "run_id": run_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    OrchestratorPipelineResult,
                    parse_obj_as(
                        type_=OrchestratorPipelineResult,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
