llama-cloud 0.0.4__py3-none-any.whl → 0.0.6__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.

@@ -1,231 +0,0 @@
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 ...core.remove_none_from_dict import remove_none_from_dict
11
- from ...errors.unprocessable_entity_error import UnprocessableEntityError
12
- from ...types.http_validation_error import HttpValidationError
13
-
14
- try:
15
- import pydantic
16
- if pydantic.__version__.startswith("1."):
17
- raise ImportError
18
- import pydantic.v1 as pydantic # type: ignore
19
- except ImportError:
20
- import pydantic # type: ignore
21
-
22
- # this is used as the default value for optional parameters
23
- OMIT = typing.cast(typing.Any, ...)
24
-
25
-
26
- class BillingClient:
27
- def __init__(self, *, client_wrapper: SyncClientWrapper):
28
- self._client_wrapper = client_wrapper
29
-
30
- def create_checkout_session(self, *, success_url: str, cancel_url: str) -> str:
31
- """
32
- Create a new checkout session.
33
-
34
- Parameters:
35
- - success_url: str.
36
-
37
- - cancel_url: str.
38
- ---
39
- from llama_cloud.client import LlamaCloud
40
-
41
- client = LlamaCloud(
42
- token="YOUR_TOKEN",
43
- )
44
- client.billing.create_checkout_session(
45
- success_url="string",
46
- cancel_url="string",
47
- )
48
- """
49
- _response = self._client_wrapper.httpx_client.request(
50
- "POST",
51
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/checkout-session"),
52
- json=jsonable_encoder({"success_url": success_url, "cancel_url": cancel_url}),
53
- headers=self._client_wrapper.get_headers(),
54
- timeout=60,
55
- )
56
- if 200 <= _response.status_code < 300:
57
- return pydantic.parse_obj_as(str, _response.json()) # type: ignore
58
- if _response.status_code == 422:
59
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
60
- try:
61
- _response_json = _response.json()
62
- except JSONDecodeError:
63
- raise ApiError(status_code=_response.status_code, body=_response.text)
64
- raise ApiError(status_code=_response.status_code, body=_response_json)
65
-
66
- def create_customer_portal_session(self, *, return_url: str) -> str:
67
- """
68
- Create a new customer portal session.
69
-
70
- Parameters:
71
- - return_url: str.
72
- ---
73
- from llama_cloud.client import LlamaCloud
74
-
75
- client = LlamaCloud(
76
- token="YOUR_TOKEN",
77
- )
78
- client.billing.create_customer_portal_session(
79
- return_url="string",
80
- )
81
- """
82
- _response = self._client_wrapper.httpx_client.request(
83
- "POST",
84
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/customer-portal-session"),
85
- json=jsonable_encoder({"return_url": return_url}),
86
- headers=self._client_wrapper.get_headers(),
87
- timeout=60,
88
- )
89
- if 200 <= _response.status_code < 300:
90
- return pydantic.parse_obj_as(str, _response.json()) # type: ignore
91
- if _response.status_code == 422:
92
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
93
- try:
94
- _response_json = _response.json()
95
- except JSONDecodeError:
96
- raise ApiError(status_code=_response.status_code, body=_response.text)
97
- raise ApiError(status_code=_response.status_code, body=_response_json)
98
-
99
- def stripe_webhook(self, *, stripe_signature: typing.Optional[str] = None) -> typing.Any:
100
- """
101
- Stripe webhook endpoint.
102
-
103
- Parameters:
104
- - stripe_signature: typing.Optional[str].
105
- ---
106
- from llama_cloud.client import LlamaCloud
107
-
108
- client = LlamaCloud(
109
- token="YOUR_TOKEN",
110
- )
111
- client.billing.stripe_webhook()
112
- """
113
- _response = self._client_wrapper.httpx_client.request(
114
- "POST",
115
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/webhook"),
116
- headers=remove_none_from_dict({**self._client_wrapper.get_headers(), "stripe-signature": stripe_signature}),
117
- timeout=60,
118
- )
119
- if 200 <= _response.status_code < 300:
120
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
121
- if _response.status_code == 422:
122
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
123
- try:
124
- _response_json = _response.json()
125
- except JSONDecodeError:
126
- raise ApiError(status_code=_response.status_code, body=_response.text)
127
- raise ApiError(status_code=_response.status_code, body=_response_json)
128
-
129
-
130
- class AsyncBillingClient:
131
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
132
- self._client_wrapper = client_wrapper
133
-
134
- async def create_checkout_session(self, *, success_url: str, cancel_url: str) -> str:
135
- """
136
- Create a new checkout session.
137
-
138
- Parameters:
139
- - success_url: str.
140
-
141
- - cancel_url: str.
142
- ---
143
- from llama_cloud.client import AsyncLlamaCloud
144
-
145
- client = AsyncLlamaCloud(
146
- token="YOUR_TOKEN",
147
- )
148
- await client.billing.create_checkout_session(
149
- success_url="string",
150
- cancel_url="string",
151
- )
152
- """
153
- _response = await self._client_wrapper.httpx_client.request(
154
- "POST",
155
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/checkout-session"),
156
- json=jsonable_encoder({"success_url": success_url, "cancel_url": cancel_url}),
157
- headers=self._client_wrapper.get_headers(),
158
- timeout=60,
159
- )
160
- if 200 <= _response.status_code < 300:
161
- return pydantic.parse_obj_as(str, _response.json()) # type: ignore
162
- if _response.status_code == 422:
163
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
164
- try:
165
- _response_json = _response.json()
166
- except JSONDecodeError:
167
- raise ApiError(status_code=_response.status_code, body=_response.text)
168
- raise ApiError(status_code=_response.status_code, body=_response_json)
169
-
170
- async def create_customer_portal_session(self, *, return_url: str) -> str:
171
- """
172
- Create a new customer portal session.
173
-
174
- Parameters:
175
- - return_url: str.
176
- ---
177
- from llama_cloud.client import AsyncLlamaCloud
178
-
179
- client = AsyncLlamaCloud(
180
- token="YOUR_TOKEN",
181
- )
182
- await client.billing.create_customer_portal_session(
183
- return_url="string",
184
- )
185
- """
186
- _response = await self._client_wrapper.httpx_client.request(
187
- "POST",
188
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/customer-portal-session"),
189
- json=jsonable_encoder({"return_url": return_url}),
190
- headers=self._client_wrapper.get_headers(),
191
- timeout=60,
192
- )
193
- if 200 <= _response.status_code < 300:
194
- return pydantic.parse_obj_as(str, _response.json()) # type: ignore
195
- if _response.status_code == 422:
196
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
197
- try:
198
- _response_json = _response.json()
199
- except JSONDecodeError:
200
- raise ApiError(status_code=_response.status_code, body=_response.text)
201
- raise ApiError(status_code=_response.status_code, body=_response_json)
202
-
203
- async def stripe_webhook(self, *, stripe_signature: typing.Optional[str] = None) -> typing.Any:
204
- """
205
- Stripe webhook endpoint.
206
-
207
- Parameters:
208
- - stripe_signature: typing.Optional[str].
209
- ---
210
- from llama_cloud.client import AsyncLlamaCloud
211
-
212
- client = AsyncLlamaCloud(
213
- token="YOUR_TOKEN",
214
- )
215
- await client.billing.stripe_webhook()
216
- """
217
- _response = await self._client_wrapper.httpx_client.request(
218
- "POST",
219
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/webhook"),
220
- headers=remove_none_from_dict({**self._client_wrapper.get_headers(), "stripe-signature": stripe_signature}),
221
- timeout=60,
222
- )
223
- if 200 <= _response.status_code < 300:
224
- return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
225
- if _response.status_code == 422:
226
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
227
- try:
228
- _response_json = _response.json()
229
- except JSONDecodeError:
230
- raise ApiError(status_code=_response.status_code, body=_response.text)
231
- raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,2 +0,0 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-