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