
    i_U                        S SK r S SKrS SKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr   S SKr\R:                  R=                  S5      (       a  \eS SK J!r  \ RD                  " \ RF                  S5      r$ " S S5      r% " S S5      r&g! \ a    S SKr N>f = f)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)jsonable_encoder)remove_none_from_dict)UnprocessableEntityError)ConfigurableDataSourceNames)
DataSource)DataSourceCreate)HttpValidationError   )DataSourceUpdateComponent)#DataSourceUpdateCustomMetadataValuez1..c                      \ rS rSrS\4S jrSSS.S\R                  \   S\R                  \   S\R                  \
   4S	 jjrSSS.S\R                  \   S\R                  \   S
\S\
4S jjrSSS.S\R                  \   S\R                  \   S
\S\
4S jjrS\S\
4S jr\\\S.S\S\R                  \   S\S\R                  \R$                  \\R                  \   4      S\R                  \   S\
4S jjrS\SS4S jrSrg)DataSourcesClient   client_wrapperc                    Xl         g N_client_wrapperselfr   s     c/home/james-whalen/.local/lib/python3.13/site-packages/llama_cloud/resources/data_sources/client.py__init__DataSourcesClient.__init__        -    N
project_idorganization_idr"   r#   returnc          	         U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      U R                   R                  5       SS9nSUR                  s=::  a  S:  a=  O  O:[        R                  " [        R                  [           UR                  5       5      $ UR                  S	:X  a2  [!        [        R                  " ["        UR                  5       5      5      e UR                  5       n['        UR                  US
9e! [$         a    ['        UR                  UR(                  S
9ef = f)aJ  
List data sources for a given project.
If project_id is not provided, uses the default project.

Parameters:
    - project_id: typing.Optional[str].

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

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.list_data_sources()
GET/api/v1/data-sourcesr!   <   paramsheaderstimeout   ,    status_codebodyr   httpx_clientrequesturllibparseurljoinget_base_urlr	   get_headersr2   pydanticparse_obj_astypingListr   jsonr
   r   r   r   textr   r"   r#   	_response_response_jsons        r   list_data_sources#DataSourcesClient.list_data_sources#   s.   & ((55==LL  D$8$8$E$E$G#H!JLab(
)gh((446 > 
	 )''-#-((Z)@)..BRSS  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   D? ?)E(r6   c          	         U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      [        U5      U R                   R                  5       SS9nSUR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S	:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US
9e! ["         a    [%        UR                  UR&                  S
9ef = f)a  
Create a new data source.

Parameters:
    - project_id: typing.Optional[str].

    - organization_id: typing.Optional[str].

    - request: DataSourceCreate.
---
from llama_cloud import ConfigurableDataSourceNames, DataSourceCreate
from llama_cloud.client import LlamaCloud

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.create_data_source(
    request=DataSourceCreate(
        name="string",
        source_type=ConfigurableDataSourceNames.S_3,
    ),
)
POSTr'   r(   r!   r)   r+   r@   r,   r-   r.   r/   r0   r1   r   r5   r6   r7   r8   r9   r:   r	   r   r;   r2   r<   r=   r   r@   r
   r   r   r   rA   r   r"   r#   r6   rC   rD   s         r   create_data_source$DataSourcesClient.create_data_sourceG   s-   < ((55==LL  D$8$8$E$E$G#H!JLab(
)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   D8 8)E!c          	         U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      [        U5      U R                   R                  5       SS9nSUR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S	:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US
9e! ["         a    [%        UR                  UR&                  S
9ef = f)aM  
Upserts a data source.
Updates if a data source with the same name and project_id already exists. Otherwise, creates a new data source.

Parameters:
    - project_id: typing.Optional[str].

    - organization_id: typing.Optional[str].

    - request: DataSourceCreate.
---
from llama_cloud import ConfigurableDataSourceNames, DataSourceCreate
from llama_cloud.client import LlamaCloud

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.upsert_data_source(
    request=DataSourceCreate(
        name="string",
        source_type=ConfigurableDataSourceNames.S_3,
    ),
)
PUTr'   r(   r!   r)   rI   r.   r/   r0   r1   rJ   rK   s         r   upsert_data_source$DataSourcesClient.upsert_data_sourcew   s-   > ((55==LL  D$8$8$E$E$G#H!JLab(
)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rN   data_source_idc                    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3SU 35      U R                   R                  5       SS9nSUR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S:X  a2  [        [        R                  " [        UR                  5       5      5      e UR                  5       n[!        UR                  US	9e! [         a    [!        UR                  UR"                  S	9ef = f)
z
Get a data source by ID.

Parameters:
    - data_source_id: str.
---
from llama_cloud.client import LlamaCloud

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.get_data_source(
    data_source_id="string",
)
r&   r'   api/v1/data-sources/r)   r,   r-   r.   r/   r0   r1   r   r5   r6   r7   r8   r9   r:   r;   r2   r<   r=   r   r@   r
   r   r   r   rA   r   rS   rC   rD   s       r   get_data_source!DataSourcesClient.get_data_source   s#     ((55==LL  D$8$8$E$E$G#H!JNbcqbrLst((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   D% %)Enamecustom_metadata	componentr\   source_typer]   r^   c                   SU0nU[         La  X&S'   U[         La  XFS'   U[         La  XVS'   U R                  R                  R                  S[        R
                  R                  U R                  R                  5        S3SU 35      [        U5      U R                  R                  5       SS	9nS
UR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US9e! ["         a    [%        UR                  UR&                  S9ef = f)a|  
Update a data source by ID.

Parameters:
    - data_source_id: str.

    - name: typing.Optional[str].

    - source_type: ConfigurableDataSourceNames.

    - custom_metadata: typing.Optional[typing.Dict[str, typing.Optional[DataSourceUpdateCustomMetadataValue]]].

    - component: typing.Optional[DataSourceUpdateComponent]. Component that implements the data source
---
from llama_cloud import ConfigurableDataSourceNames
from llama_cloud.client import LlamaCloud

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.update_data_source(
    data_source_id="string",
    source_type=ConfigurableDataSourceNames.S_3,
)
r_   r\   r]   r^   rP   r'   rU   r)   r@   r,   r-   r.   r/   r0   r1   OMITr   r5   r6   r7   r8   r9   r:   r   r;   r2   r<   r=   r   r@   r
   r   r   r   rA   	r   rS   r\   r_   r]   r^   _requestrC   rD   s	            r   update_data_source$DataSourcesClient.update_data_source   sh   D 3@1Mt#V$&*9&'D $-[!((55==LL  D$8$8$E$E$G#H!JNbcqbrLst!(+((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   6E )Fc                 P   U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3SU 35      U R                   R                  5       SS9nSUR                  s=::  a  S:  a   g  UR                  S	:X  a2  [        [        R                  " [        UR                  5       5      5      e UR                  5       n[        UR                  US
9e! [         a    [        UR                  UR                   S
9ef = f)z
Delete a data source by ID.

Parameters:
    - data_source_id: str.
---
from llama_cloud.client import LlamaCloud

client = LlamaCloud(
    token="YOUR_TOKEN",
)
client.data_sources.delete_data_source(
    data_source_id="string",
)
DELETEr'   rU   r)   rV   r.   r/   Nr0   r1   r   r5   r6   r7   r8   r9   r:   r;   r2   r
   r<   r=   r   r@   r   r   rA   rX   s       r   delete_data_source$DataSourcesClient.delete_data_source  s     ((55==LL  D$8$8$E$E$G#H!JNbcqbrLst((446	 > 
	 )''-#- .  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   C< <)D%r   )__name__
__module____qualname____firstlineno__r   r   r>   Optionalstrr?   r   rE   r   rL   rQ   rY   rc   r   Dictr   r   rf   rk   __static_attributes__ r    r   r   r      s   .*; . 59bf"O#__S1"OKQ??[^K_"O	Z	 "ON ,004	.O OOC(.O  -	.O
 ".O 
.Of ,004	/O OOC(/O  -	/O
 "/O 
/ObOc Oj OH &*sw@D8O8O ooc"	8O
 18O  S&//Jm:n5n)op8O ??#<=8O 
8OtO O Or    r   c                      \ rS rSrS\4S jrSSS.S\R                  \   S\R                  \   S\R                  \
   4S	 jjrSSS.S\R                  \   S\R                  \   S
\S\
4S jjrSSS.S\R                  \   S\R                  \   S
\S\
4S jjrS\S\
4S jr\\\S.S\S\R                  \   S\S\R                  \R$                  \\R                  \   4      S\R                  \   S\
4S jjrS\SS4S jrSrg)AsyncDataSourcesClienti#  r   c                    Xl         g r   r   r   s     r   r   AsyncDataSourcesClient.__init__$  r   r    Nr!   r"   r#   r$   c          	        #    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      U R                   R                  5       SS9I Sh  vN nSUR                  s=::  a  S	:  a=  O  O:[        R                  " [        R                  [           UR                  5       5      $ UR                  S
:X  a2  [!        [        R                  " ["        UR                  5       5      5      e UR                  5       n['        UR                  US9e N! [$         a    ['        UR                  UR(                  S9ef = f7f)aZ  
List data sources for a given project.
If project_id is not provided, uses the default project.

Parameters:
    - project_id: typing.Optional[str].

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

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.list_data_sources()
r&   r'   r(   r!   r)   r*   Nr.   r/   r0   r1   r4   rB   s        r   rE   (AsyncDataSourcesClient.list_data_sources'  s;    & ..;;CCLL  D$8$8$E$E$G#H!JLab(
)gh((446 D 
 
	 )''-#-((Z)@)..BRSS  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   BE7	E	
BE7%E 5E7)E44E7r6   c          	        #    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      [        U5      U R                   R                  5       SS9I Sh  vN nSUR                  s=::  a  S	:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S
:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US9e N! ["         a    [%        UR                  UR&                  S9ef = f7f)a  
Create a new data source.

Parameters:
    - project_id: typing.Optional[str].

    - organization_id: typing.Optional[str].

    - request: DataSourceCreate.
---
from llama_cloud import ConfigurableDataSourceNames, DataSourceCreate
from llama_cloud.client import AsyncLlamaCloud

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.create_data_source(
    request=DataSourceCreate(
        name="string",
        source_type=ConfigurableDataSourceNames.S_3,
    ),
)
rH   r'   r(   r!   r)   rI   Nr.   r/   r0   r1   rJ   rK   s         r   rL   )AsyncDataSourcesClient.create_data_sourceK  s:    < ..;;CCLL  D$8$8$E$E$G#H!JLab(
)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+   BE0EB	E0E .E0)E--E0c          	        #    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3S5      [        XS.5      [        U5      U R                   R                  5       SS9I Sh  vN nSUR                  s=::  a  S	:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S
:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US9e N! ["         a    [%        UR                  UR&                  S9ef = f7f)a]  
Upserts a data source.
Updates if a data source with the same name and project_id already exists. Otherwise, creates a new data source.

Parameters:
    - project_id: typing.Optional[str].

    - organization_id: typing.Optional[str].

    - request: DataSourceCreate.
---
from llama_cloud import ConfigurableDataSourceNames, DataSourceCreate
from llama_cloud.client import AsyncLlamaCloud

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.upsert_data_source(
    request=DataSourceCreate(
        name="string",
        source_type=ConfigurableDataSourceNames.S_3,
    ),
)
rP   r'   r(   r!   r)   rI   Nr.   r/   r0   r1   rJ   rK   s         r   rQ   )AsyncDataSourcesClient.upsert_data_source{  s:    > ..;;CCLL  D$8$8$E$E$G#H!JLab(
)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r~   rS   c                   #    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3SU 35      U R                   R                  5       SS9I Sh  vN nSUR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S	:X  a2  [        [        R                  " [        UR                  5       5      5      e UR                  5       n[!        UR                  US
9e N! [         a    [!        UR                  UR"                  S
9ef = f7f)z
Get a data source by ID.

Parameters:
    - data_source_id: str.
---
from llama_cloud.client import AsyncLlamaCloud

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.get_data_source(
    data_source_id="string",
)
r&   r'   rU   r)   rV   Nr.   r/   r0   r1   rW   rX   s       r   rY   &AsyncDataSourcesClient.get_data_source  s0      ..;;CCLL  D$8$8$E$E$G#H!JNbcqbrLst((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+   A>E D/B	ED1 E1)EEr[   r\   r_   r]   r^   c                (  #    SU0nU[         La  X&S'   U[         La  XFS'   U[         La  XVS'   U R                  R                  R                  S[        R
                  R                  U R                  R                  5        S3SU 35      [        U5      U R                  R                  5       SS	9I S
h  vN nSUR                  s=::  a  S:  a,  O  O)[        R                  " [        UR                  5       5      $ UR                  S:X  a2  [        [        R                  " [         UR                  5       5      5      e UR                  5       n[%        UR                  US9e N! ["         a    [%        UR                  UR&                  S9ef = f7f)a  
Update a data source by ID.

Parameters:
    - data_source_id: str.

    - name: typing.Optional[str].

    - source_type: ConfigurableDataSourceNames.

    - custom_metadata: typing.Optional[typing.Dict[str, typing.Optional[DataSourceUpdateCustomMetadataValue]]].

    - component: typing.Optional[DataSourceUpdateComponent]. Component that implements the data source
---
from llama_cloud import ConfigurableDataSourceNames
from llama_cloud.client import AsyncLlamaCloud

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.update_data_source(
    data_source_id="string",
    source_type=ConfigurableDataSourceNames.S_3,
)
r_   r\   r]   r^   rP   r'   rU   r)   ra   Nr.   r/   r0   r1   rb   rd   s	            r   rf   )AsyncDataSourcesClient.update_data_source  su    D 3@1Mt#V$&*9&'D $-[!..;;CCLL  D$8$8$E$E$G#H!JNbcqbrLst!(+((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+   B3F5E$6B	F E& F&)FFc                 l  #    U R                   R                  R                  S[        R                  R                  U R                   R                  5        S3SU 35      U R                   R                  5       SS9I Sh  vN nSUR                  s=::  a  S:  a   g  UR                  S	:X  a2  [        [        R                  " [        UR                  5       5      5      e UR                  5       n[        UR                  US
9e N! [         a    [        UR                  UR                   S
9ef = f7f)z
Delete a data source by ID.

Parameters:
    - data_source_id: str.
---
from llama_cloud.client import AsyncLlamaCloud

client = AsyncLlamaCloud(
    token="YOUR_TOKEN",
)
await client.data_sources.delete_data_source(
    data_source_id="string",
)
ri   r'   rU   r)   rV   Nr.   r/   r0   r1   rj   rX   s       r   rk   )AsyncDataSourcesClient.delete_data_source  s      ..;;CCLL  D$8$8$E$E$G#H!JNbcqbrLst((446	 D 
 
	 )''-#- .  C'*8+@+@ATV_VdVdVf+ghh	S&^^-N 9#8#8~NN
  	Sy'<'<9>>RR	Ss+   A>D4 DA D4"D 2D4)D11D4r   )rm   rn   ro   rp   r   r   r>   rq   rr   r?   r   rE   r   rL   rQ   rY   rc   r   rs   r   r   rf   rk   rt   ru   r    r   rw   rw   #  s   .*< . 59bf"O#__S1"OKQ??[^K_"O	Z	 "ON ,004	.O OOC(.O  -	.O
 ".O 
.Of ,004	/O OOC(/O  -	/O
 "/O 
/ObOC OJ OH &*sw@D8O8O ooc"	8O
 18O  S&//Jm:n5n)op8O ??#<=8O 
8OtOs Ot Or    rw   )'r>   urllib.parser7   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.jsonable_encoderr   core.remove_none_from_dictr	   !errors.unprocessable_entity_errorr
   $types.configurable_data_source_namesr   types.data_sourcer   types.data_source_creater   types.http_validation_errorr   "types.data_source_update_componentr   .types.data_source_update_custom_metadata_valuer   r<   __version__
startswithImportErrorpydantic.v1v1castAnyrc   r   rw   ru   r    r   <module>r      s      ( & H 5 ? I O + 8 > I _&&t,,"
 {{6::s#AO AOHAO AOW  s   ,B2 2
B?>B?