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

import datetime as dt
import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.auth_schema_response import AuthSchemaResponse
from ..types.authorization_response import AuthorizationResponse
from ..types.available_connectors_response import AvailableConnectorsResponse
from ..types.complete_o_auth_response import CompleteOAuthResponse
from ..types.connections_response import ConnectionsResponse
from ..types.connector_info import ConnectorInfo
from ..types.connector_response import ConnectorResponse
from ..types.connector_tools_response import ConnectorToolsResponse
from ..types.credential_health_status import CredentialHealthStatus
from ..types.credential_test_request import CredentialTestRequest
from ..types.credential_test_result import CredentialTestResult
from ..types.delete_connection_response import DeleteConnectionResponse
from ..types.execution_logs_response import ExecutionLogsResponse
from ..types.imap_connection_response import ImapConnectionResponse
from ..types.imap_footer_response import ImapFooterResponse
from ..types.o_auth_credentials_response import OAuthCredentialsResponse
from ..types.rename_connection_response import RenameConnectionResponse
from ..types.toggle_connection_response import ToggleConnectionResponse
from .raw_client import AsyncRawPersonalConnectorsClient, RawPersonalConnectorsClient

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


class PersonalConnectorsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawPersonalConnectorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawPersonalConnectorsClient
        """
        return self._raw_client

    def list_available_connectors(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        q: typing.Optional[str] = None,
        category: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AvailableConnectorsResponse:
        """
        List all available connector types that can be connected.

        Returns all available connector types from the synced catalog.
        When authenticated, shows per-user connection status.

        Parameters
        ----------
        organization_id : typing.Optional[str]
            Organization ID

        q : typing.Optional[str]
            Search by tool_key or display_name

        category : typing.Optional[str]
            Filter by category

        limit : typing.Optional[int]
            Max connectors returned

        offset : typing.Optional[int]
            Pagination offset

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

        Returns
        -------
        AvailableConnectorsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.list_available_connectors()
        """
        _response = self._raw_client.list_available_connectors(
            organization_id=organization_id,
            q=q,
            category=category,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    def get_connector_details(
        self,
        tool_key: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConnectorInfo:
        """
        Get details of a specific connector by tool_key.

        Returns connector information including connection status if authenticated.

        Parameters
        ----------
        tool_key : str

        organization_id : typing.Optional[str]
            Organization ID

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

        Returns
        -------
        ConnectorInfo
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_connector_details(
            tool_key="tool_key",
        )
        """
        _response = self._raw_client.get_connector_details(
            tool_key, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def get_auth_schema(
        self, connector_type: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AuthSchemaResponse:
        """
        Get authentication schema for a connector type.

        Returns the auth type (oauth or credentials) and required fields.

        Parameters
        ----------
        connector_type : str

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

        Returns
        -------
        AuthSchemaResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_auth_schema(
            connector_type="connector_type",
        )
        """
        _response = self._raw_client.get_auth_schema(connector_type, request_options=request_options)
        return _response.data

    def initiate_oauth(
        self,
        *,
        organization_id: str,
        connector_type: str,
        integration_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AuthorizationResponse:
        """
        Initiate authorization flow for a connector.

        For OAuth connectors: starts standard OAuth flow.
        For credential connectors (e.g. IMAP): returns URL to a hosted credentials form.

        Parameters
        ----------
        organization_id : str
            Organization ID

        connector_type : str
            Connector type to authorize

        integration_params : typing.Optional[typing.Dict[str, typing.Any]]
            Optional integration-specific parameters

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

        Returns
        -------
        AuthorizationResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.initiate_oauth(
            organization_id="organization_id",
            connector_type="connector_type",
        )
        """
        _response = self._raw_client.initiate_oauth(
            organization_id=organization_id,
            connector_type=connector_type,
            integration_params=integration_params,
            request_options=request_options,
        )
        return _response.data

    def list_connected_connectors(
        self, *, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ConnectorResponse]:
        """
        List user's connected personal connectors.

        Parameters
        ----------
        organization_id : str
            Organization ID

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

        Returns
        -------
        typing.List[ConnectorResponse]
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.list_connected_connectors(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_connected_connectors(
            organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def get_tool_connections(
        self,
        tool_key: str,
        *,
        organization_id: str,
        application_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConnectionsResponse:
        """
        Get user's connected accounts for a specific tool.

        Parameters
        ----------
        tool_key : str

        organization_id : str
            Organization ID

        application_id : typing.Optional[str]
            Application scope

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

        Returns
        -------
        ConnectionsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_tool_connections(
            tool_key="tool_key",
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_tool_connections(
            tool_key, organization_id=organization_id, application_id=application_id, request_options=request_options
        )
        return _response.data

    def complete_oauth(
        self, *, organization_id: str, state_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CompleteOAuthResponse:
        """
        Complete an OAuth flow by polling the connector service for connection status.

        Parameters
        ----------
        organization_id : str
            Organization ID

        state_token : str
            The OAuth state token (ostate_xxx) returned from /authorize

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

        Returns
        -------
        CompleteOAuthResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.complete_oauth(
            organization_id="organization_id",
            state_token="state_token",
        )
        """
        _response = self._raw_client.complete_oauth(
            organization_id=organization_id, state_token=state_token, request_options=request_options
        )
        return _response.data

    def delete_connection(
        self, credential_id: str, *, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteConnectionResponse:
        """
        Delete a user's connection/credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

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

        Returns
        -------
        DeleteConnectionResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.delete_connection(
            credential_id="credential_id",
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.delete_connection(
            credential_id, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def rename_connection(
        self,
        credential_id: str,
        *,
        organization_id: str,
        credential_name: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RenameConnectionResponse:
        """
        Rename a user's connection/credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

        credential_name : str
            New name for the credential

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

        Returns
        -------
        RenameConnectionResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.rename_connection(
            credential_id="credential_id",
            organization_id="organization_id",
            credential_name="credential_name",
        )
        """
        _response = self._raw_client.rename_connection(
            credential_id,
            organization_id=organization_id,
            credential_name=credential_name,
            request_options=request_options,
        )
        return _response.data

    def toggle_connection_active(
        self,
        credential_id: str,
        *,
        organization_id: str,
        is_active: bool,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ToggleConnectionResponse:
        """
        Enable or disable a personal connector credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

        is_active : bool
            Whether the connection should be active

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

        Returns
        -------
        ToggleConnectionResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.toggle_connection_active(
            credential_id="credential_id",
            organization_id="organization_id",
            is_active=True,
        )
        """
        _response = self._raw_client.toggle_connection_active(
            credential_id, organization_id=organization_id, is_active=is_active, request_options=request_options
        )
        return _response.data

    def connect_imap(
        self,
        *,
        organization_id: str,
        email_address: str,
        password: str,
        imap_host: str,
        smtp_host: str,
        imap_port: typing.Optional[int] = OMIT,
        smtp_port: typing.Optional[int] = OMIT,
        use_ssl: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ImapConnectionResponse:
        """
        Connect IMAP/SMTP email account with username/password authentication.

        Parameters
        ----------
        organization_id : str
            Organization ID

        email_address : str
            Email address

        password : str
            Email password

        imap_host : str
            IMAP server hostname

        smtp_host : str
            SMTP server hostname

        imap_port : typing.Optional[int]
            IMAP port (993 for SSL, 143 for STARTTLS)

        smtp_port : typing.Optional[int]
            SMTP port (465 for SSL, 587 for STARTTLS)

        use_ssl : typing.Optional[bool]
            Use SSL/TLS connection

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

        Returns
        -------
        ImapConnectionResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.connect_imap(
            organization_id="organization_id",
            email_address="email_address",
            password="password",
            imap_host="imap_host",
            smtp_host="smtp_host",
        )
        """
        _response = self._raw_client.connect_imap(
            organization_id=organization_id,
            email_address=email_address,
            password=password,
            imap_host=imap_host,
            smtp_host=smtp_host,
            imap_port=imap_port,
            smtp_port=smtp_port,
            use_ssl=use_ssl,
            request_options=request_options,
        )
        return _response.data

    def set_imap_footer(
        self,
        *,
        organization_id: str,
        footer_html: typing.Optional[str] = OMIT,
        footer_text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ImapFooterResponse:
        """
        Set custom email footer for IMAP account.

        Parameters
        ----------
        organization_id : str
            Organization ID

        footer_html : typing.Optional[str]
            HTML footer content

        footer_text : typing.Optional[str]
            Plain text footer content

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

        Returns
        -------
        ImapFooterResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.set_imap_footer(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.set_imap_footer(
            organization_id=organization_id,
            footer_html=footer_html,
            footer_text=footer_text,
            request_options=request_options,
        )
        return _response.data

    def oauth_proxy_callback(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
        """
        Proxy endpoint for OAuth provider callbacks.

        Forwards all query params server-side so the provider consent screen
        shows our domain, not a third party's.

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.oauth_proxy_callback()
        """
        _response = self._raw_client.oauth_proxy_callback(request_options=request_options)
        return _response.data

    def oauth_proxy_callback_v1personal_connectors_oauth_proxy_get(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Proxy endpoint for OAuth provider callbacks.

        Forwards all query params server-side so the provider consent screen
        shows our domain, not a third party's.

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.oauth_proxy_callback_v1personal_connectors_oauth_proxy_get()
        """
        _response = self._raw_client.oauth_proxy_callback_v1personal_connectors_oauth_proxy_get(
            request_options=request_options
        )
        return _response.data

    def retry_connector(
        self, *, connector: str, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Render a page that lets the user re-initiate a connector authorization.

        Parameters
        ----------
        connector : str
            Connector tool key

        organization_id : str
            Organization ID

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.retry_connector(
            connector="connector",
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.retry_connector(
            connector=connector, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    def oauth_callback(
        self,
        *,
        code: typing.Optional[str] = None,
        state: typing.Optional[str] = None,
        error: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        connected_account_id: typing.Optional[str] = None,
        app_name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Handle OAuth callback from third-party services.

        Parameters
        ----------
        code : typing.Optional[str]
            OAuth authorization code

        state : typing.Optional[str]
            OAuth state token

        error : typing.Optional[str]
            OAuth error parameter

        status : typing.Optional[str]
            Connection status

        connected_account_id : typing.Optional[str]
            Connected account ID

        app_name : typing.Optional[str]
            Connected app name

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.oauth_callback()
        """
        _response = self._raw_client.oauth_callback(
            code=code,
            state=state,
            error=error,
            status=status,
            connected_account_id=connected_account_id,
            app_name=app_name,
            request_options=request_options,
        )
        return _response.data

    def credentials_form_page(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Render hosted credentials form for non-OAuth connectors.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.credentials_form_page(
            state_token="state_token",
        )
        """
        _response = self._raw_client.credentials_form_page(state_token, request_options=request_options)
        return _response.data

    def credentials_form_submit(
        self,
        state_token: str,
        *,
        test_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Handle credential form submission (test or save).

        Parameters
        ----------
        state_token : str

        test_only : typing.Optional[bool]
            Only test, don't save

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

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

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.credentials_form_submit(
            state_token="state_token",
        )
        """
        _response = self._raw_client.credentials_form_submit(
            state_token, test_only=test_only, request_options=request_options
        )
        return _response.data

    def pre_oauth_form_page(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Render a hosted form for connectors that need fields before OAuth.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.pre_oauth_form_page(
            state_token="state_token",
        )
        """
        _response = self._raw_client.pre_oauth_form_page(state_token, request_options=request_options)
        return _response.data

    def pre_oauth_form_submit(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Handle pre-OAuth form submission.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.pre_oauth_form_submit(
            state_token="state_token",
        )
        """
        _response = self._raw_client.pre_oauth_form_submit(state_token, request_options=request_options)
        return _response.data

    def redirect_to_auth(
        self, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Redirect to the actual OAuth authorization URL.

        Supports both state_token (ostate_*) and connection_id lookups.

        Parameters
        ----------
        connection_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.redirect_to_auth(
            connection_id="connection_id",
        )
        """
        _response = self._raw_client.redirect_to_auth(connection_id, request_options=request_options)
        return _response.data

    def list_execution_logs(
        self,
        *,
        organization_id: str,
        credential_id: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        start_date: typing.Optional[dt.datetime] = None,
        end_date: typing.Optional[dt.datetime] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExecutionLogsResponse:
        """
        List tool execution logs for the authenticated user.

        Parameters
        ----------
        organization_id : str
            Organization ID

        credential_id : typing.Optional[str]
            Filter by credential ID

        status : typing.Optional[str]
            Filter by status

        start_date : typing.Optional[dt.datetime]
            Filter logs from this date

        end_date : typing.Optional[dt.datetime]
            Filter logs until this date

        limit : typing.Optional[int]
            Max logs to return

        offset : typing.Optional[int]
            Pagination offset

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

        Returns
        -------
        ExecutionLogsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.list_execution_logs(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_execution_logs(
            organization_id=organization_id,
            credential_id=credential_id,
            status=status,
            start_date=start_date,
            end_date=end_date,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    def get_connector_credentials(
        self,
        credential_id: str,
        *,
        flowplate_key: typing.Optional[str] = None,
        aitronos_hub_key: typing.Optional[str] = None,
        api_key: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OAuthCredentialsResponse:
        """
        Get OAuth credentials for a connector credential (admin only).

        Parameters
        ----------
        credential_id : str

        flowplate_key : typing.Optional[str]
            Flowplate Master API Key

        aitronos_hub_key : typing.Optional[str]
            Aitronos Hub Master API Key

        api_key : typing.Optional[str]
            Pipeline Connector API Key

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

        Returns
        -------
        OAuthCredentialsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_connector_credentials(
            credential_id="credential_id",
        )
        """
        _response = self._raw_client.get_connector_credentials(
            credential_id,
            flowplate_key=flowplate_key,
            aitronos_hub_key=aitronos_hub_key,
            api_key=api_key,
            request_options=request_options,
        )
        return _response.data

    def get_credentials_by_connection_id(
        self,
        connection_id: str,
        *,
        flowplate_key: typing.Optional[str] = None,
        aitronos_hub_key: typing.Optional[str] = None,
        api_key: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OAuthCredentialsResponse:
        """
        Get OAuth credentials directly by connector connection ID (admin only).

        Parameters
        ----------
        connection_id : str

        flowplate_key : typing.Optional[str]
            Flowplate Master API Key

        aitronos_hub_key : typing.Optional[str]
            Aitronos Hub Master API Key

        api_key : typing.Optional[str]
            Pipeline Connector API Key

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

        Returns
        -------
        OAuthCredentialsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_credentials_by_connection_id(
            connection_id="connection_id",
        )
        """
        _response = self._raw_client.get_credentials_by_connection_id(
            connection_id,
            flowplate_key=flowplate_key,
            aitronos_hub_key=aitronos_hub_key,
            api_key=api_key,
            request_options=request_options,
        )
        return _response.data

    def check_credential_health(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CredentialHealthStatus:
        """
        Check the health status of a credential.

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        CredentialHealthStatus
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.check_credential_health(
            credential_id="credential_id",
        )
        """
        _response = self._raw_client.check_credential_health(credential_id, request_options=request_options)
        return _response.data

    def test_credential(
        self,
        credential_id: str,
        *,
        request: typing.Optional[CredentialTestRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CredentialTestResult:
        """
        Test a credential by executing a controlled read-only action.

        Parameters
        ----------
        credential_id : str

        request : typing.Optional[CredentialTestRequest]

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

        Returns
        -------
        CredentialTestResult
            Successful Response

        Examples
        --------
        from aitronos import Aitronos, CredentialTestRequest

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.test_credential(
            credential_id="credential_id",
            request=CredentialTestRequest(),
        )
        """
        _response = self._raw_client.test_credential(credential_id, request=request, request_options=request_options)
        return _response.data

    def disconnect_connector(
        self, connector_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Disconnect a personal connector (soft delete).

        Parameters
        ----------
        connector_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.disconnect_connector(
            connector_id="connector_id",
        )
        """
        _response = self._raw_client.disconnect_connector(connector_id, request_options=request_options)
        return _response.data

    def update_connector(
        self, connector_id: str, *, is_active: bool, request_options: typing.Optional[RequestOptions] = None
    ) -> ConnectorResponse:
        """
        Update a personal connector's status (enable/disable).

        Parameters
        ----------
        connector_id : str

        is_active : bool
            Whether connector should be active

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

        Returns
        -------
        ConnectorResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.update_connector(
            connector_id="connector_id",
            is_active=True,
        )
        """
        _response = self._raw_client.update_connector(
            connector_id, is_active=is_active, request_options=request_options
        )
        return _response.data

    def list_connector_tools(
        self, connector_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConnectorToolsResponse:
        """
        List available tools for a personal connector.

        Parameters
        ----------
        connector_id : str

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

        Returns
        -------
        ConnectorToolsResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.list_connector_tools(
            connector_id="connector_id",
        )
        """
        _response = self._raw_client.list_connector_tools(connector_id, request_options=request_options)
        return _response.data

    def update_connector_tools(
        self,
        connector_id: str,
        *,
        enabled: bool,
        allowed_tools: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Update tool configuration for a personal connector.

        Parameters
        ----------
        connector_id : str

        enabled : bool
            Enable/disable all tools

        allowed_tools : typing.Optional[typing.Sequence[str]]
            List of allowed tool names (None = all allowed)

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

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

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.update_connector_tools(
            connector_id="connector_id",
            enabled=True,
        )
        """
        _response = self._raw_client.update_connector_tools(
            connector_id, enabled=enabled, allowed_tools=allowed_tools, request_options=request_options
        )
        return _response.data

    def disconnect_connector_credential(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Disconnect a connector credential (soft delete).

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.disconnect_connector_credential(
            credential_id="credential_id",
        )
        """
        _response = self._raw_client.disconnect_connector_credential(credential_id, request_options=request_options)
        return _response.data

    def list_credential_actions(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        List available actions for a connected tool credential.

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.list_credential_actions(
            credential_id="credential_id",
        )
        """
        _response = self._raw_client.list_credential_actions(credential_id, request_options=request_options)
        return _response.data

    def get_connector_comments(
        self,
        connector: str,
        item_id: str,
        *,
        limit: typing.Optional[int] = None,
        owner: typing.Optional[str] = None,
        repo: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Fetch comments for a connector item.

        Parameters
        ----------
        connector : str

        item_id : str

        limit : typing.Optional[int]
            Max comments to return

        owner : typing.Optional[str]
            Repository owner (required for GitHub)

        repo : typing.Optional[str]
            Repository name (required for GitHub)

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

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

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.get_connector_comments(
            connector="connector",
            item_id="item_id",
        )
        """
        _response = self._raw_client.get_connector_comments(
            connector, item_id, limit=limit, owner=owner, repo=repo, request_options=request_options
        )
        return _response.data

    def add_connector_comment(
        self,
        connector: str,
        item_id: str,
        *,
        text: str,
        owner: typing.Optional[str] = None,
        repo: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Add a comment/reply to a connector item (issue, task, ticket).

        Parameters
        ----------
        connector : str

        item_id : str

        text : str
            Comment body text

        owner : typing.Optional[str]
            Repository owner (required for GitHub)

        repo : typing.Optional[str]
            Repository name (required for GitHub)

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

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

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.personal_connectors.add_connector_comment(
            connector="connector",
            item_id="item_id",
            text="text",
        )
        """
        _response = self._raw_client.add_connector_comment(
            connector, item_id, text=text, owner=owner, repo=repo, request_options=request_options
        )
        return _response.data


class AsyncPersonalConnectorsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawPersonalConnectorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawPersonalConnectorsClient
        """
        return self._raw_client

    async def list_available_connectors(
        self,
        *,
        organization_id: typing.Optional[str] = None,
        q: typing.Optional[str] = None,
        category: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AvailableConnectorsResponse:
        """
        List all available connector types that can be connected.

        Returns all available connector types from the synced catalog.
        When authenticated, shows per-user connection status.

        Parameters
        ----------
        organization_id : typing.Optional[str]
            Organization ID

        q : typing.Optional[str]
            Search by tool_key or display_name

        category : typing.Optional[str]
            Filter by category

        limit : typing.Optional[int]
            Max connectors returned

        offset : typing.Optional[int]
            Pagination offset

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

        Returns
        -------
        AvailableConnectorsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.list_available_connectors()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_available_connectors(
            organization_id=organization_id,
            q=q,
            category=category,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    async def get_connector_details(
        self,
        tool_key: str,
        *,
        organization_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConnectorInfo:
        """
        Get details of a specific connector by tool_key.

        Returns connector information including connection status if authenticated.

        Parameters
        ----------
        tool_key : str

        organization_id : typing.Optional[str]
            Organization ID

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

        Returns
        -------
        ConnectorInfo
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_connector_details(
                tool_key="tool_key",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_connector_details(
            tool_key, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    async def get_auth_schema(
        self, connector_type: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AuthSchemaResponse:
        """
        Get authentication schema for a connector type.

        Returns the auth type (oauth or credentials) and required fields.

        Parameters
        ----------
        connector_type : str

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

        Returns
        -------
        AuthSchemaResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_auth_schema(
                connector_type="connector_type",
            )


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

    async def initiate_oauth(
        self,
        *,
        organization_id: str,
        connector_type: str,
        integration_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AuthorizationResponse:
        """
        Initiate authorization flow for a connector.

        For OAuth connectors: starts standard OAuth flow.
        For credential connectors (e.g. IMAP): returns URL to a hosted credentials form.

        Parameters
        ----------
        organization_id : str
            Organization ID

        connector_type : str
            Connector type to authorize

        integration_params : typing.Optional[typing.Dict[str, typing.Any]]
            Optional integration-specific parameters

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

        Returns
        -------
        AuthorizationResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.initiate_oauth(
                organization_id="organization_id",
                connector_type="connector_type",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.initiate_oauth(
            organization_id=organization_id,
            connector_type=connector_type,
            integration_params=integration_params,
            request_options=request_options,
        )
        return _response.data

    async def list_connected_connectors(
        self, *, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[ConnectorResponse]:
        """
        List user's connected personal connectors.

        Parameters
        ----------
        organization_id : str
            Organization ID

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

        Returns
        -------
        typing.List[ConnectorResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.list_connected_connectors(
                organization_id="organization_id",
            )


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

    async def get_tool_connections(
        self,
        tool_key: str,
        *,
        organization_id: str,
        application_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConnectionsResponse:
        """
        Get user's connected accounts for a specific tool.

        Parameters
        ----------
        tool_key : str

        organization_id : str
            Organization ID

        application_id : typing.Optional[str]
            Application scope

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

        Returns
        -------
        ConnectionsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_tool_connections(
                tool_key="tool_key",
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_tool_connections(
            tool_key, organization_id=organization_id, application_id=application_id, request_options=request_options
        )
        return _response.data

    async def complete_oauth(
        self, *, organization_id: str, state_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> CompleteOAuthResponse:
        """
        Complete an OAuth flow by polling the connector service for connection status.

        Parameters
        ----------
        organization_id : str
            Organization ID

        state_token : str
            The OAuth state token (ostate_xxx) returned from /authorize

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

        Returns
        -------
        CompleteOAuthResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.complete_oauth(
                organization_id="organization_id",
                state_token="state_token",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.complete_oauth(
            organization_id=organization_id, state_token=state_token, request_options=request_options
        )
        return _response.data

    async def delete_connection(
        self, credential_id: str, *, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteConnectionResponse:
        """
        Delete a user's connection/credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

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

        Returns
        -------
        DeleteConnectionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.delete_connection(
                credential_id="credential_id",
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_connection(
            credential_id, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    async def rename_connection(
        self,
        credential_id: str,
        *,
        organization_id: str,
        credential_name: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RenameConnectionResponse:
        """
        Rename a user's connection/credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

        credential_name : str
            New name for the credential

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

        Returns
        -------
        RenameConnectionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.rename_connection(
                credential_id="credential_id",
                organization_id="organization_id",
                credential_name="credential_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.rename_connection(
            credential_id,
            organization_id=organization_id,
            credential_name=credential_name,
            request_options=request_options,
        )
        return _response.data

    async def toggle_connection_active(
        self,
        credential_id: str,
        *,
        organization_id: str,
        is_active: bool,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ToggleConnectionResponse:
        """
        Enable or disable a personal connector credential.

        Parameters
        ----------
        credential_id : str

        organization_id : str
            Organization ID

        is_active : bool
            Whether the connection should be active

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

        Returns
        -------
        ToggleConnectionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.toggle_connection_active(
                credential_id="credential_id",
                organization_id="organization_id",
                is_active=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.toggle_connection_active(
            credential_id, organization_id=organization_id, is_active=is_active, request_options=request_options
        )
        return _response.data

    async def connect_imap(
        self,
        *,
        organization_id: str,
        email_address: str,
        password: str,
        imap_host: str,
        smtp_host: str,
        imap_port: typing.Optional[int] = OMIT,
        smtp_port: typing.Optional[int] = OMIT,
        use_ssl: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ImapConnectionResponse:
        """
        Connect IMAP/SMTP email account with username/password authentication.

        Parameters
        ----------
        organization_id : str
            Organization ID

        email_address : str
            Email address

        password : str
            Email password

        imap_host : str
            IMAP server hostname

        smtp_host : str
            SMTP server hostname

        imap_port : typing.Optional[int]
            IMAP port (993 for SSL, 143 for STARTTLS)

        smtp_port : typing.Optional[int]
            SMTP port (465 for SSL, 587 for STARTTLS)

        use_ssl : typing.Optional[bool]
            Use SSL/TLS connection

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

        Returns
        -------
        ImapConnectionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.connect_imap(
                organization_id="organization_id",
                email_address="email_address",
                password="password",
                imap_host="imap_host",
                smtp_host="smtp_host",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.connect_imap(
            organization_id=organization_id,
            email_address=email_address,
            password=password,
            imap_host=imap_host,
            smtp_host=smtp_host,
            imap_port=imap_port,
            smtp_port=smtp_port,
            use_ssl=use_ssl,
            request_options=request_options,
        )
        return _response.data

    async def set_imap_footer(
        self,
        *,
        organization_id: str,
        footer_html: typing.Optional[str] = OMIT,
        footer_text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ImapFooterResponse:
        """
        Set custom email footer for IMAP account.

        Parameters
        ----------
        organization_id : str
            Organization ID

        footer_html : typing.Optional[str]
            HTML footer content

        footer_text : typing.Optional[str]
            Plain text footer content

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

        Returns
        -------
        ImapFooterResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.set_imap_footer(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.set_imap_footer(
            organization_id=organization_id,
            footer_html=footer_html,
            footer_text=footer_text,
            request_options=request_options,
        )
        return _response.data

    async def oauth_proxy_callback(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
        """
        Proxy endpoint for OAuth provider callbacks.

        Forwards all query params server-side so the provider consent screen
        shows our domain, not a third party's.

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.oauth_proxy_callback()


        asyncio.run(main())
        """
        _response = await self._raw_client.oauth_proxy_callback(request_options=request_options)
        return _response.data

    async def oauth_proxy_callback_v1personal_connectors_oauth_proxy_get(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Proxy endpoint for OAuth provider callbacks.

        Forwards all query params server-side so the provider consent screen
        shows our domain, not a third party's.

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.oauth_proxy_callback_v1personal_connectors_oauth_proxy_get()


        asyncio.run(main())
        """
        _response = await self._raw_client.oauth_proxy_callback_v1personal_connectors_oauth_proxy_get(
            request_options=request_options
        )
        return _response.data

    async def retry_connector(
        self, *, connector: str, organization_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Render a page that lets the user re-initiate a connector authorization.

        Parameters
        ----------
        connector : str
            Connector tool key

        organization_id : str
            Organization ID

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.retry_connector(
                connector="connector",
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.retry_connector(
            connector=connector, organization_id=organization_id, request_options=request_options
        )
        return _response.data

    async def oauth_callback(
        self,
        *,
        code: typing.Optional[str] = None,
        state: typing.Optional[str] = None,
        error: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        connected_account_id: typing.Optional[str] = None,
        app_name: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Handle OAuth callback from third-party services.

        Parameters
        ----------
        code : typing.Optional[str]
            OAuth authorization code

        state : typing.Optional[str]
            OAuth state token

        error : typing.Optional[str]
            OAuth error parameter

        status : typing.Optional[str]
            Connection status

        connected_account_id : typing.Optional[str]
            Connected account ID

        app_name : typing.Optional[str]
            Connected app name

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.oauth_callback()


        asyncio.run(main())
        """
        _response = await self._raw_client.oauth_callback(
            code=code,
            state=state,
            error=error,
            status=status,
            connected_account_id=connected_account_id,
            app_name=app_name,
            request_options=request_options,
        )
        return _response.data

    async def credentials_form_page(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Render hosted credentials form for non-OAuth connectors.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.credentials_form_page(
                state_token="state_token",
            )


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

    async def credentials_form_submit(
        self,
        state_token: str,
        *,
        test_only: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Handle credential form submission (test or save).

        Parameters
        ----------
        state_token : str

        test_only : typing.Optional[bool]
            Only test, don't save

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

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

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.credentials_form_submit(
                state_token="state_token",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.credentials_form_submit(
            state_token, test_only=test_only, request_options=request_options
        )
        return _response.data

    async def pre_oauth_form_page(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Render a hosted form for connectors that need fields before OAuth.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.pre_oauth_form_page(
                state_token="state_token",
            )


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

    async def pre_oauth_form_submit(
        self, state_token: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Handle pre-OAuth form submission.

        Parameters
        ----------
        state_token : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.pre_oauth_form_submit(
                state_token="state_token",
            )


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

    async def redirect_to_auth(
        self, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Redirect to the actual OAuth authorization URL.

        Supports both state_token (ostate_*) and connection_id lookups.

        Parameters
        ----------
        connection_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.redirect_to_auth(
                connection_id="connection_id",
            )


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

    async def list_execution_logs(
        self,
        *,
        organization_id: str,
        credential_id: typing.Optional[str] = None,
        status: typing.Optional[str] = None,
        start_date: typing.Optional[dt.datetime] = None,
        end_date: typing.Optional[dt.datetime] = None,
        limit: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExecutionLogsResponse:
        """
        List tool execution logs for the authenticated user.

        Parameters
        ----------
        organization_id : str
            Organization ID

        credential_id : typing.Optional[str]
            Filter by credential ID

        status : typing.Optional[str]
            Filter by status

        start_date : typing.Optional[dt.datetime]
            Filter logs from this date

        end_date : typing.Optional[dt.datetime]
            Filter logs until this date

        limit : typing.Optional[int]
            Max logs to return

        offset : typing.Optional[int]
            Pagination offset

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

        Returns
        -------
        ExecutionLogsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.list_execution_logs(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_execution_logs(
            organization_id=organization_id,
            credential_id=credential_id,
            status=status,
            start_date=start_date,
            end_date=end_date,
            limit=limit,
            offset=offset,
            request_options=request_options,
        )
        return _response.data

    async def get_connector_credentials(
        self,
        credential_id: str,
        *,
        flowplate_key: typing.Optional[str] = None,
        aitronos_hub_key: typing.Optional[str] = None,
        api_key: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OAuthCredentialsResponse:
        """
        Get OAuth credentials for a connector credential (admin only).

        Parameters
        ----------
        credential_id : str

        flowplate_key : typing.Optional[str]
            Flowplate Master API Key

        aitronos_hub_key : typing.Optional[str]
            Aitronos Hub Master API Key

        api_key : typing.Optional[str]
            Pipeline Connector API Key

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

        Returns
        -------
        OAuthCredentialsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_connector_credentials(
                credential_id="credential_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_connector_credentials(
            credential_id,
            flowplate_key=flowplate_key,
            aitronos_hub_key=aitronos_hub_key,
            api_key=api_key,
            request_options=request_options,
        )
        return _response.data

    async def get_credentials_by_connection_id(
        self,
        connection_id: str,
        *,
        flowplate_key: typing.Optional[str] = None,
        aitronos_hub_key: typing.Optional[str] = None,
        api_key: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OAuthCredentialsResponse:
        """
        Get OAuth credentials directly by connector connection ID (admin only).

        Parameters
        ----------
        connection_id : str

        flowplate_key : typing.Optional[str]
            Flowplate Master API Key

        aitronos_hub_key : typing.Optional[str]
            Aitronos Hub Master API Key

        api_key : typing.Optional[str]
            Pipeline Connector API Key

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

        Returns
        -------
        OAuthCredentialsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_credentials_by_connection_id(
                connection_id="connection_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_credentials_by_connection_id(
            connection_id,
            flowplate_key=flowplate_key,
            aitronos_hub_key=aitronos_hub_key,
            api_key=api_key,
            request_options=request_options,
        )
        return _response.data

    async def check_credential_health(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> CredentialHealthStatus:
        """
        Check the health status of a credential.

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        CredentialHealthStatus
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.check_credential_health(
                credential_id="credential_id",
            )


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

    async def test_credential(
        self,
        credential_id: str,
        *,
        request: typing.Optional[CredentialTestRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CredentialTestResult:
        """
        Test a credential by executing a controlled read-only action.

        Parameters
        ----------
        credential_id : str

        request : typing.Optional[CredentialTestRequest]

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

        Returns
        -------
        CredentialTestResult
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos, CredentialTestRequest

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.test_credential(
                credential_id="credential_id",
                request=CredentialTestRequest(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.test_credential(
            credential_id, request=request, request_options=request_options
        )
        return _response.data

    async def disconnect_connector(
        self, connector_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Disconnect a personal connector (soft delete).

        Parameters
        ----------
        connector_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.disconnect_connector(
                connector_id="connector_id",
            )


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

    async def update_connector(
        self, connector_id: str, *, is_active: bool, request_options: typing.Optional[RequestOptions] = None
    ) -> ConnectorResponse:
        """
        Update a personal connector's status (enable/disable).

        Parameters
        ----------
        connector_id : str

        is_active : bool
            Whether connector should be active

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

        Returns
        -------
        ConnectorResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.update_connector(
                connector_id="connector_id",
                is_active=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_connector(
            connector_id, is_active=is_active, request_options=request_options
        )
        return _response.data

    async def list_connector_tools(
        self, connector_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConnectorToolsResponse:
        """
        List available tools for a personal connector.

        Parameters
        ----------
        connector_id : str

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

        Returns
        -------
        ConnectorToolsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.list_connector_tools(
                connector_id="connector_id",
            )


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

    async def update_connector_tools(
        self,
        connector_id: str,
        *,
        enabled: bool,
        allowed_tools: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Update tool configuration for a personal connector.

        Parameters
        ----------
        connector_id : str

        enabled : bool
            Enable/disable all tools

        allowed_tools : typing.Optional[typing.Sequence[str]]
            List of allowed tool names (None = all allowed)

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

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

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.update_connector_tools(
                connector_id="connector_id",
                enabled=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_connector_tools(
            connector_id, enabled=enabled, allowed_tools=allowed_tools, request_options=request_options
        )
        return _response.data

    async def disconnect_connector_credential(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Disconnect a connector credential (soft delete).

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.disconnect_connector_credential(
                credential_id="credential_id",
            )


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

    async def list_credential_actions(
        self, credential_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        List available actions for a connected tool credential.

        Parameters
        ----------
        credential_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.list_credential_actions(
                credential_id="credential_id",
            )


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

    async def get_connector_comments(
        self,
        connector: str,
        item_id: str,
        *,
        limit: typing.Optional[int] = None,
        owner: typing.Optional[str] = None,
        repo: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Fetch comments for a connector item.

        Parameters
        ----------
        connector : str

        item_id : str

        limit : typing.Optional[int]
            Max comments to return

        owner : typing.Optional[str]
            Repository owner (required for GitHub)

        repo : typing.Optional[str]
            Repository name (required for GitHub)

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

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

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.get_connector_comments(
                connector="connector",
                item_id="item_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_connector_comments(
            connector, item_id, limit=limit, owner=owner, repo=repo, request_options=request_options
        )
        return _response.data

    async def add_connector_comment(
        self,
        connector: str,
        item_id: str,
        *,
        text: str,
        owner: typing.Optional[str] = None,
        repo: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Add a comment/reply to a connector item (issue, task, ticket).

        Parameters
        ----------
        connector : str

        item_id : str

        text : str
            Comment body text

        owner : typing.Optional[str]
            Repository owner (required for GitHub)

        repo : typing.Optional[str]
            Repository name (required for GitHub)

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

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

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.personal_connectors.add_connector_comment(
                connector="connector",
                item_id="item_id",
                text="text",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_connector_comment(
            connector, item_id, text=text, owner=owner, repo=repo, request_options=request_options
        )
        return _response.data
