
    g                         d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZ ddlmZ dd	lmZmZmZmZ  G d
 de      Zy)zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )BaseSDK    N)modelsutils)HookContext)OptionalNullableUNSET)get_security_from_env)ListMappingOptionalUnionc                      e Zd ZdZdedddddeej                  ej                  f   de	ej                     deej                     de	e   de	e   d	e	eeef      d
e	ej"                     fdZdedddddeej                  ej                  f   de	ej                     deej                     de	e   de	e   d	e	eeef      d
e	ej"                     fdZddeeeeedddd
de	e   de	e   deeej*                        deeej,                        dee   deej                     deej                     de	e   de	e   d	e	eeef      d
e	ej.                     fdZddeeeeedddd
de	e   de	e   deeej*                        deeej,                        dee   deej                     deej                     de	e   de	e   d	e	eeef      d
e	ej.                     fdZedddddedeej                     de	e   de	e   d	e	eeef      d
e	ej4                     fdZedddddedeej                     de	e   de	e   d	e	eeef      d
e	ej4                     fdZedddddedeej                     de	e   de	e   d	e	eeef      d
e	ej:                     fdZedddddedeej                     de	e   de	e   d	e	eeef      d
e	ej:                     fdZedddddedeej                     de	e   de	e   d	e	eeef      d
e	e jB                     fdZ"edddddedeej                     de	e   de	e   d	e	eeef      d
e	e jB                     fdZ#dedddd ded!e	e   deej                     de	e   de	e   d	e	eeef      d
e	ejH                     fd"Z%dedddd ded!e	e   deej                     de	e   de	e   d	e	eeef      d
e	ejH                     fd#Z&y)$Filesz	Files APIN)purposeretries
server_url
timeout_mshttp_headersfiler   r   r   r   r   returnc                x   d}d}|| j                   j                  }||}t        j                  t	        j
                  |t        j                        |      | j                  dd||ddddd|| j                   j                  fd	|
      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g df}
| j                  t        dg t        | j                   j                  t        j                               |	ddg|
      }t	        j"                  |dd      r5t	        j$                  |j&                  t(        t        j*                           S t	        j"                  |ddgd      r7t	        j,                  |      }t        j.                  d|j0                  ||      |j2                  j5                  d      }t	        j,                  |      }t        j.                  d|j0                   d| d|j0                  ||      )  Upload File

        Upload a file that can be used across various endpoints.

        The size of individual files can be a maximum of 512 MB. The Fine-tuning API only supports .jsonl files.

        Please contact us if you need to increase these storage limits.

        :param file: The File object (not file name) to be uploaded.  To upload a file and specify a custom file name you should format your request as such:  ```bash  file=@path/to/your/file.jsonl;filename=custom_name.jsonl  ```  Otherwise, you can just keep the original file name:  ```bash  file=@path/to/your/file.jsonl  ```
        :param purpose:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   POST	/v1/filesTF
user-agentapplication/jsonc                  R    t        j                   dddt        j                        S NF	multipartr   serialize_request_bodyr   +FilesAPIRoutesUploadFileMultiPartBodyParamsrequests   D/var/www/openai/venv/lib/python3.12/site-packages/mistralai/files.py<lambda>zFiles.upload.<locals>.<lambda>B   %    (D(DBB)    methodpathbase_urlurl_variablesr&   request_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_valuer   securityget_serialized_bodyr   429500502503504files_api_routes_upload_fileoperation_idoauth2_scopessecurity_source4XX5XXhook_ctxr&   error_status_codesretry_config200*API error occurredContent-Type$Unexpected response received (code: , type: ))sdk_configurationr   r   r$   r   get_pydantic_modelFile_build_requestr5   r	   rG   
isinstanceRetryConfig
do_requestr   r
   Securitymatch_responseunmarshal_jsontextr   UploadFileOutstream_to_textSDKErrorstatus_codeheadersgetselfr   r   r   r   r   r   r.   r/   reqrG   http_reshttp_res_textcontent_typer&   s                 @r'   uploadzFiles.upload   s&   2 //::J!!HDD))$<

 !!'"&$)%)* 2%++44! ") " 
. e%%22%?00==gu001#%HIL?? ;  5**33V__!  %u~% # 
 %1CD''x@T@T7UVV5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c                  K   d}d}|| j                   j                  }||}t        j                  t	        j
                  |t        j                        |      | j                  dd||ddddd|| j                   j                  fd	|
      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g df}
| j                  t        dg t        | j                   j                  t        j                               |	ddg|
       d{   }t	        j"                  |dd      r5t	        j$                  |j&                  t(        t        j*                           S t	        j"                  |ddgd      r?t	        j,                  |       d{   }t        j.                  d|j0                  ||      |j2                  j5                  d      }t	        j,                  |       d{   }t        j.                  d|j0                   d| d|j0                  ||      7 7 7 <w)r   Nr   r   r   TFr   r   c                  R    t        j                   dddt        j                        S r    r"   r%   s   r'   r(   z$Files.upload_async.<locals>.<lambda>   r)   r*   r+   r7   r=   r>   rB   rC   rD   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   r$   r   rP   rQ   _build_request_asyncr5   r	   rG   rS   rT   do_request_asyncr   r
   rV   rW   rX   rY   r   rZ   stream_to_text_asyncr\   r]   r^   r_   r`   s                 @r'   upload_asynczFiles.upload_asyncr   sJ    2 //::J!!HDD))$<

 '''"&$)%)* 2%++44! ") ( 
. e%%22%?00==gu001#%HIL.. ;  5**33V__!  %u~% / 
 
 %1CD''x@T@T7UVV5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
/
  G Cs8   D?IIBIIAII8IIIr   d   )
page	page_sizesample_typesourcesearchr   r   r   r   r   rn   ro   rp   rq   rr   c       
         2   d}d}|	| j                   j                  }	||}t        j                  ||||||      }| j	                  dd|||ddddd|
| j                   j
                  |		      }|t        k(  r2| j                   j                  t        ur| j                   j                  }d}t        |t        j                        r|g d
f}| j                  t        dg t        | j                   j
                  t        j                              |ddg|      }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r7t        j(                  |      }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |      }t        j*                  d|j,                   d| d|j,                  ||      aG  List Files

        Returns a list of files that belong to the user's organization.

        :param page:
        :param page_size:
        :param sample_type:
        :param source:
        :param search:
        :param purpose:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        N)rn   ro   rp   rq   rr   r   GETr   FTr   r   r,   r-   r.   r/   r&   r0   r1   r2   r3   r4   r   r5   r   r7   files_api_routes_list_filesr>   rB   rC   rD   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   FilesAPIRoutesListFilesRequestrR   r5   r	   rG   rS   r   rT   rU   r   r
   rV   rW   rX   rY   r   ListFilesOutr[   r\   r]   r^   r_   ra   rn   ro   rp   rq   rr   r   r   r   r   r   r.   r/   r&   rb   rG   rc   rd   re   s                      r'   listz
Files.list   s   : //::J!!H77#
 !!'"'$)%)* 2%++44! " 
  e%%22%?00==gu001#%HIL?? :  5**33V__!  %u~% # 
 %1CD''x@S@S7TUU5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c       
         x  K   d}d}|	| j                   j                  }	||}t        j                  ||||||      }| j	                  dd|||ddddd|
| j                   j
                  |		      }|t        k(  r2| j                   j                  t        ur| j                   j                  }d}t        |t        j                        r|g d
f}| j                  t        dg t        | j                   j
                  t        j                              |ddg|       d{   }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r?t        j(                  |       d{   }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |       d{   }t        j*                  d|j,                   d| d|j,                  ||      7 7 7 <wrt   )rO   r   r   rx   ri   r5   r	   rG   rS   r   rT   rj   r   r
   rV   rW   rX   rY   r   ry   rk   r\   r]   r^   r_   rz   s                      r'   
list_asynczFiles.list_async9  s=    : //::J!!H77#
 '''"'$)%)* 2%++44! ( 
  e%%22%?00==gu001#%HIL.. :  5**33V__!  %u~% / 
 
 %1CD''x@S@S7TUU5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
/
  G Cs8   DH:H3 BH:!H6"AH:;H8<8H:6H:8H:)r   r   r   r   file_idc                (   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddg|
      }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r7t        j(                  |      }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |      }t        j*                  d|j,                   d| d|j,                  ||      a  Retrieve File

        Returns information about a specific file.

        :param file_id:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr~   ru   /v1/files/{file_id}FTr   r   rv   r7   files_api_routes_retrieve_filer>   rB   rC   rD   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   !FilesAPIRoutesRetrieveFileRequestrR   r5   r	   rG   rS   r   rT   rU   r   r
   rV   rW   rX   rY   r   RetrieveFileOutr[   r\   r]   r^   r_   ra   r~   r   r   r   r   r.   r/   r&   rb   rG   rc   rd   re   s                 r'   retrievezFiles.retrieve  s
   & //::J!!H::
 !!&'"'$(%)* 2%++44! " 
  e%%22%?00==gu001#%HIL?? =  5**33V__!  %u~% # 
 %1CD''x@V@V7WXX5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c                n  K   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddg|
       d{   }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r?t        j(                  |       d{   }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |       d{   }t        j*                  d|j,                   d| d|j,                  ||      7 7 7 <wr   )rO   r   r   r   ri   r5   r	   rG   rS   r   rT   rj   r   r
   rV   rW   rX   rY   r   r   rk   r\   r]   r^   r_   r   s                 r'   retrieve_asynczFiles.retrieve_async  s.    & //::J!!H::
 ''&'"'$(%)* 2%++44! ( 
  e%%22%?00==gu001#%HIL.. =  5**33V__!  %u~% / 
 
 %1CD''x@V@V7WXX5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
/
  G C8   DH5H.BH5H1AH56H378H51H53H5c                (   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddg|
      }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r7t        j(                  |      }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |      }t        j*                  d|j,                   d| d|j,                  ||      a  Delete File

        Delete a file.

        :param file_id:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   DELETEr   FTr   r   rv   r7   files_api_routes_delete_filer>   rB   rC   rD   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   FilesAPIRoutesDeleteFileRequestrR   r5   r	   rG   rS   r   rT   rU   r   r
   rV   rW   rX   rY   r   DeleteFileOutr[   r\   r]   r^   r_   r   s                 r'   deletezFiles.deleteG  s
   & //::J!!H88
 !!&'"'$(%)* 2%++44! " 
  e%%22%?00==gu001#%HIL?? ;  5**33V__!  %u~% # 
 %1CD''x@T@T7UVV5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c                n  K   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddg|
       d{   }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r?t        j(                  |       d{   }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |       d{   }t        j*                  d|j,                   d| d|j,                  ||      7 7 7 <wr   )rO   r   r   r   ri   r5   r	   rG   rS   r   rT   rj   r   r
   rV   rW   rX   rY   r   r   rk   r\   r]   r^   r_   r   s                 r'   delete_asynczFiles.delete_async  s.    & //::J!!H88
 ''&'"'$(%)* 2%++44! ( 
  e%%22%?00==gu001#%HIL.. ;  5**33V__!  %u~% / 
 
 %1CD''x@T@T7UVV5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
/
  G Cr   c                   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddgd|
      }t        j                  |dd      r|S t        j                  |ddgd      r7t        j                   |      }t        j"                  d|j$                  ||      |j&                  j)                  d      }t        j                   |      }t        j"                  d|j$                   d| d|j$                  ||      a  Download File

        Download a file

        :param file_id:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   ru   z/v1/files/{file_id}/contentFTr   zapplication/octet-streamrv   r7   files_api_routes_download_filer>   rB   rC   )rE   r&   rF   streamrG   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   !FilesAPIRoutesDownloadFileRequestrR   r5   r	   rG   rS   r   rT   rU   r   r
   rV   rW   r[   r\   r]   r^   r_   r   s                 r'   downloadzFiles.download  s   & //::J!!H::
 !!.'"'$(%)* :%++44! " 
  e%%22%?00==gu001#%HIL?? =  5**33V__!  %u~% # 
 %1KLO5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c                  K   d}d}|| j                   j                  }||}t        j                  |      }| j	                  dd|||ddddd|| j                   j
                  |	      }	|t        k(  r2| j                   j                  t        ur| j                   j                  }d}
t        |t        j                        r|g d
f}
| j                  t        dg t        | j                   j
                  t        j                              |	ddgd|
       d{   }t        j                  |dd      r|S t        j                  |ddgd      r?t        j                   |       d{   }t        j"                  d|j$                  ||      |j&                  j)                  d      }t        j                   |       d{   }t        j"                  d|j$                   d| d|j$                  ||      7 7 7 ;wr   )rO   r   r   r   ri   r5   r	   rG   rS   r   rT   rj   r   r
   rV   rW   rk   r\   r]   r^   r_   r   s                 r'   download_asynczFiles.download_asyncG  s    & //::J!!H::
 ''.'"'$(%)* :%++44! ( 
  e%%22%?00==gu001#%HIL.. =  5**33V__!  %u~% / 
 
 %1KLO5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
1
" G Cs8   DHG<AH*G>+AHH 8H>H H   )expiryr   r   r   r   r   c                *   d}d}|| j                   j                  }||}t        j                  ||      }	| j	                  dd|||	ddddd|| j                   j
                  |	      }
|t        k(  r2| j                   j                  t        ur| j                   j                  }d}t        |t        j                        r|g d
f}| j                  t        dg t        | j                   j
                  t        j                              |
ddg|      }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r7t        j(                  |      }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |      }t        j*                  d|j,                   d| d|j,                  ||      a  Get Signed Url

        :param file_id:
        :param expiry: Number of hours before the url becomes invalid. Defaults to 24h
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        N)r~   r   ru   z/v1/files/{file_id}/urlFTr   r   rv   r7   files_api_routes_get_signed_urlr>   rB   rC   rD   rH   rI   rJ   rK   rL   rM   rN   )rO   r   r   !FilesAPIRoutesGetSignedURLRequestrR   r5   r	   rG   rS   r   rT   rU   r   r
   rV   rW   rX   rY   r   FileSignedURLr[   r\   r]   r^   r_   ra   r~   r   r   r   r   r   r.   r/   r&   rb   rG   rc   rd   re   s                  r'   get_signed_urlzFiles.get_signed_url  s   & //::J!!H::

 !!*'"'$(%)* 2%++44! " 
  e%%22%?00==gu001#%HIL?? >  5**33V__!  %u~% # 
 %1CD''x@T@T7UVV5%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r*   c                p  K   d}d}|| j                   j                  }||}t        j                  ||      }	| j	                  dd|||	ddddd|| j                   j
                  |	      }
|t        k(  r2| j                   j                  t        ur| j                   j                  }d}t        |t        j                        r|g d
f}| j                  t        dg t        | j                   j
                  t        j                              |
ddg|       d{   }t        j                  |dd      r5t        j                   |j"                  t$        t        j&                           S t        j                  |ddgd      r?t        j(                  |       d{   }t        j*                  d|j,                  ||      |j.                  j1                  d      }t        j(                  |       d{   }t        j*                  d|j,                   d| d|j,                  ||      7 7 7 <wr   )rO   r   r   r   ri   r5   r	   rG   rS   r   rT   rj   r   r
   rV   rW   rX   rY   r   r   rk   r\   r]   r^   r_   r   s                  r'   get_signed_url_asynczFiles.get_signed_url_async  s1    & //::J!!H::

 ''*'"'$(%)* 2%++44! ( 
  e%%22%?00==gu001#%HIL.. >  5**33V__!  %u~% / 
 
 %1CD''x@T@T7UVV5%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
/
  G Cs8   DH6H/BH6H2AH67H488H62H64H6)'__name__
__module____qualname____doc__r	   r   r   rQ   FileTypedDictr   FilePurposer   r   rT   strintr   rZ   rf   rl   r   
SampleTypeSourcery   r{   r}   r   r   r   r   r   r   httpxResponser   r   r   r   r    r*   r'   r   r      s    157<$($(48a
 FKK!5!556a
 &,,-	a

 "%"3"34a
 SMa
 SMa
 wsCx01a
 
&&&	'a
N 157<$($(48a
 FKK!5!556a
 &,,-	a

 "%"3"34a
 SMa
 SMa
 wsCx01a
 
&&&	'a
L  #&AF8=(-8=7<$($(48b
 smb
 C=	b

 &d6+<+<&=>b
 !fmm!45b
 !%b
 "&"4"45b
 "%"3"34b
 SMb
 SMb
 wsCx01b
 
&%%	&b
N  #&AF8=(-8=7<$($(48b
 smb
 C=	b

 &d6+<+<&=>b
 !fmm!45b
 !%b
 "&"4"45b
 "%"3"34b
 SMb
 SMb
 wsCx01b
 
&%%	&b
P 8=$($(48S
 S
 "%"3"34	S

 SMS
 SMS
 wsCx01S
 
&((	)S
r 8=$($(48S
 S
 "%"3"34	S

 SMS
 SMS
 wsCx01S
 
&((	)S
r 8=$($(48S
 S
 "%"3"34	S

 SMS
 SMS
 wsCx01S
 
&&&	'S
r 8=$($(48S
 S
 "%"3"34	S

 SMS
 SMS
 wsCx01S
 
&&&	'S
r 8=$($(48T
 T
 "%"3"34	T

 SMT
 SMT
 wsCx01T
 
%..	!T
t 8=$($(48T
 T
 "%"3"34	T

 SMT
 SMT
 wsCx01T
 
%..	!T
t !#7<$($(48T
 T
 	T

 "%"3"34T
 SMT
 SMT
 wsCx01T
 
&&&	'T
t !#7<$($(48T
 T
 	T

 "%"3"34T
 SMT
 SMT
 wsCx01T
 
&&&	'T
r*   r   )r   basesdkr   r   	mistralair   r   mistralai._hooksr   mistralai.typesr   r	   mistralai.utilsr
   typingr   r   r   r   r   r   r*   r'   <module>r      s.    G   # ( 3 1 1 1{
G {
r*   