llama-cloud 0.0.8__py3-none-any.whl → 0.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of llama-cloud might be problematic. Click here for more details.

Files changed (32) hide show
  1. llama_cloud/__init__.py +16 -0
  2. llama_cloud/client.py +3 -0
  3. llama_cloud/resources/__init__.py +13 -1
  4. llama_cloud/resources/data_sinks/client.py +40 -8
  5. llama_cloud/resources/data_sources/client.py +48 -12
  6. llama_cloud/resources/data_sources/types/data_source_update_component_one.py +2 -0
  7. llama_cloud/resources/extraction/client.py +4 -20
  8. llama_cloud/resources/organizations/__init__.py +2 -0
  9. llama_cloud/resources/organizations/client.py +786 -0
  10. llama_cloud/resources/pipelines/client.py +166 -10
  11. llama_cloud/resources/projects/client.py +28 -8
  12. llama_cloud/types/__init__.py +14 -0
  13. llama_cloud/types/chat_params.py +38 -0
  14. llama_cloud/types/cloud_jira_data_source.py +43 -0
  15. llama_cloud/types/cloud_sharepoint_data_source.py +1 -0
  16. llama_cloud/types/configurable_data_source_names.py +4 -0
  17. llama_cloud/types/data_source_component_one.py +2 -0
  18. llama_cloud/types/data_source_create_component_one.py +2 -0
  19. llama_cloud/types/eval_dataset_job_record.py +1 -0
  20. llama_cloud/types/extraction_schema.py +0 -1
  21. llama_cloud/types/organization.py +38 -0
  22. llama_cloud/types/organization_create.py +35 -0
  23. llama_cloud/types/pipeline_data_source_component_one.py +2 -0
  24. llama_cloud/types/preset_retrieval_params.py +5 -0
  25. llama_cloud/types/project.py +1 -1
  26. llama_cloud/types/retrieval_mode.py +29 -0
  27. llama_cloud/types/user_organization.py +40 -0
  28. llama_cloud/types/user_organization_create.py +36 -0
  29. {llama_cloud-0.0.8.dist-info → llama_cloud-0.0.9.dist-info}/METADATA +2 -1
  30. {llama_cloud-0.0.8.dist-info → llama_cloud-0.0.9.dist-info}/RECORD +32 -23
  31. {llama_cloud-0.0.8.dist-info → llama_cloud-0.0.9.dist-info}/WHEEL +1 -1
  32. {llama_cloud-0.0.8.dist-info → llama_cloud-0.0.9.dist-info}/LICENSE +0 -0
@@ -0,0 +1,786 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
11
+ from ...types.http_validation_error import HttpValidationError
12
+ from ...types.organization import Organization
13
+ from ...types.organization_create import OrganizationCreate
14
+ from ...types.user_organization import UserOrganization
15
+ from ...types.user_organization_create import UserOrganizationCreate
16
+
17
+ try:
18
+ import pydantic
19
+ if pydantic.__version__.startswith("1."):
20
+ raise ImportError
21
+ import pydantic.v1 as pydantic # type: ignore
22
+ except ImportError:
23
+ import pydantic # type: ignore
24
+
25
+ # this is used as the default value for optional parameters
26
+ OMIT = typing.cast(typing.Any, ...)
27
+
28
+
29
+ class OrganizationsClient:
30
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
31
+ self._client_wrapper = client_wrapper
32
+
33
+ def list_organizations(self) -> typing.List[Organization]:
34
+ """
35
+ List organizations for a user.
36
+
37
+ ---
38
+ from llama_cloud.client import LlamaCloud
39
+
40
+ client = LlamaCloud(
41
+ token="YOUR_TOKEN",
42
+ )
43
+ client.organizations.list_organizations()
44
+ """
45
+ _response = self._client_wrapper.httpx_client.request(
46
+ "GET",
47
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
48
+ headers=self._client_wrapper.get_headers(),
49
+ timeout=60,
50
+ )
51
+ if 200 <= _response.status_code < 300:
52
+ return pydantic.parse_obj_as(typing.List[Organization], _response.json()) # type: ignore
53
+ if _response.status_code == 422:
54
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
55
+ try:
56
+ _response_json = _response.json()
57
+ except JSONDecodeError:
58
+ raise ApiError(status_code=_response.status_code, body=_response.text)
59
+ raise ApiError(status_code=_response.status_code, body=_response_json)
60
+
61
+ def create_organization(self, *, request: OrganizationCreate) -> Organization:
62
+ """
63
+ Create a new organization.
64
+
65
+ Parameters:
66
+ - request: OrganizationCreate.
67
+ ---
68
+ from llama_cloud import OrganizationCreate
69
+ from llama_cloud.client import LlamaCloud
70
+
71
+ client = LlamaCloud(
72
+ token="YOUR_TOKEN",
73
+ )
74
+ client.organizations.create_organization(
75
+ request=OrganizationCreate(
76
+ name="string",
77
+ ),
78
+ )
79
+ """
80
+ _response = self._client_wrapper.httpx_client.request(
81
+ "POST",
82
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
83
+ json=jsonable_encoder(request),
84
+ headers=self._client_wrapper.get_headers(),
85
+ timeout=60,
86
+ )
87
+ if 200 <= _response.status_code < 300:
88
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
89
+ if _response.status_code == 422:
90
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
91
+ try:
92
+ _response_json = _response.json()
93
+ except JSONDecodeError:
94
+ raise ApiError(status_code=_response.status_code, body=_response.text)
95
+ raise ApiError(status_code=_response.status_code, body=_response_json)
96
+
97
+ def upsert_organization(self, *, request: OrganizationCreate) -> Organization:
98
+ """
99
+ Upsert a new organization.
100
+
101
+ Parameters:
102
+ - request: OrganizationCreate.
103
+ ---
104
+ from llama_cloud import OrganizationCreate
105
+ from llama_cloud.client import LlamaCloud
106
+
107
+ client = LlamaCloud(
108
+ token="YOUR_TOKEN",
109
+ )
110
+ client.organizations.upsert_organization(
111
+ request=OrganizationCreate(
112
+ name="string",
113
+ ),
114
+ )
115
+ """
116
+ _response = self._client_wrapper.httpx_client.request(
117
+ "PUT",
118
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
119
+ json=jsonable_encoder(request),
120
+ headers=self._client_wrapper.get_headers(),
121
+ timeout=60,
122
+ )
123
+ if 200 <= _response.status_code < 300:
124
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
125
+ if _response.status_code == 422:
126
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
127
+ try:
128
+ _response_json = _response.json()
129
+ except JSONDecodeError:
130
+ raise ApiError(status_code=_response.status_code, body=_response.text)
131
+ raise ApiError(status_code=_response.status_code, body=_response_json)
132
+
133
+ def get_default_organization(self) -> Organization:
134
+ """
135
+ Get the default organization for the user.
136
+
137
+ ---
138
+ from llama_cloud.client import LlamaCloud
139
+
140
+ client = LlamaCloud(
141
+ token="YOUR_TOKEN",
142
+ )
143
+ client.organizations.get_default_organization()
144
+ """
145
+ _response = self._client_wrapper.httpx_client.request(
146
+ "GET",
147
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations/default"),
148
+ headers=self._client_wrapper.get_headers(),
149
+ timeout=60,
150
+ )
151
+ if 200 <= _response.status_code < 300:
152
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
153
+ if _response.status_code == 422:
154
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
155
+ try:
156
+ _response_json = _response.json()
157
+ except JSONDecodeError:
158
+ raise ApiError(status_code=_response.status_code, body=_response.text)
159
+ raise ApiError(status_code=_response.status_code, body=_response_json)
160
+
161
+ def set_default_organization(self, *, organization_id: str) -> Organization:
162
+ """
163
+ Set the default organization for the user.
164
+
165
+ Parameters:
166
+ - organization_id: str. The organization's ID.
167
+ ---
168
+ from llama_cloud.client import LlamaCloud
169
+
170
+ client = LlamaCloud(
171
+ token="YOUR_TOKEN",
172
+ )
173
+ client.organizations.set_default_organization(
174
+ organization_id="string",
175
+ )
176
+ """
177
+ _response = self._client_wrapper.httpx_client.request(
178
+ "PUT",
179
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations/default"),
180
+ json=jsonable_encoder({"organization_id": organization_id}),
181
+ headers=self._client_wrapper.get_headers(),
182
+ timeout=60,
183
+ )
184
+ if 200 <= _response.status_code < 300:
185
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
186
+ if _response.status_code == 422:
187
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
188
+ try:
189
+ _response_json = _response.json()
190
+ except JSONDecodeError:
191
+ raise ApiError(status_code=_response.status_code, body=_response.text)
192
+ raise ApiError(status_code=_response.status_code, body=_response_json)
193
+
194
+ def get_organization(self, organization_id: str) -> Organization:
195
+ """
196
+ Get an organization by ID.
197
+
198
+ Parameters:
199
+ - organization_id: str.
200
+ ---
201
+ from llama_cloud.client import LlamaCloud
202
+
203
+ client = LlamaCloud(
204
+ token="YOUR_TOKEN",
205
+ )
206
+ client.organizations.get_organization(
207
+ organization_id="string",
208
+ )
209
+ """
210
+ _response = self._client_wrapper.httpx_client.request(
211
+ "GET",
212
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
213
+ headers=self._client_wrapper.get_headers(),
214
+ timeout=60,
215
+ )
216
+ if 200 <= _response.status_code < 300:
217
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
218
+ if _response.status_code == 422:
219
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
220
+ try:
221
+ _response_json = _response.json()
222
+ except JSONDecodeError:
223
+ raise ApiError(status_code=_response.status_code, body=_response.text)
224
+ raise ApiError(status_code=_response.status_code, body=_response_json)
225
+
226
+ def update_organization(self, organization_id: str, *, name: typing.Optional[str] = OMIT) -> Organization:
227
+ """
228
+ Update an existing organization.
229
+
230
+ Parameters:
231
+ - organization_id: str.
232
+
233
+ - name: typing.Optional[str]. A name for the organization.
234
+ ---
235
+ from llama_cloud.client import LlamaCloud
236
+
237
+ client = LlamaCloud(
238
+ token="YOUR_TOKEN",
239
+ )
240
+ client.organizations.update_organization(
241
+ organization_id="string",
242
+ )
243
+ """
244
+ _request: typing.Dict[str, typing.Any] = {}
245
+ if name is not OMIT:
246
+ _request["name"] = name
247
+ _response = self._client_wrapper.httpx_client.request(
248
+ "PUT",
249
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
250
+ json=jsonable_encoder(_request),
251
+ headers=self._client_wrapper.get_headers(),
252
+ timeout=60,
253
+ )
254
+ if 200 <= _response.status_code < 300:
255
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
256
+ if _response.status_code == 422:
257
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
258
+ try:
259
+ _response_json = _response.json()
260
+ except JSONDecodeError:
261
+ raise ApiError(status_code=_response.status_code, body=_response.text)
262
+ raise ApiError(status_code=_response.status_code, body=_response_json)
263
+
264
+ def delete_organization(self, organization_id: str) -> None:
265
+ """
266
+ Delete an organization by ID.
267
+
268
+ Parameters:
269
+ - organization_id: str.
270
+ ---
271
+ from llama_cloud.client import LlamaCloud
272
+
273
+ client = LlamaCloud(
274
+ token="YOUR_TOKEN",
275
+ )
276
+ client.organizations.delete_organization(
277
+ organization_id="string",
278
+ )
279
+ """
280
+ _response = self._client_wrapper.httpx_client.request(
281
+ "DELETE",
282
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
283
+ headers=self._client_wrapper.get_headers(),
284
+ timeout=60,
285
+ )
286
+ if 200 <= _response.status_code < 300:
287
+ return
288
+ if _response.status_code == 422:
289
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
290
+ try:
291
+ _response_json = _response.json()
292
+ except JSONDecodeError:
293
+ raise ApiError(status_code=_response.status_code, body=_response.text)
294
+ raise ApiError(status_code=_response.status_code, body=_response_json)
295
+
296
+ def list_organization_users(self, organization_id: str) -> typing.List[UserOrganization]:
297
+ """
298
+ Get all users in an organization.
299
+
300
+ Parameters:
301
+ - organization_id: str.
302
+ ---
303
+ from llama_cloud.client import LlamaCloud
304
+
305
+ client = LlamaCloud(
306
+ token="YOUR_TOKEN",
307
+ )
308
+ client.organizations.list_organization_users(
309
+ organization_id="string",
310
+ )
311
+ """
312
+ _response = self._client_wrapper.httpx_client.request(
313
+ "GET",
314
+ urllib.parse.urljoin(
315
+ f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}/users"
316
+ ),
317
+ headers=self._client_wrapper.get_headers(),
318
+ timeout=60,
319
+ )
320
+ if 200 <= _response.status_code < 300:
321
+ return pydantic.parse_obj_as(typing.List[UserOrganization], _response.json()) # type: ignore
322
+ if _response.status_code == 422:
323
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
324
+ try:
325
+ _response_json = _response.json()
326
+ except JSONDecodeError:
327
+ raise ApiError(status_code=_response.status_code, body=_response.text)
328
+ raise ApiError(status_code=_response.status_code, body=_response_json)
329
+
330
+ def add_users_to_organization(
331
+ self, organization_id: str, *, request: typing.List[UserOrganizationCreate]
332
+ ) -> typing.List[UserOrganization]:
333
+ """
334
+ Add a user to an organization.
335
+
336
+ Parameters:
337
+ - organization_id: str.
338
+
339
+ - request: typing.List[UserOrganizationCreate].
340
+ ---
341
+ from llama_cloud.client import LlamaCloud
342
+
343
+ client = LlamaCloud(
344
+ token="YOUR_TOKEN",
345
+ )
346
+ client.organizations.add_users_to_organization(
347
+ organization_id="string",
348
+ request=[],
349
+ )
350
+ """
351
+ _response = self._client_wrapper.httpx_client.request(
352
+ "PUT",
353
+ urllib.parse.urljoin(
354
+ f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}/users"
355
+ ),
356
+ json=jsonable_encoder(request),
357
+ headers=self._client_wrapper.get_headers(),
358
+ timeout=60,
359
+ )
360
+ if 200 <= _response.status_code < 300:
361
+ return pydantic.parse_obj_as(typing.List[UserOrganization], _response.json()) # type: ignore
362
+ if _response.status_code == 422:
363
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
364
+ try:
365
+ _response_json = _response.json()
366
+ except JSONDecodeError:
367
+ raise ApiError(status_code=_response.status_code, body=_response.text)
368
+ raise ApiError(status_code=_response.status_code, body=_response_json)
369
+
370
+ def remove_users_from_organization(self, organization_id: str, member_user_id: str) -> None:
371
+ """
372
+ Remove users from an organization by email.
373
+
374
+ Parameters:
375
+ - organization_id: str.
376
+
377
+ - member_user_id: str.
378
+ ---
379
+ from llama_cloud.client import LlamaCloud
380
+
381
+ client = LlamaCloud(
382
+ token="YOUR_TOKEN",
383
+ )
384
+ client.organizations.remove_users_from_organization(
385
+ organization_id="string",
386
+ member_user_id="string",
387
+ )
388
+ """
389
+ _response = self._client_wrapper.httpx_client.request(
390
+ "DELETE",
391
+ urllib.parse.urljoin(
392
+ f"{self._client_wrapper.get_base_url()}/",
393
+ f"api/v1/organizations/{organization_id}/users/{member_user_id}",
394
+ ),
395
+ headers=self._client_wrapper.get_headers(),
396
+ timeout=60,
397
+ )
398
+ if 200 <= _response.status_code < 300:
399
+ return
400
+ if _response.status_code == 422:
401
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
402
+ try:
403
+ _response_json = _response.json()
404
+ except JSONDecodeError:
405
+ raise ApiError(status_code=_response.status_code, body=_response.text)
406
+ raise ApiError(status_code=_response.status_code, body=_response_json)
407
+
408
+
409
+ class AsyncOrganizationsClient:
410
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
411
+ self._client_wrapper = client_wrapper
412
+
413
+ async def list_organizations(self) -> typing.List[Organization]:
414
+ """
415
+ List organizations for a user.
416
+
417
+ ---
418
+ from llama_cloud.client import AsyncLlamaCloud
419
+
420
+ client = AsyncLlamaCloud(
421
+ token="YOUR_TOKEN",
422
+ )
423
+ await client.organizations.list_organizations()
424
+ """
425
+ _response = await self._client_wrapper.httpx_client.request(
426
+ "GET",
427
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
428
+ headers=self._client_wrapper.get_headers(),
429
+ timeout=60,
430
+ )
431
+ if 200 <= _response.status_code < 300:
432
+ return pydantic.parse_obj_as(typing.List[Organization], _response.json()) # type: ignore
433
+ if _response.status_code == 422:
434
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
435
+ try:
436
+ _response_json = _response.json()
437
+ except JSONDecodeError:
438
+ raise ApiError(status_code=_response.status_code, body=_response.text)
439
+ raise ApiError(status_code=_response.status_code, body=_response_json)
440
+
441
+ async def create_organization(self, *, request: OrganizationCreate) -> Organization:
442
+ """
443
+ Create a new organization.
444
+
445
+ Parameters:
446
+ - request: OrganizationCreate.
447
+ ---
448
+ from llama_cloud import OrganizationCreate
449
+ from llama_cloud.client import AsyncLlamaCloud
450
+
451
+ client = AsyncLlamaCloud(
452
+ token="YOUR_TOKEN",
453
+ )
454
+ await client.organizations.create_organization(
455
+ request=OrganizationCreate(
456
+ name="string",
457
+ ),
458
+ )
459
+ """
460
+ _response = await self._client_wrapper.httpx_client.request(
461
+ "POST",
462
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
463
+ json=jsonable_encoder(request),
464
+ headers=self._client_wrapper.get_headers(),
465
+ timeout=60,
466
+ )
467
+ if 200 <= _response.status_code < 300:
468
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
469
+ if _response.status_code == 422:
470
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
471
+ try:
472
+ _response_json = _response.json()
473
+ except JSONDecodeError:
474
+ raise ApiError(status_code=_response.status_code, body=_response.text)
475
+ raise ApiError(status_code=_response.status_code, body=_response_json)
476
+
477
+ async def upsert_organization(self, *, request: OrganizationCreate) -> Organization:
478
+ """
479
+ Upsert a new organization.
480
+
481
+ Parameters:
482
+ - request: OrganizationCreate.
483
+ ---
484
+ from llama_cloud import OrganizationCreate
485
+ from llama_cloud.client import AsyncLlamaCloud
486
+
487
+ client = AsyncLlamaCloud(
488
+ token="YOUR_TOKEN",
489
+ )
490
+ await client.organizations.upsert_organization(
491
+ request=OrganizationCreate(
492
+ name="string",
493
+ ),
494
+ )
495
+ """
496
+ _response = await self._client_wrapper.httpx_client.request(
497
+ "PUT",
498
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations"),
499
+ json=jsonable_encoder(request),
500
+ headers=self._client_wrapper.get_headers(),
501
+ timeout=60,
502
+ )
503
+ if 200 <= _response.status_code < 300:
504
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
505
+ if _response.status_code == 422:
506
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
507
+ try:
508
+ _response_json = _response.json()
509
+ except JSONDecodeError:
510
+ raise ApiError(status_code=_response.status_code, body=_response.text)
511
+ raise ApiError(status_code=_response.status_code, body=_response_json)
512
+
513
+ async def get_default_organization(self) -> Organization:
514
+ """
515
+ Get the default organization for the user.
516
+
517
+ ---
518
+ from llama_cloud.client import AsyncLlamaCloud
519
+
520
+ client = AsyncLlamaCloud(
521
+ token="YOUR_TOKEN",
522
+ )
523
+ await client.organizations.get_default_organization()
524
+ """
525
+ _response = await self._client_wrapper.httpx_client.request(
526
+ "GET",
527
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations/default"),
528
+ headers=self._client_wrapper.get_headers(),
529
+ timeout=60,
530
+ )
531
+ if 200 <= _response.status_code < 300:
532
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
533
+ if _response.status_code == 422:
534
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
535
+ try:
536
+ _response_json = _response.json()
537
+ except JSONDecodeError:
538
+ raise ApiError(status_code=_response.status_code, body=_response.text)
539
+ raise ApiError(status_code=_response.status_code, body=_response_json)
540
+
541
+ async def set_default_organization(self, *, organization_id: str) -> Organization:
542
+ """
543
+ Set the default organization for the user.
544
+
545
+ Parameters:
546
+ - organization_id: str. The organization's ID.
547
+ ---
548
+ from llama_cloud.client import AsyncLlamaCloud
549
+
550
+ client = AsyncLlamaCloud(
551
+ token="YOUR_TOKEN",
552
+ )
553
+ await client.organizations.set_default_organization(
554
+ organization_id="string",
555
+ )
556
+ """
557
+ _response = await self._client_wrapper.httpx_client.request(
558
+ "PUT",
559
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/organizations/default"),
560
+ json=jsonable_encoder({"organization_id": organization_id}),
561
+ headers=self._client_wrapper.get_headers(),
562
+ timeout=60,
563
+ )
564
+ if 200 <= _response.status_code < 300:
565
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
566
+ if _response.status_code == 422:
567
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
568
+ try:
569
+ _response_json = _response.json()
570
+ except JSONDecodeError:
571
+ raise ApiError(status_code=_response.status_code, body=_response.text)
572
+ raise ApiError(status_code=_response.status_code, body=_response_json)
573
+
574
+ async def get_organization(self, organization_id: str) -> Organization:
575
+ """
576
+ Get an organization by ID.
577
+
578
+ Parameters:
579
+ - organization_id: str.
580
+ ---
581
+ from llama_cloud.client import AsyncLlamaCloud
582
+
583
+ client = AsyncLlamaCloud(
584
+ token="YOUR_TOKEN",
585
+ )
586
+ await client.organizations.get_organization(
587
+ organization_id="string",
588
+ )
589
+ """
590
+ _response = await self._client_wrapper.httpx_client.request(
591
+ "GET",
592
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
593
+ headers=self._client_wrapper.get_headers(),
594
+ timeout=60,
595
+ )
596
+ if 200 <= _response.status_code < 300:
597
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
598
+ if _response.status_code == 422:
599
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
600
+ try:
601
+ _response_json = _response.json()
602
+ except JSONDecodeError:
603
+ raise ApiError(status_code=_response.status_code, body=_response.text)
604
+ raise ApiError(status_code=_response.status_code, body=_response_json)
605
+
606
+ async def update_organization(self, organization_id: str, *, name: typing.Optional[str] = OMIT) -> Organization:
607
+ """
608
+ Update an existing organization.
609
+
610
+ Parameters:
611
+ - organization_id: str.
612
+
613
+ - name: typing.Optional[str]. A name for the organization.
614
+ ---
615
+ from llama_cloud.client import AsyncLlamaCloud
616
+
617
+ client = AsyncLlamaCloud(
618
+ token="YOUR_TOKEN",
619
+ )
620
+ await client.organizations.update_organization(
621
+ organization_id="string",
622
+ )
623
+ """
624
+ _request: typing.Dict[str, typing.Any] = {}
625
+ if name is not OMIT:
626
+ _request["name"] = name
627
+ _response = await self._client_wrapper.httpx_client.request(
628
+ "PUT",
629
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
630
+ json=jsonable_encoder(_request),
631
+ headers=self._client_wrapper.get_headers(),
632
+ timeout=60,
633
+ )
634
+ if 200 <= _response.status_code < 300:
635
+ return pydantic.parse_obj_as(Organization, _response.json()) # type: ignore
636
+ if _response.status_code == 422:
637
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
638
+ try:
639
+ _response_json = _response.json()
640
+ except JSONDecodeError:
641
+ raise ApiError(status_code=_response.status_code, body=_response.text)
642
+ raise ApiError(status_code=_response.status_code, body=_response_json)
643
+
644
+ async def delete_organization(self, organization_id: str) -> None:
645
+ """
646
+ Delete an organization by ID.
647
+
648
+ Parameters:
649
+ - organization_id: str.
650
+ ---
651
+ from llama_cloud.client import AsyncLlamaCloud
652
+
653
+ client = AsyncLlamaCloud(
654
+ token="YOUR_TOKEN",
655
+ )
656
+ await client.organizations.delete_organization(
657
+ organization_id="string",
658
+ )
659
+ """
660
+ _response = await self._client_wrapper.httpx_client.request(
661
+ "DELETE",
662
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}"),
663
+ headers=self._client_wrapper.get_headers(),
664
+ timeout=60,
665
+ )
666
+ if 200 <= _response.status_code < 300:
667
+ return
668
+ if _response.status_code == 422:
669
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
670
+ try:
671
+ _response_json = _response.json()
672
+ except JSONDecodeError:
673
+ raise ApiError(status_code=_response.status_code, body=_response.text)
674
+ raise ApiError(status_code=_response.status_code, body=_response_json)
675
+
676
+ async def list_organization_users(self, organization_id: str) -> typing.List[UserOrganization]:
677
+ """
678
+ Get all users in an organization.
679
+
680
+ Parameters:
681
+ - organization_id: str.
682
+ ---
683
+ from llama_cloud.client import AsyncLlamaCloud
684
+
685
+ client = AsyncLlamaCloud(
686
+ token="YOUR_TOKEN",
687
+ )
688
+ await client.organizations.list_organization_users(
689
+ organization_id="string",
690
+ )
691
+ """
692
+ _response = await self._client_wrapper.httpx_client.request(
693
+ "GET",
694
+ urllib.parse.urljoin(
695
+ f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}/users"
696
+ ),
697
+ headers=self._client_wrapper.get_headers(),
698
+ timeout=60,
699
+ )
700
+ if 200 <= _response.status_code < 300:
701
+ return pydantic.parse_obj_as(typing.List[UserOrganization], _response.json()) # type: ignore
702
+ if _response.status_code == 422:
703
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
704
+ try:
705
+ _response_json = _response.json()
706
+ except JSONDecodeError:
707
+ raise ApiError(status_code=_response.status_code, body=_response.text)
708
+ raise ApiError(status_code=_response.status_code, body=_response_json)
709
+
710
+ async def add_users_to_organization(
711
+ self, organization_id: str, *, request: typing.List[UserOrganizationCreate]
712
+ ) -> typing.List[UserOrganization]:
713
+ """
714
+ Add a user to an organization.
715
+
716
+ Parameters:
717
+ - organization_id: str.
718
+
719
+ - request: typing.List[UserOrganizationCreate].
720
+ ---
721
+ from llama_cloud.client import AsyncLlamaCloud
722
+
723
+ client = AsyncLlamaCloud(
724
+ token="YOUR_TOKEN",
725
+ )
726
+ await client.organizations.add_users_to_organization(
727
+ organization_id="string",
728
+ request=[],
729
+ )
730
+ """
731
+ _response = await self._client_wrapper.httpx_client.request(
732
+ "PUT",
733
+ urllib.parse.urljoin(
734
+ f"{self._client_wrapper.get_base_url()}/", f"api/v1/organizations/{organization_id}/users"
735
+ ),
736
+ json=jsonable_encoder(request),
737
+ headers=self._client_wrapper.get_headers(),
738
+ timeout=60,
739
+ )
740
+ if 200 <= _response.status_code < 300:
741
+ return pydantic.parse_obj_as(typing.List[UserOrganization], _response.json()) # type: ignore
742
+ if _response.status_code == 422:
743
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
744
+ try:
745
+ _response_json = _response.json()
746
+ except JSONDecodeError:
747
+ raise ApiError(status_code=_response.status_code, body=_response.text)
748
+ raise ApiError(status_code=_response.status_code, body=_response_json)
749
+
750
+ async def remove_users_from_organization(self, organization_id: str, member_user_id: str) -> None:
751
+ """
752
+ Remove users from an organization by email.
753
+
754
+ Parameters:
755
+ - organization_id: str.
756
+
757
+ - member_user_id: str.
758
+ ---
759
+ from llama_cloud.client import AsyncLlamaCloud
760
+
761
+ client = AsyncLlamaCloud(
762
+ token="YOUR_TOKEN",
763
+ )
764
+ await client.organizations.remove_users_from_organization(
765
+ organization_id="string",
766
+ member_user_id="string",
767
+ )
768
+ """
769
+ _response = await self._client_wrapper.httpx_client.request(
770
+ "DELETE",
771
+ urllib.parse.urljoin(
772
+ f"{self._client_wrapper.get_base_url()}/",
773
+ f"api/v1/organizations/{organization_id}/users/{member_user_id}",
774
+ ),
775
+ headers=self._client_wrapper.get_headers(),
776
+ timeout=60,
777
+ )
778
+ if 200 <= _response.status_code < 300:
779
+ return
780
+ if _response.status_code == 422:
781
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
782
+ try:
783
+ _response_json = _response.json()
784
+ except JSONDecodeError:
785
+ raise ApiError(status_code=_response.status_code, body=_response.text)
786
+ raise ApiError(status_code=_response.status_code, body=_response_json)