o
    iUT                     @   s   d dl Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZ e e jdZG dd dZG dd dZdS )    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions)CreateConnectorOAuth)CreateConnectorResponse)CreateConnectorServiceAuth)DeleteConnectorResponse)GetConnectorResponse)ListConnectorsResponse)OAuthAuthorizeResponse)UpdateConnectorResponse   )AsyncRawConnectorsClientRawConnectorsClient.c                   @     e Zd ZdefddZedefddZddddd	ej	e
 d
ej	e
 dej	e defddZeeeeeedddededej	e dej	eje  dej	e dej	e dej	e dej	e dej	e defddZdddedej	e defddZdddedej	e defddZeeeeeeedddedej	e dej	e dej	eje  dej	e dej	e dej	e dej	e dej	e defd d!Zddd"ded#ej	e dej	e defd$d%ZdS )&ConnectorsClientclient_wrapperc                C      t |d| _d S N)r   )r   _raw_clientselfr    r   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/cohere/connectors/client.py__init__      zConnectorsClient.__init__returnc                 C      | j S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawConnectorsClient
        r   r   r   r   r   with_raw_response      	z"ConnectorsClient.with_raw_responseNlimitoffsetrequest_optionsr$   r%   r&   c                C      | j j|||d}|jS )aY  
        Returns a list of connectors ordered by descending creation date (newer first). See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.

        Parameters
        ----------
        limit : typing.Optional[float]
            Maximum number of connectors to return [0, 100].

        offset : typing.Optional[float]
            Number of connectors to skip before returning results [0, inf].

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

        Returns
        -------
        ListConnectorsResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.list()
        r#   r   listdatar   r$   r%   r&   	_responser   r   r   r)   $   s   $zConnectorsClient.listdescriptionexcludesoauthactivecontinue_on_failureservice_authr&   nameurlr.   r/   r0   r1   r2   r3   c       	         C   $   | j j|||||||||	d	}
|
jS )a  
        Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See ['Creating and Deploying a Connector'](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) for more information.

        Parameters
        ----------
        name : str
            A human-readable name for the connector.

        url : str
            The URL of the connector that will be used to search for documents.

        description : typing.Optional[str]
            A description of the connector.

        excludes : typing.Optional[typing.Sequence[str]]
            A list of fields to exclude from the prompt (fields remain in the document).

        oauth : typing.Optional[CreateConnectorOAuth]
            The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

        active : typing.Optional[bool]
            Whether the connector is active or not.

        continue_on_failure : typing.Optional[bool]
            Whether a chat request should continue or not if the request to this connector fails.

        service_auth : typing.Optional[CreateConnectorServiceAuth]
            The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

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

        Returns
        -------
        CreateConnectorResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.create(
            name="name",
            url="url",
        )
        	r4   r5   r.   r/   r0   r1   r2   r3   r&   r   creater*   r   r4   r5   r.   r/   r0   r1   r2   r3   r&   r,   r   r   r   r9   K   s   ?zConnectorsClient.creater&   idc                C      | j j||d}|jS )a  
        Retrieve a connector by ID. See ['Connectors'](https://docs.cohere.com/docs/connectors) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to retrieve.

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

        Returns
        -------
        GetConnectorResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.get(
            id="id",
        )
        r;   r   getr*   r   r<   r&   r,   r   r   r   r?         zConnectorsClient.getc                C   r=   )a  
        Delete a connector by ID. See ['Connectors'](https://docs.cohere.com/docs/connectors) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to delete.

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

        Returns
        -------
        DeleteConnectorResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.delete(
            id="id",
        )
        r;   r   deleter*   r@   r   r   r   rC      rA   zConnectorsClient.deleter4   r5   r/   r0   r1   r2   r3   r&   c                C   r6   )a  
        Update a connector by ID. Omitted fields will not be updated. See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to update.

        name : typing.Optional[str]
            A human-readable name for the connector.

        url : typing.Optional[str]
            The URL of the connector that will be used to search for documents.

        excludes : typing.Optional[typing.Sequence[str]]
            A list of fields to exclude from the prompt (fields remain in the document).

        oauth : typing.Optional[CreateConnectorOAuth]
            The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

        active : typing.Optional[bool]

        continue_on_failure : typing.Optional[bool]

        service_auth : typing.Optional[CreateConnectorServiceAuth]
            The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

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

        Returns
        -------
        UpdateConnectorResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.update(
            id="id",
        )
        rD   r   updater*   r   r<   r4   r5   r/   r0   r1   r2   r3   r&   r,   r   r   r   rF      s   <zConnectorsClient.updateafter_token_redirectr&   rI   c                C   r'   )ah  
        Authorize the connector with the given ID for the connector oauth app.  See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to authorize.

        after_token_redirect : typing.Optional[str]
            The URL to redirect to after the connector has been authorized.

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

        Returns
        -------
        OAuthAuthorizeResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.connectors.o_auth_authorize(
            id="id",
        )
        rH   r   o_auth_authorizer*   r   r<   rI   r&   r,   r   r   r   rK      s   &z!ConnectorsClient.o_auth_authorize)__name__
__module____qualname__r   r   propertyr   r!   typingOptionalfloatr   r   r)   OMITstrSequencer   boolr   r   r9   r
   r?   r	   rC   r   rF   r   rK   r   r   r   r   r      s    
,	

"L" $	

Mr   c                   @   r   )&AsyncConnectorsClientr   c                C   r   r   )r   r   r   r   r   r   r   M  r   zAsyncConnectorsClient.__init__r   c                 C   r   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawConnectorsClient
        r   r    r   r   r   r!   P  r"   z'AsyncConnectorsClient.with_raw_responseNr#   r$   r%   r&   c                       | j j|||dI dH }|jS )a  
        Returns a list of connectors ordered by descending creation date (newer first). See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.

        Parameters
        ----------
        limit : typing.Optional[float]
            Maximum number of connectors to return [0, 100].

        offset : typing.Optional[float]
            Number of connectors to skip before returning results [0, inf].

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

        Returns
        -------
        ListConnectorsResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


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


        asyncio.run(main())
        r#   Nr(   r+   r   r   r   r)   [  s   ,zAsyncConnectorsClient.listr-   r4   r5   r.   r/   r0   r1   r2   r3   c       	            ,   | j j|||||||||	d	I dH }
|
jS )ao  
        Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See ['Creating and Deploying a Connector'](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) for more information.

        Parameters
        ----------
        name : str
            A human-readable name for the connector.

        url : str
            The URL of the connector that will be used to search for documents.

        description : typing.Optional[str]
            A description of the connector.

        excludes : typing.Optional[typing.Sequence[str]]
            A list of fields to exclude from the prompt (fields remain in the document).

        oauth : typing.Optional[CreateConnectorOAuth]
            The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

        active : typing.Optional[bool]
            Whether the connector is active or not.

        continue_on_failure : typing.Optional[bool]
            Whether a chat request should continue or not if the request to this connector fails.

        service_auth : typing.Optional[CreateConnectorServiceAuth]
            The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

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

        Returns
        -------
        CreateConnectorResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.connectors.create(
                name="name",
                url="url",
            )


        asyncio.run(main())
        r7   Nr8   r:   r   r   r   r9     s   GzAsyncConnectorsClient.creater;   r<   c                      | j j||dI dH }|jS )a  
        Retrieve a connector by ID. See ['Connectors'](https://docs.cohere.com/docs/connectors) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to retrieve.

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

        Returns
        -------
        GetConnectorResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.connectors.get(
                id="id",
            )


        asyncio.run(main())
        r;   Nr>   r@   r   r   r   r?     s   %zAsyncConnectorsClient.getc                   r[   )a  
        Delete a connector by ID. See ['Connectors'](https://docs.cohere.com/docs/connectors) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to delete.

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

        Returns
        -------
        DeleteConnectorResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.connectors.delete(
                id="id",
            )


        asyncio.run(main())
        r;   NrB   r@   r   r   r   rC     s   'zAsyncConnectorsClient.deleterD   c                   rZ   )ai  
        Update a connector by ID. Omitted fields will not be updated. See ['Managing your Connector'](https://docs.cohere.com/docs/managing-your-connector) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to update.

        name : typing.Optional[str]
            A human-readable name for the connector.

        url : typing.Optional[str]
            The URL of the connector that will be used to search for documents.

        excludes : typing.Optional[typing.Sequence[str]]
            A list of fields to exclude from the prompt (fields remain in the document).

        oauth : typing.Optional[CreateConnectorOAuth]
            The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.

        active : typing.Optional[bool]

        continue_on_failure : typing.Optional[bool]

        service_auth : typing.Optional[CreateConnectorServiceAuth]
            The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.

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

        Returns
        -------
        UpdateConnectorResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.connectors.update(
                id="id",
            )


        asyncio.run(main())
        rD   NrE   rG   r   r   r   rF   0  s   DzAsyncConnectorsClient.updaterH   rI   c                   rY   )a  
        Authorize the connector with the given ID for the connector oauth app.  See ['Connector Authentication'](https://docs.cohere.com/docs/connector-authentication) for more information.

        Parameters
        ----------
        id : str
            The ID of the connector to authorize.

        after_token_redirect : typing.Optional[str]
            The URL to redirect to after the connector has been authorized.

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

        Returns
        -------
        OAuthAuthorizeResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.connectors.o_auth_authorize(
                id="id",
            )


        asyncio.run(main())
        rH   NrJ   rL   r   r   r   rK     s
   .z&AsyncConnectorsClient.o_auth_authorize)rM   rN   rO   r   r   rP   r   r!   rQ   rR   rS   r   r   r)   rT   rU   rV   r   rW   r   r   r9   r
   r?   r	   rC   r   rF   r   rK   r   r   r   r   rX   L  s    
4	

"T)
.	

UrX   )rQ   core.client_wrapperr   r   core.request_optionsr   types.create_connector_o_authr   types.create_connector_responser   #types.create_connector_service_authr   types.delete_connector_responser	   types.get_connector_responser
   types.list_connectors_responser   types.o_auth_authorize_responser   types.update_connector_responser   
raw_clientr   r   castAnyrT   r   rX   r   r   r   r   <module>   s"     9