# 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 .raw_client import AsyncRawSentryOauthClient, RawSentryOauthClient


class SentryOauthClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSentryOauthClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSentryOauthClient
        """
        return self._raw_client

    def authorizesentry_oauth(
        self,
        *,
        instance_id: str,
        redirect_url: typing.Optional[str] = None,
        force_refresh: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Start OAuth flow and redirect to authorization page.

        Parameters
        ----------
        instance_id : str
            Unique identifier for the MCP connection

        redirect_url : typing.Optional[str]
            Optional URL to redirect to after authorization

        force_refresh : typing.Optional[bool]
            Force re-authorization even if valid tokens exist

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from klavis import Klavis

        client = Klavis(
            api_key="YOUR_API_KEY",
        )
        client.sentry_oauth.authorizesentry_oauth(
            instance_id="instance_id",
            redirect_url="redirect_url",
            force_refresh=True,
        )
        """
        _response = self._raw_client.authorizesentry_oauth(
            instance_id=instance_id,
            redirect_url=redirect_url,
            force_refresh=force_refresh,
            request_options=request_options,
        )
        return _response.data


class AsyncSentryOauthClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSentryOauthClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSentryOauthClient
        """
        return self._raw_client

    async def authorizesentry_oauth(
        self,
        *,
        instance_id: str,
        redirect_url: typing.Optional[str] = None,
        force_refresh: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Start OAuth flow and redirect to authorization page.

        Parameters
        ----------
        instance_id : str
            Unique identifier for the MCP connection

        redirect_url : typing.Optional[str]
            Optional URL to redirect to after authorization

        force_refresh : typing.Optional[bool]
            Force re-authorization even if valid tokens exist

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from klavis import AsyncKlavis

        client = AsyncKlavis(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.sentry_oauth.authorizesentry_oauth(
                instance_id="instance_id",
                redirect_url="redirect_url",
                force_refresh=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.authorizesentry_oauth(
            instance_id=instance_id,
            redirect_url=redirect_url,
            force_refresh=force_refresh,
            request_options=request_options,
        )
        return _response.data
