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

import typing
from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.journey import Journey
from ..core.pydantic_utilities import parse_obj_as
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.composition_mode_dto import CompositionModeDto
from ..core.jsonable_encoder import jsonable_encoder
from ..errors.not_found_error import NotFoundError
from ..types.journey_condition_update_params import JourneyConditionUpdateParams
from ..types.journey_tag_update_params import JourneyTagUpdateParams
from ..core.serialization import convert_and_respect_annotation_metadata
from ..core.client_wrapper import AsyncClientWrapper

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


class JourneysClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def list(
        self,
        *,
        tag_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Journey]:
        """
        Retrieves a list of all journeys in the system.

        Parameters
        ----------
        tag_id : typing.Optional[str]
            The tag ID to filter journeys by

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

        Returns
        -------
        typing.List[Journey]
            List of all journeys in the system

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.list()
        """
        _response = self._client_wrapper.httpx_client.request(
            "journeys",
            method="GET",
            params={
                "tag_id": tag_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Journey],
                    parse_obj_as(
                        type_=typing.List[Journey],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def create(
        self,
        *,
        title: str,
        description: str,
        conditions: typing.Sequence[str],
        id: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        composition_mode: typing.Optional[CompositionModeDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Creates a new journey in the system.

        The journey will be initialized with the provided title, description, and conditions.
        A unique identifier will be automatically generated unless a custom ID is provided.

        Parameters
        ----------
        title : str
            The title of the journey

        description : str

        conditions : typing.Sequence[str]

        id : typing.Optional[str]
            Unique identifier for the journey

        tags : typing.Optional[typing.Sequence[str]]
            List of tag IDs associated with the journey

        composition_mode : typing.Optional[CompositionModeDto]

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

        Returns
        -------
        Journey
            Journey successfully created. Returns the complete journey object including generated ID.

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.create(
            title="Customer Onboarding",
            description="1. Customer wants to lock their card\n2. Customer reports that their card doesn't work\n3. Customer suspects their card has been stolen",
            conditions=[
                "customer needs unlocking their card",
                "customer needs help with card",
            ],
            id="IUCGT-lvpS",
            tags=["tag1", "tag2"],
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            "journeys",
            method="POST",
            json={
                "title": title,
                "description": description,
                "conditions": conditions,
                "id": id,
                "tags": tags,
                "composition_mode": composition_mode,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def retrieve(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Retrieves details of a specific journey by ID.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        Journey
            Journey details successfully retrieved. Returns the complete journey object.

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.retrieve(
            journey_id="IUCGT-lvpS",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def delete(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Deletes a journey from the system.

        Also deletes the associated guideline.
        Deleting a non-existent journey will return 404.
        No content will be returned from a successful deletion.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        None

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.delete(
            journey_id="IUCGT-lvpS",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def update(
        self,
        journey_id: str,
        *,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        conditions: typing.Optional[JourneyConditionUpdateParams] = OMIT,
        tags: typing.Optional[JourneyTagUpdateParams] = OMIT,
        composition_mode: typing.Optional[CompositionModeDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Updates an existing journey's attributes.

        Only the provided attributes will be updated; others will remain unchanged.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

        title : typing.Optional[str]
            The title of the journey

        description : typing.Optional[str]

        conditions : typing.Optional[JourneyConditionUpdateParams]

        tags : typing.Optional[JourneyTagUpdateParams]

        composition_mode : typing.Optional[CompositionModeDto]

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

        Returns
        -------
        Journey
            Journey successfully updated. Returns the updated journey.

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.update(
            journey_id="IUCGT-lvpS",
            title="Customer Onboarding",
            description="1. Customer wants to lock their card\n2. Customer reports that their card doesn't work\n3. Customer suspects their card has been stolen",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="PATCH",
            json={
                "title": title,
                "description": description,
                "conditions": convert_and_respect_annotation_metadata(
                    object_=conditions,
                    annotation=JourneyConditionUpdateParams,
                    direction="write",
                ),
                "tags": convert_and_respect_annotation_metadata(
                    object_=tags, annotation=JourneyTagUpdateParams, direction="write"
                ),
                "composition_mode": composition_mode,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def mermaid(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> str:
        """
        Returns the journey as a Mermaid 'stateDiagramv-v2' string.
        Content-Type: text/plain

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        str
            Mermaid stateDiagram V2 (text/plain). Copy/paste directly into a Mermaid renderer.

        Examples
        --------
        from parlant.client import ParlantClient

        client = ParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )
        client.journeys.mermaid(
            journey_id="journey_id",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}/mermaid",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return _response.text  # type: ignore
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


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

    async def list(
        self,
        *,
        tag_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Journey]:
        """
        Retrieves a list of all journeys in the system.

        Parameters
        ----------
        tag_id : typing.Optional[str]
            The tag ID to filter journeys by

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

        Returns
        -------
        typing.List[Journey]
            List of all journeys in the system

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "journeys",
            method="GET",
            params={
                "tag_id": tag_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Journey],
                    parse_obj_as(
                        type_=typing.List[Journey],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def create(
        self,
        *,
        title: str,
        description: str,
        conditions: typing.Sequence[str],
        id: typing.Optional[str] = OMIT,
        tags: typing.Optional[typing.Sequence[str]] = OMIT,
        composition_mode: typing.Optional[CompositionModeDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Creates a new journey in the system.

        The journey will be initialized with the provided title, description, and conditions.
        A unique identifier will be automatically generated unless a custom ID is provided.

        Parameters
        ----------
        title : str
            The title of the journey

        description : str

        conditions : typing.Sequence[str]

        id : typing.Optional[str]
            Unique identifier for the journey

        tags : typing.Optional[typing.Sequence[str]]
            List of tag IDs associated with the journey

        composition_mode : typing.Optional[CompositionModeDto]

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

        Returns
        -------
        Journey
            Journey successfully created. Returns the complete journey object including generated ID.

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.journeys.create(
                title="Customer Onboarding",
                description="1. Customer wants to lock their card\n2. Customer reports that their card doesn't work\n3. Customer suspects their card has been stolen",
                conditions=[
                    "customer needs unlocking their card",
                    "customer needs help with card",
                ],
                id="IUCGT-lvpS",
                tags=["tag1", "tag2"],
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "journeys",
            method="POST",
            json={
                "title": title,
                "description": description,
                "conditions": conditions,
                "id": id,
                "tags": tags,
                "composition_mode": composition_mode,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def retrieve(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Retrieves details of a specific journey by ID.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        Journey
            Journey details successfully retrieved. Returns the complete journey object.

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.journeys.retrieve(
                journey_id="IUCGT-lvpS",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def delete(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Deletes a journey from the system.

        Also deletes the associated guideline.
        Deleting a non-existent journey will return 404.
        No content will be returned from a successful deletion.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.journeys.delete(
                journey_id="IUCGT-lvpS",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def update(
        self,
        journey_id: str,
        *,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        conditions: typing.Optional[JourneyConditionUpdateParams] = OMIT,
        tags: typing.Optional[JourneyTagUpdateParams] = OMIT,
        composition_mode: typing.Optional[CompositionModeDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Journey:
        """
        Updates an existing journey's attributes.

        Only the provided attributes will be updated; others will remain unchanged.

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

        title : typing.Optional[str]
            The title of the journey

        description : typing.Optional[str]

        conditions : typing.Optional[JourneyConditionUpdateParams]

        tags : typing.Optional[JourneyTagUpdateParams]

        composition_mode : typing.Optional[CompositionModeDto]

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

        Returns
        -------
        Journey
            Journey successfully updated. Returns the updated journey.

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.journeys.update(
                journey_id="IUCGT-lvpS",
                title="Customer Onboarding",
                description="1. Customer wants to lock their card\n2. Customer reports that their card doesn't work\n3. Customer suspects their card has been stolen",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}",
            method="PATCH",
            json={
                "title": title,
                "description": description,
                "conditions": convert_and_respect_annotation_metadata(
                    object_=conditions,
                    annotation=JourneyConditionUpdateParams,
                    direction="write",
                ),
                "tags": convert_and_respect_annotation_metadata(
                    object_=tags, annotation=JourneyTagUpdateParams, direction="write"
                ),
                "composition_mode": composition_mode,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Journey,
                    parse_obj_as(
                        type_=Journey,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def mermaid(
        self,
        journey_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> str:
        """
        Returns the journey as a Mermaid 'stateDiagramv-v2' string.
        Content-Type: text/plain

        Parameters
        ----------
        journey_id : str
            Unique identifier for the journey

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

        Returns
        -------
        str
            Mermaid stateDiagram V2 (text/plain). Copy/paste directly into a Mermaid renderer.

        Examples
        --------
        import asyncio

        from parlant.client import AsyncParlantClient

        client = AsyncParlantClient(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.journeys.mermaid(
                journey_id="journey_id",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"journeys/{jsonable_encoder(journey_id)}/mermaid",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return _response.text  # type: ignore
            if _response.status_code == 404:
                raise NotFoundError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    typing.cast(
                        typing.Optional[typing.Any],
                        parse_obj_as(
                            type_=typing.Optional[typing.Any],  # type: ignore
                            object_=_response.json(),
                        ),
                    )
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
