U
    ~fhR                     @  s|  d dl mZ d dlmZmZ d dlmZ d dlZddlm	Z	 ddl
mZmZmZmZmZmZ dd	lmZmZmZmZmZmZmZ dd
lmZmZmZ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'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddgZ5G dd de!Z6G dd de"Z7G dd dZ8G dd dZ9G dd dZ:G dd dZ;dS )     )annotations)Mappingcast)LiteralN   )_legacy_response   )ContentAsyncContentContentWithRawResponseAsyncContentWithRawResponseContentWithStreamingResponse!AsyncContentWithStreamingResponse)	NOT_GIVENBodyQueryHeadersNoneTypeNotGiven	FileTypes)extract_filesmaybe_transformdeepcopy_minimalasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncCursorPageAsyncCursorPage)AsyncPaginatormake_request_options)file_list_paramsfile_create_params)FileListResponse)FileCreateResponse)FileRetrieveResponseFiles
AsyncFilesc                   @  s   e Zd ZeddddZeddddZeddd	d
ZeedddeddddddddddddZdddedddddddddddZ	eeedddedddddddddd d!	d"d#Z
dddedddddddd$dd%d&ZdS )'r(   r	   returnc                 C  s
   t | jS N)r	   _clientself r0   K/tmp/pip-unpacked-wheel-rjiviquo/openai/resources/containers/files/files.pycontent#   s    zFiles.contentFilesWithRawResponsec                 C  s   t | S a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r3   r.   r0   r0   r1   with_raw_response'   s    zFiles.with_raw_responseFilesWithStreamingResponsec                 C  s   t | S z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r6   r.   r0   r0   r1   with_streaming_response1   s    zFiles.with_streaming_responseNfilefile_idextra_headersextra_query
extra_bodytimeoutstrFileTypes | NotGivenstr | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr&   container_idr:   r;   r<   r=   r>   r?   r+   c          
   
   C  s~   |st d|t||d}tttttf |dggd}	ddi|pJi }| jd| dt|t	j
|	t||||d	td
S )<  
        Create a Container File

        You can send either a multipart/form-data request with the raw file content, or
        a JSON request with a file ID.

        Args:
          file: The File object (not file name) to be uploaded.

          file_id: Name of the file to create.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        ;Expected a non-empty value for `container_id` but received r:   r;   r:   pathsContent-Typemultipart/form-data/containers//filesr<   r=   r>   r?   bodyfilesoptionscast_to)
ValueErrorr   r   r   r   r@   object_postr   r$   FileCreateParamsr"   r&   
r/   rH   r:   r;   r<   r=   r>   r?   rT   rU   r0   r0   r1   create:   s*     

   zFiles.createrR   r'   r;   rH   r<   r=   r>   r?   r+   c                C  sL   |st d||s$t d|| jd| d| t||||dtdS )K  
        Retrieve Container File

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rJ   6Expected a non-empty value for `file_id` but received rP   /files/rR   rV   rW   rX   _getr"   r'   r/   r;   rH   r<   r=   r>   r?   r0   r0   r1   retrieveq   s       zFiles.retrieveafterlimitorderr<   r=   r>   r?   int | NotGiven#Literal[('asc', 'desc')] | NotGivenz SyncCursorPage[FileListResponse]	rH   rh   ri   rj   r<   r=   r>   r?   r+   c          	      C  sN   |st d|| jd| dtt t||||t|||dtjdtdS a  List Container files

        Args:
          after: A cursor for use in pagination.

        `after` is an object ID that defines your place
              in the list. For instance, if you make a list request and receive 100 objects,
              ending with obj_foo, your subsequent call can include after=obj_foo in order to
              fetch the next page of the list.

          limit: A limit on the number of objects to be returned. Limit can range between 1 and
              100, and the default is 20.

          order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
              order and `desc` for descending order.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rJ   rP   rQ   )rh   ri   rj   )r<   r=   r>   r?   query)pagerV   model)rX   _get_api_listr   r%   r"   r   r#   FileListParams	r/   rH   rh   ri   rj   r<   r=   r>   r?   r0   r0   r1   list   s(    &
z
Files.listNonec                C  s\   |st d||s$t d|ddi|p0i }| jd| d| t||||dtdS )	I  
        Delete Container File

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rJ   r`   Accept*/*rP   ra   rR   rb   rX   _deleter"   r   re   r0   r0   r1   delete   s       zFiles.delete__name__
__module____qualname__r   r2   r5   r8   r   r]   rf   ru   r|   r0   r0   r0   r1   r(   "   s>   	 >("Cc                   @  s   e Zd ZeddddZeddddZeddd	d
ZeedddeddddddddddddZdddedddddddddddZ	eeedddedddddddddd d!	d"d#Z
dddedddddddd$dd%d&ZdS )'r)   r
   r*   c                 C  s
   t | jS r,   )r
   r-   r.   r0   r0   r1   r2      s    zAsyncFiles.contentAsyncFilesWithRawResponsec                 C  s   t | S r4   )r   r.   r0   r0   r1   r5      s    zAsyncFiles.with_raw_responseAsyncFilesWithStreamingResponsec                 C  s   t | S r7   )r   r.   r0   r0   r1   r8     s    z"AsyncFiles.with_streaming_responseNr9   r@   rA   rB   rC   rD   rE   rF   r&   rG   c          
   
     s   |st d|t||d}tttttf |dggd}	ddi|pJi }| jd| dt|t	j
I d	H |	t||||d
tdI d	H S )rI   rJ   rK   r:   rL   rN   rO   rP   rQ   NrR   rS   )rX   r   r   r   r   r@   rY   rZ   r   r$   r[   r"   r&   r\   r0   r0   r1   r]     s*     
   zAsyncFiles.createrR   r'   r^   c                  sR   |st d||s$t d|| jd| d| t||||dtdI dH S )r_   rJ   r`   rP   ra   rR   rb   Nrc   re   r0   r0   r1   rf   F  s       zAsyncFiles.retrieverg   rk   rl   zCAsyncPaginator[FileListResponse, AsyncCursorPage[FileListResponse]]rm   c          	      C  sN   |st d|| jd| dtt t||||t|||dtjdtdS rn   )rX   rr   r    r%   r"   r   r#   rs   rt   r0   r0   r1   ru   j  s(    &
zAsyncFiles.listrv   c                  sb   |st d||s$t d|ddi|p0i }| jd| d| t||||dtdI d	H S )
rw   rJ   r`   rx   ry   rP   ra   rR   rb   Nrz   re   r0   r0   r1   r|     s       zAsyncFiles.deleter}   r0   r0   r0   r1   r)      s>   	 >("Cc                   @  s.   e Zd ZdddddZedddd	Zd
S )r3   r(   rv   rU   r+   c                 C  sB   || _ t|j| _t|j| _t|j| _t|j| _d S r,   )_filesr   Zto_raw_response_wrapperr]   rf   ru   r|   r/   rU   r0   r0   r1   __init__  s    zFilesWithRawResponse.__init__r   r*   c                 C  s   t | jjS r,   )r   r   r2   r.   r0   r0   r1   r2     s    zFilesWithRawResponse.contentNr~   r   r   r   r   r2   r0   r0   r0   r1   r3     s   r3   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r   r)   rv   r   c                 C  sB   || _ t|j| _t|j| _t|j| _t|j| _d S r,   )r   r   Zasync_to_raw_response_wrapperr]   rf   ru   r|   r   r0   r0   r1   r     s    z"AsyncFilesWithRawResponse.__init__r   r*   c                 C  s   t | jjS r,   )r   r   r2   r.   r0   r0   r1   r2     s    z!AsyncFilesWithRawResponse.contentNr   r0   r0   r0   r1   r     s   r   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r6   r(   rv   r   c                 C  s:   || _ t|j| _t|j| _t|j| _t|j| _d S r,   )r   r   r]   rf   ru   r|   r   r0   r0   r1   r     s    z#FilesWithStreamingResponse.__init__r   r*   c                 C  s   t | jjS r,   )r   r   r2   r.   r0   r0   r1   r2   	  s    z"FilesWithStreamingResponse.contentNr   r0   r0   r0   r1   r6     s   r6   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r   r)   rv   r   c                 C  s:   || _ t|j| _t|j| _t|j| _t|j| _d S r,   )r   r   r]   rf   ru   r|   r   r0   r0   r1   r     s    z(AsyncFilesWithStreamingResponse.__init__r   r*   c                 C  s   t | jjS r,   )r   r   r2   r.   r0   r0   r1   r2     s    z'AsyncFilesWithStreamingResponse.contentNr   r0   r0   r0   r1   r     s   r   )<
__future__r   typingr   r   Ztyping_extensionsr   Zhttpx r   r2   r	   r
   r   r   r   r   _typesr   r   r   r   r   r   r   _utilsr   r   r   r   _compatr   Z	_resourcer   r   	_responser   r   Z
paginationr   r    Z_base_clientr!   r"   Ztypes.containersr#   r$   Z#types.containers.file_list_responser%   Z%types.containers.file_create_responser&   Z'types.containers.file_retrieve_responser'   __all__r(   r)   r3   r   r6   r   r0   r0   r0   r1   <module>   s2    $ V V