
    Ji=                        d dl Z d dlZd dlmZ ddl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 dd
lmZ 	 d dlZej*                  j-                  d      red dlmZ  G d d      Z G d d      Zy# e$ r d dlZY  w xY w)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)remove_none_from_dict)UnprocessableEntityError)HttpValidationError)PageFigureMetadata)PresignedUrlz1.c                      e Zd ZdefdZddddedej                  e   dej                  e   dej                  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dddded
ededej                  e   dej                  e   dej                  fdZdddded
ededej                  e   dej                  e   defdZy)PageFiguresClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     {/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/llama_cloud/resources/page_figures/client.py__init__zPageFiguresClient.__init__   
    -    N
project_idorganization_ididr   r   returnc          	         | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d      t        ||d      | j                   j                         d      }d|j                  cxk  rd	k  r<n n9t        j                  t        j                  t           |j                               S |j                  d
k(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      # t$        $ r" t'        |j                  |j(                        w xY w)a  
        List metadata for all figures from all pages of a file.

        Parameters:
            - id: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.page_figures.list_file_pages_figures(
            id="string",
        )
        GET/api/v1/files//page-figuresr   <   paramsheaderstimeout   ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr   get_headersr-   pydanticparse_obj_astypingListr   jsonr	   r
   r   r   textr   r   r   r   	_response_response_jsons         r   list_file_pages_figuresz)PageFiguresClient.list_file_pages_figures   s=   , ((55==LL  D$8$8$E$E$G#H!Jm\^[__lLmn(
Wf)gh((446 > 
	 )''-#-((5G)H)..JZ[[  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   E +E0
page_indexc          
         | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d|       t        ||d      | j                   j                         d      }d|j                  cxk  rd	k  r<n n9t        j                  t        j                  t           |j                               S |j                  d
k(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      # t$        $ r" t'        |j                  |j(                        w xY w)a  
        List metadata for figures from a specific page of a file.

        Parameters:
            - id: str.

            - page_index: int.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.page_figures.list_file_page_figures(
            id="string",
            page_index=1,
        )
        r    r!   r"   /page-figures/r   r$   r%   r)   r*   r+   r,   r/   r   r   rA   r   r   r>   r?   s          r   list_file_page_figuresz(PageFiguresClient.list_file_page_figuresC   sE   < ((55==LL  ''4467q9]2$n]g\h;i )
Wf)gh((446 > 
	 )''-#-((5G)H)..JZ[[  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss    E +E2figure_namec                   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d| d|       t        ||d      | j                   j                         d      }d|j                  cxk  rd	k  r5n n2t        j                  t        j                  |j                               S |j                  d
k(  r1t        t        j                  t         |j                                     	 |j                         }t%        |j                  |      # t"        $ r" t%        |j                  |j&                        w xY w)a)  
        Get a specific figure from a page of a file.

        Parameters:
            - id: str.

            - page_index: int.

            - figure_name: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.page_figures.get_file_page_figure(
            id="string",
            page_index=1,
            figure_name="string",
        )
        r    r!   r"   rC   r   r$   r%   r)   r*   r+   r,   r   r0   r1   r2   r3   r4   r5   r   r6   r-   r7   r8   r9   Anyr;   r	   r
   r   r   r<   r   r   rA   rF   r   r   r>   r?   s           r   get_file_page_figurez&PageFiguresClient.get_file_page_figuret   sI   D ((55==LL  ''4467q9]2$n]g\hhijuiv;w )
Wf)gh((446 > 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   E +E.c                   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d| d| d      t        ||d      | j                   j                         d      }d	|j                  cxk  rd
k  r+n n(t        j                  t        |j                               S |j                  dk(  r1t        t        j                  t        |j                                     	 |j                         }t#        |j                  |      # t         $ r" t#        |j                  |j$                        w xY w)a   
        Returns a presigned url to read a page figure.

        The presigned url is valid for a limited time period, after which it will expire.
        Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.

        Parameters:
            - id: str.

            - page_index: int.

            - figure_name: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import LlamaCloud

        client = LlamaCloud(
            token="YOUR_TOKEN",
        )
        client.page_figures.generate_file_page_figure_presigned_url(
            id="string",
            page_index=1,
            figure_name="string",
        )
        POSTr!   r"   rC   /presigned_urlr   r$   r%   r)   r*   r+   r,   r   r0   r1   r2   r3   r4   r5   r   r6   r-   r7   r8   r   r;   r	   r
   r   r   r<   rJ   s           r   'generate_file_page_figure_presigned_urlz9PageFiguresClient.generate_file_page_figure_presigned_url   sC   J ((55==LL  ''4467q9t>*Q{m>Z )
Wf)gh((446 > 	
	 )''-#-((y~~7GHH  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   D: :+E%)__name__
__module____qualname__r   r   strr9   Optionalr:   r   r@   intrE   rI   rK   r   rP    r   r   r   r      s   .*; . >Bko%O%O&,ooc&:%OTZTcTcdgTh%O	'	(%OX ,004/O/O /O
 OOC(/O  -/O 
'	(/On ,0043O3O 3O 	3O OOC(3O  -3O 
3Ov ,0047O7O 7O 	7O OOC(7O  -7O 
7Or   r   c                      e Zd ZdefdZddddedej                  e   dej                  e   dej                  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dddded
ededej                  e   dej                  e   dej                  fdZdddded
ededej                  e   dej                  e   defdZy)AsyncPageFiguresClientr   c                    || _         y r   r   r   s     r   r   zAsyncPageFiguresClient.__init__   r   r   Nr   r   r   r   r   c          	        K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d      t        ||d      | j                   j                         d       d{   }d	|j                  cxk  rd
k  r<n n9t        j                  t        j                  t           |j                               S |j                  dk(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      7 # t$        $ r" t'        |j                  |j(                        w xY ww)a  
        List metadata for all figures from all pages of a file.

        Parameters:
            - id: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.page_figures.list_file_pages_figures(
            id="string",
        )
        r    r!   r"   r#   r   r$   r%   Nr)   r*   r+   r,   r/   r=   s         r   r@   z.AsyncPageFiguresClient.list_file_pages_figures   sK    , ..;;CCLL  D$8$8$E$E$G#H!Jm\^[__lLmn(
Wf)gh((446 D 
 
	 )''-#-((5G)H)..JZ[[  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BE?EBE?(E 8E?+E<<E?rA   c          
        K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d|       t        ||d      | j                   j                         d       d{   }d	|j                  cxk  rd
k  r<n n9t        j                  t        j                  t           |j                               S |j                  dk(  r1t!        t        j                  t"        |j                                     	 |j                         }t'        |j                  |      7 # t$        $ r" t'        |j                  |j(                        w xY ww)a  
        List metadata for figures from a specific page of a file.

        Parameters:
            - id: str.

            - page_index: int.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.page_figures.list_file_page_figures(
            id="string",
            page_index=1,
        )
        r    r!   r"   rC   r   r$   r%   Nr)   r*   r+   r,   r/   rD   s          r   rE   z-AsyncPageFiguresClient.list_file_page_figures  sS    < ..;;CCLL  ''4467q9]2$n]g\h;i )
Wf)gh((446 D 
 
	 )''-#-((5G)H)..JZ[[  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN#
  	Sy'<'<9>>RR	Ss+   BFEBF*E :F+E>>FrF   c                  K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d| d|       t        ||d      | j                   j                         d       d{   }d	|j                  cxk  rd
k  r5n n2t        j                  t        j                  |j                               S |j                  dk(  r1t        t        j                  t         |j                                     	 |j                         }t%        |j                  |      7 # t"        $ r" t%        |j                  |j&                        w xY ww)a9  
        Get a specific figure from a page of a file.

        Parameters:
            - id: str.

            - page_index: int.

            - figure_name: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.page_figures.get_file_page_figure(
            id="string",
            page_index=1,
            figure_name="string",
        )
        r    r!   r"   rC   r   r$   r%   Nr)   r*   r+   r,   rH   rJ   s           r   rK   z+AsyncPageFiguresClient.get_file_page_figure?  sW    D ..;;CCLL  ''4467q9]2$n]g\hhijuiv;w )
Wf)gh((446 D 
 
	 )''-#-((Y^^5EFF  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN#
  	Sy'<'<9>>RR	Ss+   BE=EBE=&E 6E=+E::E=c                  K   | j                   j                  j                  dt        j                  j                  | j                   j                          dd| d| d| d      t        ||d      | j                   j                         d       d	{   }d
|j                  cxk  rdk  r+n n(t        j                  t        |j                               S |j                  dk(  r1t        t        j                  t        |j                                     	 |j                         }t#        |j                  |      7 # t         $ r" t#        |j                  |j$                        w xY ww)a0  
        Returns a presigned url to read a page figure.

        The presigned url is valid for a limited time period, after which it will expire.
        Be careful on accidental exposure of the presigned url, as it may allow unauthorized access to the file before the expiration.

        Parameters:
            - id: str.

            - page_index: int.

            - figure_name: str.

            - project_id: typing.Optional[str].

            - organization_id: typing.Optional[str].
        ---
        from llama_cloud.client import AsyncLlamaCloud

        client = AsyncLlamaCloud(
            token="YOUR_TOKEN",
        )
        await client.page_figures.generate_file_page_figure_presigned_url(
            id="string",
            page_index=1,
            figure_name="string",
        )
        rM   r!   r"   rC   rN   r   r$   r%   Nr)   r*   r+   r,   rO   rJ   s           r   rP   z>AsyncPageFiguresClient.generate_file_page_figure_presigned_urlt  sQ    J ..;;CCLL  ''4467q9t>*Q{m>Z )
Wf)gh((446 D 	
 	
	 )''-#-((y~~7GHH  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN%	
   	Sy'<'<9>>RR	Ss+   BE4EBE4E -E4+E11E4)rQ   rR   rS   r   r   rT   r9   rU   r:   r   r@   rV   rE   rI   rK   r   rP   rW   r   r   rY   rY      s   .*< . >Bko%O%O&,ooc&:%OTZTcTcdgTh%O	'	(%OX ,004/O/O /O
 OOC(/O  -/O 
'	(/On ,0043O3O 3O 	3O OOC(3O  -3O 
3Ov ,0047O7O 7O 	7O OOC(7O  -7O 
7Or   rY   )r9   urllib.parser2   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.remove_none_from_dictr   !errors.unprocessable_entity_errorr	   types.http_validation_errorr
   types.page_figure_metadatar   types.presigned_urlr   r7   __version__
startswithImportErrorpydantic.v1v1r   rY   rW   r   r   <module>rm      s|      ( & H ? I > < /&&t,"
HO HOVHO HO_  s   'A8 8	BB