
    ]jp                        d dl Z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 ddlmZ  ej:                  ej<                  d      Z G d d      Z  G d d      Z!y)    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions)ConvertedFormatRequest)Export)!LseAnnotationFilterOptionsRequest)LseExportCreate)LseTaskFilterOptionsRequest)SerializationOptionsRequest)Status7BfEnum)UserSimpleRequest   )AsyncRawExportsClientRawExportsClient)ConvertExportsResponse.c                      e Zd ZdefdZedefd       Zdddddddede	j                  e   d	e	j                  e   d
e	j                  e   de	j                  e	j                  ee	j                  e   f      de	j                  e   de	j                   e   fdZdddede	j                  e   de	j&                  e   fdZddddede	j                  e   de	j                  e   de	j&                  e   fdZeeeeeeeeeedddede	j                  e   de	j                  e	j                  e      de	j                  e	j4                     de	j                  e   de	j                  ej:                     d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Z"dddedede	j                  e   defd Z#dddedede	j                  e   ddfd!Z$edd"deded
ed	e	j                  e   de	j                  e   de%fd#Z&ddd$deded
e	j                  e   de	j                  e   de	j                   e   f
d%Z'y)&ExportsClientclient_wrapperc                &    t        |      | _        y N)r   )r   _raw_clientselfr   s     R/root/env/lib/python3.12/site-packages/label_studio_sdk/projects/exports/client.py__init__zExportsClient.__init__   s    +>J    returnc                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawExportsClient
        r   r   s    r   with_raw_responsezExportsClient.with_raw_response        r   Ndownload_all_tasksdownload_resourcesexport_typeidsrequest_optionsidr%   r&   r'   r(   r)   c             #      K   | j                   j                  ||||||      5 }|j                  E d{    ddd       y7 # 1 sw Y   yxY ww)a9
  

                This endpoint is deprecated in Enterprise. Use the async export API instead:
                POST /api/projects/{id}/exports/ (see [Create new export](/api#operation/api_projects_exports_create)).

                In Label Studio Enterprise, this endpoint will always return a 404 Not Found response with instructions to use the async export API.

                <i>Note: if you have a large project it's recommended to use
                export snapshots, this easy export endpoint might have timeouts.</i><br/><br>
                Export annotated tasks as a file in a specific format.
                For example, to export JSON annotations for a project to a file called `annotations.json`,
                run the following from the command line:
                ```bash
                curl -X GET http://localhost:8000/api/projects/{id}/export?exportType=JSON -H 'Authorization: Token abc123' --output 'annotations.json'
                ```
                To export all tasks, including skipped tasks and others without annotations, run the following from the command line:
                ```bash
                curl -X GET http://localhost:8000/api/projects/{id}/export?exportType=JSON&download_all_tasks=true -H 'Authorization: Token abc123' --output 'annotations.json'
                ```
                To export specific tasks with IDs of 123 and 345, run the following from the command line:
                ```bash
                curl -X GET 'http://localhost:8000/api/projects/{id}/export?ids[]=123&ids[]=345' -H 'Authorization: Token abc123' --output 'annotations.json'
                ```


        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        download_all_tasks : typing.Optional[bool]
            If true, download all tasks regardless of status. If false, download only annotated tasks.

        download_resources : typing.Optional[bool]
            If true, download all resource files such as images, audio, and others relevant to the tasks.

        export_type : typing.Optional[str]
            Selected export format (JSON by default)

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Specify a list of task IDs to retrieve only the details for those tasks.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Exported data
        r$   Nr   download_syncdata)r   r*   r%   r&   r'   r(   r)   rs           r   r-   zExportsClient.download_sync&   se     x ++11#+ , 
 	 vv	 	 	 	s+   "AAAA	AAA	Ar)   c                T    | j                   j                  ||      }|j                  S )a  

                This endpoint is deprecated in Enterprise. Use the async export API instead:
                POST /api/projects/{{id}}/exports/ (see [Create new export](/api#operation/api_projects_exports_create)).

                In Label Studio Enterprise, this endpoint will always return a 404 Not Found response with instructions to use the async export API.

                Retrieve the available export formats for the current project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

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

        Returns
        -------
        typing.List[str]
            Export formats

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.list_formats(
            id=1,
        )
        r0   r   list_formatsr.   r   r*   r)   	_responses       r   r3   zExportsClient.list_formatsl   s*    D $$11"o1V	~~r   orderingr)   r7   c                V    | j                   j                  |||      }|j                  S )a  
        Returns a list of exported files for a specific project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

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

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

        Returns
        -------
        typing.List[Export]


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.list(
            id=1,
        )
        r6   r   listr.   r   r*   r7   r)   r5   s        r   r:   zExportsClient.list   s-    B $$))"xQ`)a	~~r   annotation_filter_optionsconverted_formatscounters
created_byfinished_atmd5serialization_optionsstatustask_filter_optionstitler)   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   c                h    | j                   j                  |||||||||	|
||      }|j                  S )a  
        Create a new export request to start a background task and generate an export file for a specific project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        annotation_filter_options : typing.Optional[LseAnnotationFilterOptionsRequest]

        converted_formats : typing.Optional[typing.Sequence[ConvertedFormatRequest]]

        counters : typing.Optional[typing.Any]

        created_by : typing.Optional[UserSimpleRequest]

        finished_at : typing.Optional[dt.datetime]
            Complete or fail time

        md5 : typing.Optional[str]

        serialization_options : typing.Optional[SerializationOptionsRequest]

        status : typing.Optional[Status7BfEnum]

        task_filter_options : typing.Optional[LseTaskFilterOptionsRequest]

        title : typing.Optional[str]

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

        Returns
        -------
        LseExportCreate


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.create(
            id=1,
        )
        r<   r   creater.   r   r*   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   r)   r5   s                 r   rI   zExportsClient.create   sP    @ $$++&?/!#"7 3+ , 
	 ~~r   	export_pkc                V    | j                   j                  |||      }|j                  S )a  
        Retrieve information about an export file by export ID for a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

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

        Returns
        -------
        Export


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.get(
            id=1,
            export_pk=1,
        )
        r0   r   getr.   r   r*   rK   r)   r5   s        r   rN   zExportsClient.get  s,    @ $$((Y(X	~~r   c                V    | j                   j                  |||      }|j                  S )a  
        Delete an export file by specified export ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

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

        Returns
        -------
        None

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.delete(
            id=1,
            export_pk=1,
        )
        r0   r   deleter.   rO   s        r   rR   zExportsClient.delete(  s+    > $$++B	?+[	~~r   r&   r)   c                Z    | j                   j                  |||||      }|j                  S )ai  
        Convert export snapshot to selected format

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

        export_type : str
            Export file format.

        download_resources : typing.Optional[bool]
            Download resources in converter.

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

        Returns
        -------
        ConvertExportsResponse


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.exports.convert(
            id=1,
            export_pk=1,
            export_type="export_type",
        )
        r'   r&   r)   r   convertr.   r   r*   rK   r'   r&   r)   r5   s          r   rW   zExportsClient.convertJ  s;    ^ $$,,#1+ - 
	 ~~r   r'   r)   c             #      K   | j                   j                  ||||      5 }|j                  E d{    ddd       y7 # 1 sw Y   yxY ww)a7  

                Download an export file in the specified format for a specific project. Specify the project ID with the `id`
                parameter in the path and the ID of the export file you want to download using the `export_pk` parameter
                in the path.

                Get the `export_pk` from the response of the request to [Create new export](/api#operation/api_projects_exports_create)
                or after [listing export files](/api#operation/api_projects_exports_list).


        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

        export_type : typing.Optional[str]
            Selected export format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Export file
        rY   Nr   downloadr.   )r   r*   rK   r'   r)   r/   s         r   r\   zExportsClient.download  sT     J &&r9+_n&o 	stvv	 		 	s+    AAA A	A AAA)(__name__
__module____qualname__r   r   propertyr   r"   inttypingOptionalboolstrUnionSequencer   Iteratorbytesr-   Listr3   r   r:   OMITr	   r   Anyr   dtdatetimer   r   r   r
   rI   rN   rR   r   rW   r\    r   r   r   r      s   K*; K  #3     5948,0HL;?DD #OOD1	D
 #OOD1D __S)D __V\\#vs/C*CDED  8D 
	DL [_ #s #8W #cicncnorcs #L <@tx""$*OOC$8"RXRaRabpRq"	V	"P Y]VZ049=48$(NR15LP&*;?NN $*??3T#U	N
 "??6??;Q+RSN //&**-N OO$56N __R[[1N __S!N  &/JKN .N $__-HIN s#N  8N 
N` bf !c !c !v~?^ !jp !F ei      &//R`Ba  mq  P 59;?66 6
 6 #OOD16  86 
 6z -1;?&& &
 __S)&  8& 
	&r   r   c                      e Zd ZdefdZedefd       Zdddddddede	j                  e   d	e	j                  e   d
e	j                  e   de	j                  e	j                  ee	j                  e   f      de	j                  e   de	j                   e   fdZdddede	j                  e   de	j&                  e   fdZddddede	j                  e   de	j                  e   de	j&                  e   fdZeeeeeeeeeedddede	j                  e   de	j                  e	j                  e      de	j                  e	j4                     de	j                  e   de	j                  ej:                     d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Z"dddedede	j                  e   defd Z#dddedede	j                  e   ddfd!Z$edd"deded
ed	e	j                  e   de	j                  e   de%fd#Z&ddd$deded
e	j                  e   de	j                  e   de	j                   e   f
d%Z'y)&AsyncExportsClientr   c                &    t        |      | _        y r   )r   r   r   s     r   r   zAsyncExportsClient.__init__  s    0Or   r   c                     | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawExportsClient
        r    r!   s    r   r"   z$AsyncExportsClient.with_raw_response  r#   r   Nr$   r*   r%   r&   r'   r(   r)   c                  K   | j                   j                  ||||||      4 d{   }|j                  2 3 d{   }| 7 7 6 ddd      d{  7   y# 1 d{  7  sw Y   yxY ww)a>
  

                This endpoint is deprecated in Enterprise. Use the async export API instead:
                POST /api/projects/{id}/exports/ (see [Create new export](/api#operation/api_projects_exports_create)).

                In Label Studio Enterprise, this endpoint will always return a 404 Not Found response with instructions to use the async export API.

                <i>Note: if you have a large project it's recommended to use
                export snapshots, this easy export endpoint might have timeouts.</i><br/><br>
                Export annotated tasks as a file in a specific format.
                For example, to export JSON annotations for a project to a file called `annotations.json`,
                run the following from the command line:
                ```bash
                curl -X GET http://localhost:8000/api/projects/{id}/export?exportType=JSON -H 'Authorization: Token abc123' --output 'annotations.json'
                ```
                To export all tasks, including skipped tasks and others without annotations, run the following from the command line:
                ```bash
                curl -X GET http://localhost:8000/api/projects/{id}/export?exportType=JSON&download_all_tasks=true -H 'Authorization: Token abc123' --output 'annotations.json'
                ```
                To export specific tasks with IDs of 123 and 345, run the following from the command line:
                ```bash
                curl -X GET 'http://localhost:8000/api/projects/{id}/export?ids[]=123&ids[]=345' -H 'Authorization: Token abc123' --output 'annotations.json'
                ```


        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        download_all_tasks : typing.Optional[bool]
            If true, download all tasks regardless of status. If false, download only annotated tasks.

        download_resources : typing.Optional[bool]
            If true, download all resource files such as images, audio, and others relevant to the tasks.

        export_type : typing.Optional[str]
            Selected export format (JSON by default)

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Specify a list of task IDs to retrieve only the details for those tasks.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Exported data
        r$   Nr,   )	r   r*   r%   r&   r'   r(   r)   r/   _chunks	            r   r-   z AsyncExportsClient.download_sync  s     x ##1111#+ 2 
 		 		  !  f				 		 		 		 		se   &A4AA4AAA
AAA4
AAA4AA4A1%A(&A1-A4r0   c                p   K   | j                   j                  ||       d{   }|j                  S 7 w)a_  

                This endpoint is deprecated in Enterprise. Use the async export API instead:
                POST /api/projects/{{id}}/exports/ (see [Create new export](/api#operation/api_projects_exports_create)).

                In Label Studio Enterprise, this endpoint will always return a 404 Not Found response with instructions to use the async export API.

                Retrieve the available export formats for the current project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

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

        Returns
        -------
        typing.List[str]
            Export formats

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.list_formats(
                id=1,
            )


        asyncio.run(main())
        r0   Nr2   r4   s       r   r3   zAsyncExportsClient.list_formats  s7     X **77O7\\	~~ ]s   !646r6   r7   c                r   K   | j                   j                  |||       d{   }|j                  S 7 w)a&  
        Returns a list of exported files for a specific project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

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

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

        Returns
        -------
        typing.List[Export]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.list(
                id=1,
            )


        asyncio.run(main())
        r6   Nr9   r;   s        r   r:   zAsyncExportsClient.list0  s:     R **//XWf/gg	~~ h   "757r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   c                   K   | j                   j                  |||||||||	|
||       d{   }|j                  S 7 w)au  
        Create a new export request to start a background task and generate an export file for a specific project by ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        annotation_filter_options : typing.Optional[LseAnnotationFilterOptionsRequest]

        converted_formats : typing.Optional[typing.Sequence[ConvertedFormatRequest]]

        counters : typing.Optional[typing.Any]

        created_by : typing.Optional[UserSimpleRequest]

        finished_at : typing.Optional[dt.datetime]
            Complete or fail time

        md5 : typing.Optional[str]

        serialization_options : typing.Optional[SerializationOptionsRequest]

        status : typing.Optional[Status7BfEnum]

        task_filter_options : typing.Optional[LseTaskFilterOptionsRequest]

        title : typing.Optional[str]

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

        Returns
        -------
        LseExportCreate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.create(
                id=1,
            )


        asyncio.run(main())
        r<   NrH   rJ   s                 r   rI   zAsyncExportsClient.create\  s^     P **11&?/!#"7 3+ 2 
 
	 ~~
s   +A >A rK   c                r   K   | j                   j                  |||       d{   }|j                  S 7 w)a0  
        Retrieve information about an export file by export ID for a specific project.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

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

        Returns
        -------
        Export


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.get(
                id=1,
                export_pk=1,
            )


        asyncio.run(main())
        r0   NrM   rO   s        r   rN   zAsyncExportsClient.get  s9     P **..r9o.^^	~~ _rx   c                r   K   | j                   j                  |||       d{   }|j                  S 7 w)a  
        Delete an export file by specified export ID.

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.delete(
                id=1,
                export_pk=1,
            )


        asyncio.run(main())
        r0   NrQ   rO   s        r   rR   zAsyncExportsClient.delete  s:     N **11"iQ`1aa	~~ brx   rS   c                v   K   | j                   j                  |||||       d{   }|j                  S 7 w)a  
        Convert export snapshot to selected format

        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

        export_type : str
            Export file format.

        download_resources : typing.Optional[bool]
            Download resources in converter.

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

        Returns
        -------
        ConvertExportsResponse


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.exports.convert(
                id=1,
                export_pk=1,
                export_type="export_type",
            )


        asyncio.run(main())
        rU   NrV   rX   s          r   rW   zAsyncExportsClient.convert	  sI     n **22#1+ 3 
 
	 ~~
s   $979rY   c                  K   | j                   j                  ||||      4 d{   }|j                  2 3 d{   }| 7 7 6 ddd      d{  7   y# 1 d{  7  sw Y   yxY ww)a<  

                Download an export file in the specified format for a specific project. Specify the project ID with the `id`
                parameter in the path and the ID of the export file you want to download using the `export_pk` parameter
                in the path.

                Get the `export_pk` from the response of the request to [Create new export](/api#operation/api_projects_exports_create)
                or after [listing export files](/api#operation/api_projects_exports_list).


        Parameters
        ----------
        id : int
            A unique integer value identifying this project.

        export_pk : int
            Primary key identifying the export file.

        export_type : typing.Optional[str]
            Selected export format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Export file
        rY   Nr[   )r   r*   rK   r'   r)   r/   ru   s          r   r\   zAsyncExportsClient.downloadI  sw     J ##,,	{O - 
 	 	 !  f			 	 	 	 	sd   $A2AA2AA
AA
AA2A

AA2AA2A/#A&$A/+A2)(r]   r^   r_   r   r   r`   r   r"   ra   rb   rc   rd   re   rf   rg   r   AsyncIteratorri   r-   rj   r3   r   r:   rk   r	   r   rl   r   rm   rn   r   r   r   r
   rI   rN   rR   r   rW   r\   ro   r   r   rq   rq     s   P*< P  #8     5948,0HL;?EE #OOD1	E
 #OOD1E __S)E __V\\#vs/C*CDEE  8E 
		e	$EP NR--+1??>+J-	S	-` <@tx**$*OOC$8*RXRaRabpRq*	V	*` Y]VZ049=48$(NR15LP&*;?VV $*??3T#U	V
 "??6??;Q+RSV //&**-V OO$56V __R[[1V __S!V  &/JKV .V $__-HIV s#V  8V 
Vp hl )C )C )V__UcEd )pv )V ko (s (s (XfHg (sw (` 59;?>> >
 > #OOD1>  8> 
 >J -1;?)) )
 __S))  8) 
		e	$)r   rq   )"rn   rm   rb   core.client_wrapperr   r   core.request_optionsr   types.converted_format_requestr   types.exportr   +types.lse_annotation_filter_options_requestr	   types.lse_export_creater
   %types.lse_task_filter_options_requestr   #types.serialization_options_requestr   types.status7bf_enumr   types.user_simple_requestr   
raw_clientr   r   types.convert_exports_responser   castrl   rk   r   rq   ro   r   r   <module>r      sb      H 2 D " \ 6 P N 1 : ? B v{{6::s#Q QhG Gr   