
    ]j'                         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mZ  e j"                  e j$                  d      Z G d d      Z G d d      Zy)    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions)LseapiTokenCreate)LseapiTokenList)TokenRefreshResponse)TokenRotateResponse   )AsyncRawTokensClientRawTokensClient.c            	          e Zd ZdefdZedefd       Zddddej                  e
   dej                  e   dej                  e   fd	Zdd
dej                  e   defdZdd
de
dej                  e   dej"                  e
ej$                  f   fdZdd
de
dej                  e   defdZdd
de
dej                  e   defdZy)TokensClientclient_wrapperc                &    t        |      | _        y N)r   )r   _raw_clientselfr   s     H/root/env/lib/python3.12/site-packages/label_studio_sdk/tokens/client.py__init__zTokensClient.__init__   s    *.I    returnc                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawTokensClient
        r   r   s    r   with_raw_responsezTokensClient.with_raw_response        r   Norderingrequest_optionsr    r!   c                T    | j                   j                  ||      }|j                  S )a0  
        List all API tokens for the current user.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[LseapiTokenList]


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.tokens.list()
        r   r   listdatar   r    r!   	_responses       r   r$   zTokensClient.list    s)    8 $$))8_)]	~~r   r!   c                R    | j                   j                  |      }|j                  S )a  
        Create a new API token for the current user.

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

        Returns
        -------
        LseapiTokenCreate


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.tokens.create()
        r(   r   creater%   r   r!   r'   s      r   r+   zTokensClient.create?   s'    . $$++O+L	~~r   refreshc                T    | j                   j                  ||      }|j                  S )aM  
        Adds a JWT refresh token to the blacklist, preventing it from being used to obtain new access tokens.

        Parameters
        ----------
        refresh : str

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

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


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.tokens.blacklist(
            refresh="refresh",
        )
        r-   r!   r   	blacklistr%   r   r-   r!   r'   s       r   r1   zTokensClient.blacklistY   s*    : $$..wP_.`	~~r   c                T    | j                   j                  ||      }|j                  S )a  
        Get a new access token, using a refresh token.

        Parameters
        ----------
        refresh : str

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

        Returns
        -------
        TokenRefreshResponse


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.tokens.refresh(
            refresh="refresh",
        )
        r/   r   r-   r%   r2   s       r   r-   zTokensClient.refreshy   s)    6 $$,,Wo,^	~~r   c                T    | j                   j                  ||      }|j                  S )a  
        Creates a new JWT refresh token and blacklists the current one.

        Parameters
        ----------
        refresh : str

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

        Returns
        -------
        TokenRotateResponse


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.tokens.rotate(
            refresh="refresh",
        )
        r/   r   rotater%   r2   s       r   r7   zTokensClient.rotate   s)    6 $$++G_+]	~~r   )__name__
__module____qualname__r   r   propertyr   r   typingOptionalstrr   Listr   r$   r   r+   DictAnyr1   r	   r-   r
   r7    r   r   r   r      s&   J*; J  ?     37ko!??3/IOYgIh	_	%> LP )H Te 6 SW060O	S&**_	%@ [_ # 8W cw < Z^  v~7V bu r   r   c            	          e Zd ZdefdZedefd       Zddddej                  e
   dej                  e   dej                  e   fd	Zdd
dej                  e   defdZdd
de
dej                  e   dej"                  e
ej$                  f   fdZdd
de
dej                  e   defdZdd
de
dej                  e   defdZy)AsyncTokensClientr   c                &    t        |      | _        y r   )r   r   r   s     r   r   zAsyncTokensClient.__init__   s    /~Nr   r   c                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawTokensClient
        r   r   s    r   r   z#AsyncTokensClient.with_raw_response   r   r   Nr   r    r!   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a  
        List all API tokens for the current user.

        Parameters
        ----------
        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[LseapiTokenList]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        r   Nr#   r&   s       r   r$   zAsyncTokensClient.list   s8     H **//Sb/cc	~~ d   !646r(   c                n   K   | j                   j                  |       d{   }|j                  S 7 w)a5  
        Create a new API token for the current user.

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

        Returns
        -------
        LseapiTokenCreate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tokens.create()


        asyncio.run(main())
        r(   Nr*   r,   s      r   r+   zAsyncTokensClient.create   s4     > **11/1RR	~~ Ss    535r-   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a  
        Adds a JWT refresh token to the blacklist, preventing it from being used to obtain new access tokens.

        Parameters
        ----------
        refresh : str

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

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


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tokens.blacklist(
                refresh="refresh",
            )


        asyncio.run(main())
        r/   Nr0   r2   s       r   r1   zAsyncTokensClient.blacklist  s8     J **44WVe4ff	~~ grH   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a  
        Get a new access token, using a refresh token.

        Parameters
        ----------
        refresh : str

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

        Returns
        -------
        TokenRefreshResponse


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tokens.refresh(
                refresh="refresh",
            )


        asyncio.run(main())
        r/   Nr4   r2   s       r   r-   zAsyncTokensClient.refresh6  s8     J **227Tc2dd	~~ erH   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a  
        Creates a new JWT refresh token and blacklists the current one.

        Parameters
        ----------
        refresh : str

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

        Returns
        -------
        TokenRotateResponse


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tokens.rotate(
                refresh="refresh",
            )


        asyncio.run(main())
        r/   Nr6   r2   s       r   r7   zAsyncTokensClient.rotate^  s8     J **11'Sb1cc	~~ drH   )r8   r9   r:   r   r   r;   r   r   r<   r=   r>   r   r?   r   r$   r   r+   r@   rA   r1   r	   r-   r
   r7   rB   r   r   rD   rD      s.   O*< O  #7     37ko%!??3/%IOYgIh%	_	%%N RV  v~/N  Zk  F SW&&060O&	S&**_	%&R SW&&060O&	&R SW&&060O&	&r   rD   )r<   core.client_wrapperr   r   core.request_optionsr   types.lseapi_token_creater   types.lseapi_token_listr   types.token_refresh_responser	   types.token_rotate_responser
   
raw_clientr   r   castrA   OMITr   rD   rB   r   r   <module>rV      sP     G 1 9 5 ? = = v{{6::s#b bJN Nr   