
    ]jE                         d dl 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mZ ddlmZ dd	lmZ dd
lmZ ddlmZ  e j*                  e j,                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)
FileUpload.c                   Z   e Zd ZdefdZdddedej                  e   de	e
   fdZdddedej                  e   de	d   fd	Zedd
dedej                  ej                     dej                  e   de	e
   fdZddddddedej                  e   dej                  ej$                  eej(                  e   f      dej                  e   dej                  e   de	ej*                  e
      fdZdddedej                  e   de	d   fdZdddedej                  e   de	d   fdZy)RawFilesClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     K/root/env/lib/python3.12/site-packages/label_studio_sdk/files/raw_client.py__init__zRawFilesClient.__init__   
    -    Nrequest_optionsidr   returnc                   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)	a$  
        Retrieve details about a specific uploaded file.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[FileUpload]

        api/import/file-upload/GETmethodr      ,  type_object_responsedatastatus_codeheadersbody)r   httpx_clientrequestr   r.   typingcastr   r   jsonr
   r   r   dictr/   textr   r   r   	_response_data_response_jsons         r   getzRawFilesClient.get   s      ((55==%&6r&:%;<+ > 
	
	ti++1c1"( ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC C ?Dc                   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)	a  
        Delete a specific uploaded file.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[None]
        r!   DELETEr#   r%   r&   Nr*   r-   r   r1   r2   r   r.   r
   r5   r   r   r6   r/   r7   r   r   r   r9   r;   s        r   deletezRawFilesClient.delete;   s     ((55==%&6r&:%;<+ > 
	
	ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	t   $B B ?Cfiler   rD   c          	      >   | j                   j                  j                  dt        |       di i |d|ini |t        d      }	 d|j
                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||	      S |j                         }t        |j
                  t        |j                        |
      # t        $ r6 t        |j
                  t        |j                        |j                   
      w xY w)ap  
        Update a specific uploaded file.

        Parameters
        ----------
        id : int

        file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        HttpResponse[FileUpload]

        r!   PATCHrD   Tr$   r,   filesr   omitforce_multipartr%   r&   r'   r*   r-   )r   r1   r2   r   OMITr.   r3   r4   r   r   r5   r
   r   r   r6   r/   r7   r   r   rD   r   r9   r:   r;   s          r   updatezRawFilesClient.updateW   s   2 ((55==%&6r&:%;<%)%5FD>2 ,  > 

		ti++1c1"( ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC "C ?Dall_idsorderingr   rO   rP   rQ   c                n   | j                   j                  j                  dt        |       dd|||d|      }	 d|j                  cxk  rdk  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                                     }t        ||	      S |j                         }t        |j                  t        |j                        |
      # t        $ r6 t        |j                  t        |j                        |j                   
      w xY w)a  

                Retrieve the list of uploaded files used to create labeling tasks for a specific project.


        Parameters
        ----------
        id : int

        all_ : typing.Optional[bool]
            Set to "true" if you want to retrieve all file uploads

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Specify the list of file upload IDs to retrieve, e.g. ids=[1,2,3]

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

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

        Returns
        -------
        HttpResponse[typing.List[FileUpload]]

        api/projects//file-uploadsr"   allrP   rQ   r$   paramsr   r%   r&   r'   r*   r-   )r   r1   r2   r   r.   r3   r4   Listr   r   r5   r
   r   r   r6   r/   r7   	r   r   rO   rP   rQ   r   r9   r:   r;   s	            r   listzRawFilesClient.list   s   F ((55==,R01?$
 , > 	
		ti++1c1KK
+"$kk*5 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   A=C5 :C5 5?D4c                   | j                   j                  j                  dt        |       dd|      }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |	      # t        $ r6 t        |j                  t        |j                        |j                  	      w xY w)
a$  

                Delete uploaded files for a specific project.


        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[None]
        rS   rT   r>   r#   r%   r&   Nr*   r-   r?   r@   s        r   delete_manyzRawFilesClient.delete_many   s    " ((55==,R01?+ > 
	
	ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $B B ?Cfilenamec                   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)	a  
        Download a specific uploaded file.

        Parameters
        ----------
        filename : str

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

        Returns
        -------
        HttpResponse[None]
        data/upload/r"   r#   r%   r&   Nr*   r-   r?   r   r^   r   r9   r;   s        r   downloadzRawFilesClient.download   s     ((55==+H567+ > 
	
	ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	trB   )__name__
__module____qualname__r   r   intr3   Optionalr   r
   r   r<   rA   rK   r   FilerM   boolUnionstrSequencerY   r[   r]   rb    r   r   r   r      s   .*; . RV "pc "pv~/N "pZfgqZr "pH UY p p&//.2Q p]ijn]o p@ ,0;?1p1p oodii(	1p
  81p 
j	!1pn '+HL)-;?:p:p ood#	:p
 __V\\#vs/C*CDE:p //#&:p  8:p 
fkk*-	.:px Z^ pc pv~7V pbnosbt p< ]a p p&//.:Y peqrvew pr   r   c                   Z   e Zd ZdefdZdddedej                  e   de	e
   fdZdddedej                  e   de	d   fd	Zedd
dedej                  ej                     dej                  e   de	e
   fdZddddddedej                  e   dej                  ej$                  eej(                  e   f      dej                  e   dej                  e   de	ej*                  e
      fdZdddedej                  e   de	d   fdZdddedej                  e   de	d   fdZy)AsyncRawFilesClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawFilesClient.__init__  r   r   Nr   r   r   r   c                :  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                         }t        |j                  t        |j                        |	      7 # t        $ r6 t        |j                  t        |j                        |j                  	      w xY ww)
a)  
        Retrieve details about a specific uploaded file.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[FileUpload]

        r!   r"   r#   Nr%   r&   r'   r*   r-   )r   r1   r2   r   r.   r3   r4   r   r   r5   r	   r   r   r6   r/   r7   r8   s         r   r<   zAsyncRawFilesClient.get  s    $ ..;;CC%&6r&:%;<+ D 
 
	
	ti++1c1"( ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts4   8DCD AC DC ,,D?DDc                  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)	a  
        Delete a specific uploaded file.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[None]
        r!   r>   r#   Nr%   r&   r*   r-   r   r1   r2   r   r.   r	   r5   r   r   r6   r/   r7   r@   s        r   rA   zAsyncRawFilesClient.delete+  s     " ..;;CC%&6r&:%;<+ D 
 
	
	ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	t3   8C$B C$ $B" $C$%B" 5,C$"?C!!C$rC   rD   c          	      Z  K   | j                   j                  j                  dt        |       di i |d|ini |t        d       d{   }	 d|j
                  cxk  rdk  rGn nDt        j                  t        t        t        |j                         	            }t        ||
      S |j                         }t        |j
                  t        |j                        |      7 # t        $ r6 t        |j
                  t        |j                        |j                         w xY ww)au  
        Update a specific uploaded file.

        Parameters
        ----------
        id : int

        file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        AsyncHttpResponse[FileUpload]

        r!   rF   NrD   TrG   r%   r&   r'   r*   r-   )r   r1   r2   r   rK   r.   r3   r4   r   r   r5   r	   r   r   r6   r/   r7   rL   s          r   rM   zAsyncRawFilesClient.updateI  s$    2 ..;;CC%&6r&:%;<%)%5FD>2 ,  D 

 

		ti++1c1"( ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo1

,  	ty'<'<d9K\K\F]dmdrdrss	ts7   AD+
C'D+AC) +D+,C) <,D+)?D((D+rN   rO   rP   rQ   c                  K   | j                   j                  j                  dt        |       dd|||d|       d{   }	 d|j                  cxk  rdk  rin nft        j                  t
        j                  t           t        t
        j                  t           |j                         	            }t        ||
      S |j                         }t        |j                  t        |j                        |      7 # t        $ r6 t        |j                  t        |j                        |j                         w xY ww)a  

                Retrieve the list of uploaded files used to create labeling tasks for a specific project.


        Parameters
        ----------
        id : int

        all_ : typing.Optional[bool]
            Set to "true" if you want to retrieve all file uploads

        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Specify the list of file upload IDs to retrieve, e.g. ids=[1,2,3]

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

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

        Returns
        -------
        AsyncHttpResponse[typing.List[FileUpload]]

        rS   rT   r"   rU   rW   Nr%   r&   r'   r*   r-   )r   r1   r2   r   r.   r3   r4   rY   r   r   r5   r	   r   r   r6   r/   r7   rZ   s	            r   r[   zAsyncRawFilesClient.list|  s&    F ..;;CC,R01?$
 , D 	
 	
		ti++1c1KK
+"$kk*5 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo/	
*  	ty'<'<d9K\K\F]dmdrdrss	ts6   >E C?EA=D ED ,E?E  Ec                  K   | j                   j                  j                  dt        |       dd|       d{   }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |	      7 e# t        $ r6 t        |j                  t        |j                        |j                  	      w xY ww)
a)  

                Delete uploaded files for a specific project.


        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[None]
        rS   rT   r>   r#   Nr%   r&   r*   r-   rs   r@   s        r   r]   zAsyncRawFilesClient.delete_many  s     & ..;;CC,R01?+ D 
 
	
	ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	ts3   9C%B!C%$B# %C%&B# 6,C%#?C""C%r^   c                  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rn nt        |d      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)	a  
        Download a specific uploaded file.

        Parameters
        ----------
        filename : str

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

        Returns
        -------
        AsyncHttpResponse[None]
        r`   r"   r#   Nr%   r&   r*   r-   rs   ra   s        r   rb   zAsyncRawFilesClient.download  s     " ..;;CC+H567+ D 
 
	
	ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	trt   )rc   rd   re   r   r   rf   r3   rg   r   r	   r   r<   rA   rK   r   rh   rM   ri   rj   rk   rl   rY   r[   r]   rb   rm   r   r   ro   ro     s   .*< . NR$p$p+1??>+J$p	:	&$pN NRpp+1??>+Jp	4	 pD ,0;?1p1p oodii(	1p
  81p 
:	&1pn '+HL)-;?:p:p ood#	:p
 __V\\#vs/C*CDE:p //#&:p  8:p 
6;;z2	3:pz NRpp+1??>+Jp	4	 pB TXpp171Pp	4	 pr   ro   )r3   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.http_responser	   r
   core.jsonable_encoderr   core.request_optionsr   core.unchecked_base_modelr   types.file_uploadr   r4   AnyrK   r   ro   rm   r   r   <module>r      sZ     (  % G @ 4 1 6 * v{{6::s#kp kp\sp spr   