llama-cloud 0.0.1__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.
- llama_cloud/__init__.py +295 -0
- llama_cloud/client.py +72 -0
- llama_cloud/core/__init__.py +17 -0
- llama_cloud/core/api_error.py +15 -0
- llama_cloud/core/client_wrapper.py +51 -0
- llama_cloud/core/datetime_utils.py +28 -0
- llama_cloud/core/jsonable_encoder.py +103 -0
- llama_cloud/core/remove_none_from_dict.py +11 -0
- llama_cloud/errors/__init__.py +5 -0
- llama_cloud/errors/unprocessable_entity_error.py +9 -0
- llama_cloud/resources/__init__.py +40 -0
- llama_cloud/resources/api_keys/__init__.py +2 -0
- llama_cloud/resources/api_keys/client.py +302 -0
- llama_cloud/resources/billing/__init__.py +2 -0
- llama_cloud/resources/billing/client.py +234 -0
- llama_cloud/resources/component_definitions/__init__.py +2 -0
- llama_cloud/resources/component_definitions/client.py +192 -0
- llama_cloud/resources/data_sinks/__init__.py +5 -0
- llama_cloud/resources/data_sinks/client.py +506 -0
- llama_cloud/resources/data_sinks/types/__init__.py +6 -0
- llama_cloud/resources/data_sinks/types/data_sink_update_component.py +7 -0
- llama_cloud/resources/data_sinks/types/data_sink_update_component_one.py +17 -0
- llama_cloud/resources/data_sources/__init__.py +5 -0
- llama_cloud/resources/data_sources/client.py +521 -0
- llama_cloud/resources/data_sources/types/__init__.py +7 -0
- llama_cloud/resources/data_sources/types/data_source_update_component.py +7 -0
- llama_cloud/resources/data_sources/types/data_source_update_component_one.py +19 -0
- llama_cloud/resources/data_sources/types/data_source_update_custom_metadata_value.py +7 -0
- llama_cloud/resources/deprecated/__init__.py +2 -0
- llama_cloud/resources/deprecated/client.py +982 -0
- llama_cloud/resources/evals/__init__.py +2 -0
- llama_cloud/resources/evals/client.py +745 -0
- llama_cloud/resources/files/__init__.py +5 -0
- llama_cloud/resources/files/client.py +560 -0
- llama_cloud/resources/files/types/__init__.py +5 -0
- llama_cloud/resources/files/types/file_create_resource_info_value.py +5 -0
- llama_cloud/resources/parsing/__init__.py +2 -0
- llama_cloud/resources/parsing/client.py +982 -0
- llama_cloud/resources/pipelines/__init__.py +5 -0
- llama_cloud/resources/pipelines/client.py +2599 -0
- llama_cloud/resources/pipelines/types/__init__.py +5 -0
- llama_cloud/resources/pipelines/types/pipeline_file_update_custom_metadata_value.py +7 -0
- llama_cloud/resources/projects/__init__.py +2 -0
- llama_cloud/resources/projects/client.py +1231 -0
- llama_cloud/types/__init__.py +253 -0
- llama_cloud/types/api_key.py +37 -0
- llama_cloud/types/azure_open_ai_embedding.py +75 -0
- llama_cloud/types/base.py +26 -0
- llama_cloud/types/base_prompt_template.py +44 -0
- llama_cloud/types/bedrock_embedding.py +56 -0
- llama_cloud/types/chat_message.py +35 -0
- llama_cloud/types/cloud_az_storage_blob_data_source.py +40 -0
- llama_cloud/types/cloud_chroma_vector_store.py +40 -0
- llama_cloud/types/cloud_document.py +36 -0
- llama_cloud/types/cloud_document_create.py +36 -0
- llama_cloud/types/cloud_gcs_data_source.py +37 -0
- llama_cloud/types/cloud_google_drive_data_source.py +36 -0
- llama_cloud/types/cloud_one_drive_data_source.py +38 -0
- llama_cloud/types/cloud_pinecone_vector_store.py +46 -0
- llama_cloud/types/cloud_postgres_vector_store.py +44 -0
- llama_cloud/types/cloud_qdrant_vector_store.py +48 -0
- llama_cloud/types/cloud_s_3_data_source.py +42 -0
- llama_cloud/types/cloud_sharepoint_data_source.py +38 -0
- llama_cloud/types/cloud_weaviate_vector_store.py +38 -0
- llama_cloud/types/code_splitter.py +46 -0
- llama_cloud/types/cohere_embedding.py +46 -0
- llama_cloud/types/configurable_data_sink_names.py +37 -0
- llama_cloud/types/configurable_data_source_names.py +41 -0
- llama_cloud/types/configurable_transformation_definition.py +45 -0
- llama_cloud/types/configurable_transformation_names.py +73 -0
- llama_cloud/types/configured_transformation_item.py +43 -0
- llama_cloud/types/configured_transformation_item_component.py +9 -0
- llama_cloud/types/configured_transformation_item_component_one.py +35 -0
- llama_cloud/types/data_sink.py +40 -0
- llama_cloud/types/data_sink_component.py +7 -0
- llama_cloud/types/data_sink_component_one.py +17 -0
- llama_cloud/types/data_sink_create.py +36 -0
- llama_cloud/types/data_sink_create_component.py +7 -0
- llama_cloud/types/data_sink_create_component_one.py +17 -0
- llama_cloud/types/data_sink_definition.py +41 -0
- llama_cloud/types/data_source.py +44 -0
- llama_cloud/types/data_source_component.py +7 -0
- llama_cloud/types/data_source_component_one.py +19 -0
- llama_cloud/types/data_source_create.py +40 -0
- llama_cloud/types/data_source_create_component.py +7 -0
- llama_cloud/types/data_source_create_component_one.py +19 -0
- llama_cloud/types/data_source_create_custom_metadata_value.py +7 -0
- llama_cloud/types/data_source_custom_metadata_value.py +7 -0
- llama_cloud/types/data_source_definition.py +41 -0
- llama_cloud/types/eval_dataset.py +37 -0
- llama_cloud/types/eval_dataset_job_params.py +36 -0
- llama_cloud/types/eval_dataset_job_record.py +59 -0
- llama_cloud/types/eval_execution_params.py +38 -0
- llama_cloud/types/eval_execution_params_override.py +38 -0
- llama_cloud/types/eval_llm_model_data.py +33 -0
- llama_cloud/types/eval_question.py +39 -0
- llama_cloud/types/eval_question_create.py +28 -0
- llama_cloud/types/eval_question_result.py +49 -0
- llama_cloud/types/file.py +46 -0
- llama_cloud/types/file_resource_info_value.py +5 -0
- llama_cloud/types/filter_condition.py +21 -0
- llama_cloud/types/filter_operator.py +65 -0
- llama_cloud/types/gemini_embedding.py +51 -0
- llama_cloud/types/html_node_parser.py +44 -0
- llama_cloud/types/http_validation_error.py +29 -0
- llama_cloud/types/hugging_face_inference_api_embedding.py +68 -0
- llama_cloud/types/hugging_face_inference_api_embedding_token.py +5 -0
- llama_cloud/types/json_node_parser.py +43 -0
- llama_cloud/types/llama_parse_supported_file_extensions.py +161 -0
- llama_cloud/types/llm.py +55 -0
- llama_cloud/types/local_eval.py +46 -0
- llama_cloud/types/local_eval_results.py +37 -0
- llama_cloud/types/local_eval_sets.py +30 -0
- llama_cloud/types/managed_ingestion_status.py +37 -0
- llama_cloud/types/markdown_element_node_parser.py +49 -0
- llama_cloud/types/markdown_node_parser.py +43 -0
- llama_cloud/types/message_role.py +45 -0
- llama_cloud/types/metadata_filter.py +41 -0
- llama_cloud/types/metadata_filter_value.py +5 -0
- llama_cloud/types/metadata_filters.py +41 -0
- llama_cloud/types/metadata_filters_filters_item.py +8 -0
- llama_cloud/types/metric_result.py +30 -0
- llama_cloud/types/node_parser.py +37 -0
- llama_cloud/types/object_type.py +33 -0
- llama_cloud/types/open_ai_embedding.py +73 -0
- llama_cloud/types/parser_languages.py +361 -0
- llama_cloud/types/parsing_history_item.py +36 -0
- llama_cloud/types/parsing_job.py +30 -0
- llama_cloud/types/parsing_job_json_result.py +29 -0
- llama_cloud/types/parsing_job_markdown_result.py +29 -0
- llama_cloud/types/parsing_job_text_result.py +29 -0
- llama_cloud/types/parsing_usage.py +29 -0
- llama_cloud/types/pipeline.py +64 -0
- llama_cloud/types/pipeline_create.py +61 -0
- llama_cloud/types/pipeline_data_source.py +46 -0
- llama_cloud/types/pipeline_data_source_component.py +7 -0
- llama_cloud/types/pipeline_data_source_component_one.py +19 -0
- llama_cloud/types/pipeline_data_source_create.py +32 -0
- llama_cloud/types/pipeline_data_source_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_deployment.py +38 -0
- llama_cloud/types/pipeline_file.py +52 -0
- llama_cloud/types/pipeline_file_create.py +36 -0
- llama_cloud/types/pipeline_file_create_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_file_custom_metadata_value.py +7 -0
- llama_cloud/types/pipeline_file_resource_info_value.py +7 -0
- llama_cloud/types/pipeline_file_status_response.py +35 -0
- llama_cloud/types/pipeline_type.py +21 -0
- llama_cloud/types/pooling.py +29 -0
- llama_cloud/types/preset_retrieval_params.py +40 -0
- llama_cloud/types/presigned_url.py +36 -0
- llama_cloud/types/project.py +42 -0
- llama_cloud/types/project_create.py +32 -0
- llama_cloud/types/prompt_mixin_prompts.py +36 -0
- llama_cloud/types/prompt_spec.py +35 -0
- llama_cloud/types/pydantic_program_mode.py +41 -0
- llama_cloud/types/related_node_info.py +37 -0
- llama_cloud/types/retrieve_results.py +40 -0
- llama_cloud/types/sentence_splitter.py +48 -0
- llama_cloud/types/simple_file_node_parser.py +44 -0
- llama_cloud/types/status_enum.py +33 -0
- llama_cloud/types/supported_eval_llm_model.py +35 -0
- llama_cloud/types/supported_eval_llm_model_names.py +29 -0
- llama_cloud/types/text_node.py +62 -0
- llama_cloud/types/text_node_relationships_value.py +7 -0
- llama_cloud/types/text_node_with_score.py +36 -0
- llama_cloud/types/token_text_splitter.py +43 -0
- llama_cloud/types/transformation_category_names.py +21 -0
- llama_cloud/types/validation_error.py +31 -0
- llama_cloud/types/validation_error_loc_item.py +5 -0
- llama_cloud-0.0.1.dist-info/LICENSE +21 -0
- llama_cloud-0.0.1.dist-info/METADATA +25 -0
- llama_cloud-0.0.1.dist-info/RECORD +173 -0
- llama_cloud-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,302 @@
|
|
|
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.api_key import ApiKey
|
|
12
|
+
from ...types.http_validation_error import HttpValidationError
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
import pydantic.v1 as pydantic # type: ignore
|
|
16
|
+
except ImportError:
|
|
17
|
+
import pydantic # type: ignore
|
|
18
|
+
|
|
19
|
+
# this is used as the default value for optional parameters
|
|
20
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ApiKeysClient:
|
|
24
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
25
|
+
self._client_wrapper = client_wrapper
|
|
26
|
+
|
|
27
|
+
def get_keys(self) -> typing.List[ApiKey]:
|
|
28
|
+
"""
|
|
29
|
+
Get all API Keys for a user.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
from platform.client import PlatformApi
|
|
33
|
+
|
|
34
|
+
client = PlatformApi(
|
|
35
|
+
token="YOUR_TOKEN",
|
|
36
|
+
base_url="https://yourhost.com/path/to/api",
|
|
37
|
+
)
|
|
38
|
+
client.api_keys.get_keys()
|
|
39
|
+
"""
|
|
40
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
41
|
+
"GET",
|
|
42
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/api-keys"),
|
|
43
|
+
headers=self._client_wrapper.get_headers(),
|
|
44
|
+
timeout=60,
|
|
45
|
+
)
|
|
46
|
+
if 200 <= _response.status_code < 300:
|
|
47
|
+
return pydantic.parse_obj_as(typing.List[ApiKey], _response.json()) # type: ignore
|
|
48
|
+
if _response.status_code == 422:
|
|
49
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
50
|
+
try:
|
|
51
|
+
_response_json = _response.json()
|
|
52
|
+
except JSONDecodeError:
|
|
53
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
54
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
55
|
+
|
|
56
|
+
def generate_key(self, *, name: typing.Optional[str] = OMIT) -> ApiKey:
|
|
57
|
+
"""
|
|
58
|
+
Generate a new API Key.
|
|
59
|
+
|
|
60
|
+
Parameters:
|
|
61
|
+
- name: typing.Optional[str].
|
|
62
|
+
---
|
|
63
|
+
from platform.client import PlatformApi
|
|
64
|
+
|
|
65
|
+
client = PlatformApi(
|
|
66
|
+
token="YOUR_TOKEN",
|
|
67
|
+
base_url="https://yourhost.com/path/to/api",
|
|
68
|
+
)
|
|
69
|
+
client.api_keys.generate_key()
|
|
70
|
+
"""
|
|
71
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
72
|
+
if name is not OMIT:
|
|
73
|
+
_request["name"] = name
|
|
74
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
75
|
+
"POST",
|
|
76
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/api-keys"),
|
|
77
|
+
json=jsonable_encoder(_request),
|
|
78
|
+
headers=self._client_wrapper.get_headers(),
|
|
79
|
+
timeout=60,
|
|
80
|
+
)
|
|
81
|
+
if 200 <= _response.status_code < 300:
|
|
82
|
+
return pydantic.parse_obj_as(ApiKey, _response.json()) # type: ignore
|
|
83
|
+
if _response.status_code == 422:
|
|
84
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
85
|
+
try:
|
|
86
|
+
_response_json = _response.json()
|
|
87
|
+
except JSONDecodeError:
|
|
88
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
89
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
90
|
+
|
|
91
|
+
def update_existing_api_key(self, api_key_id: str, *, name: typing.Optional[str] = OMIT) -> ApiKey:
|
|
92
|
+
"""
|
|
93
|
+
Update name of an existing API Key.
|
|
94
|
+
|
|
95
|
+
Parameters:
|
|
96
|
+
- api_key_id: str.
|
|
97
|
+
|
|
98
|
+
- name: typing.Optional[str].
|
|
99
|
+
---
|
|
100
|
+
from platform.client import PlatformApi
|
|
101
|
+
|
|
102
|
+
client = PlatformApi(
|
|
103
|
+
token="YOUR_TOKEN",
|
|
104
|
+
base_url="https://yourhost.com/path/to/api",
|
|
105
|
+
)
|
|
106
|
+
client.api_keys.update_existing_api_key(
|
|
107
|
+
api_key_id="string",
|
|
108
|
+
)
|
|
109
|
+
"""
|
|
110
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
111
|
+
if name is not OMIT:
|
|
112
|
+
_request["name"] = name
|
|
113
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
114
|
+
"PUT",
|
|
115
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/api-keys/{api_key_id}"),
|
|
116
|
+
json=jsonable_encoder(_request),
|
|
117
|
+
headers=self._client_wrapper.get_headers(),
|
|
118
|
+
timeout=60,
|
|
119
|
+
)
|
|
120
|
+
if 200 <= _response.status_code < 300:
|
|
121
|
+
return pydantic.parse_obj_as(ApiKey, _response.json()) # type: ignore
|
|
122
|
+
if _response.status_code == 422:
|
|
123
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
124
|
+
try:
|
|
125
|
+
_response_json = _response.json()
|
|
126
|
+
except JSONDecodeError:
|
|
127
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
128
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
129
|
+
|
|
130
|
+
def delete_api_key(self, api_key_id: str) -> None:
|
|
131
|
+
"""
|
|
132
|
+
Delete an API Key by ID.
|
|
133
|
+
|
|
134
|
+
Parameters:
|
|
135
|
+
- api_key_id: str.
|
|
136
|
+
---
|
|
137
|
+
from platform.client import PlatformApi
|
|
138
|
+
|
|
139
|
+
client = PlatformApi(
|
|
140
|
+
token="YOUR_TOKEN",
|
|
141
|
+
base_url="https://yourhost.com/path/to/api",
|
|
142
|
+
)
|
|
143
|
+
client.api_keys.delete_api_key(
|
|
144
|
+
api_key_id="string",
|
|
145
|
+
)
|
|
146
|
+
"""
|
|
147
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
148
|
+
"DELETE",
|
|
149
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/api-keys/{api_key_id}"),
|
|
150
|
+
headers=self._client_wrapper.get_headers(),
|
|
151
|
+
timeout=60,
|
|
152
|
+
)
|
|
153
|
+
if 200 <= _response.status_code < 300:
|
|
154
|
+
return
|
|
155
|
+
if _response.status_code == 422:
|
|
156
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
157
|
+
try:
|
|
158
|
+
_response_json = _response.json()
|
|
159
|
+
except JSONDecodeError:
|
|
160
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class AsyncApiKeysClient:
|
|
165
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
166
|
+
self._client_wrapper = client_wrapper
|
|
167
|
+
|
|
168
|
+
async def get_keys(self) -> typing.List[ApiKey]:
|
|
169
|
+
"""
|
|
170
|
+
Get all API Keys for a user.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
from platform.client import AsyncPlatformApi
|
|
174
|
+
|
|
175
|
+
client = AsyncPlatformApi(
|
|
176
|
+
token="YOUR_TOKEN",
|
|
177
|
+
base_url="https://yourhost.com/path/to/api",
|
|
178
|
+
)
|
|
179
|
+
await client.api_keys.get_keys()
|
|
180
|
+
"""
|
|
181
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
182
|
+
"GET",
|
|
183
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/api-keys"),
|
|
184
|
+
headers=self._client_wrapper.get_headers(),
|
|
185
|
+
timeout=60,
|
|
186
|
+
)
|
|
187
|
+
if 200 <= _response.status_code < 300:
|
|
188
|
+
return pydantic.parse_obj_as(typing.List[ApiKey], _response.json()) # type: ignore
|
|
189
|
+
if _response.status_code == 422:
|
|
190
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
191
|
+
try:
|
|
192
|
+
_response_json = _response.json()
|
|
193
|
+
except JSONDecodeError:
|
|
194
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
195
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
196
|
+
|
|
197
|
+
async def generate_key(self, *, name: typing.Optional[str] = OMIT) -> ApiKey:
|
|
198
|
+
"""
|
|
199
|
+
Generate a new API Key.
|
|
200
|
+
|
|
201
|
+
Parameters:
|
|
202
|
+
- name: typing.Optional[str].
|
|
203
|
+
---
|
|
204
|
+
from platform.client import AsyncPlatformApi
|
|
205
|
+
|
|
206
|
+
client = AsyncPlatformApi(
|
|
207
|
+
token="YOUR_TOKEN",
|
|
208
|
+
base_url="https://yourhost.com/path/to/api",
|
|
209
|
+
)
|
|
210
|
+
await client.api_keys.generate_key()
|
|
211
|
+
"""
|
|
212
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
213
|
+
if name is not OMIT:
|
|
214
|
+
_request["name"] = name
|
|
215
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
216
|
+
"POST",
|
|
217
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/api-keys"),
|
|
218
|
+
json=jsonable_encoder(_request),
|
|
219
|
+
headers=self._client_wrapper.get_headers(),
|
|
220
|
+
timeout=60,
|
|
221
|
+
)
|
|
222
|
+
if 200 <= _response.status_code < 300:
|
|
223
|
+
return pydantic.parse_obj_as(ApiKey, _response.json()) # type: ignore
|
|
224
|
+
if _response.status_code == 422:
|
|
225
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
226
|
+
try:
|
|
227
|
+
_response_json = _response.json()
|
|
228
|
+
except JSONDecodeError:
|
|
229
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
230
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
231
|
+
|
|
232
|
+
async def update_existing_api_key(self, api_key_id: str, *, name: typing.Optional[str] = OMIT) -> ApiKey:
|
|
233
|
+
"""
|
|
234
|
+
Update name of an existing API Key.
|
|
235
|
+
|
|
236
|
+
Parameters:
|
|
237
|
+
- api_key_id: str.
|
|
238
|
+
|
|
239
|
+
- name: typing.Optional[str].
|
|
240
|
+
---
|
|
241
|
+
from platform.client import AsyncPlatformApi
|
|
242
|
+
|
|
243
|
+
client = AsyncPlatformApi(
|
|
244
|
+
token="YOUR_TOKEN",
|
|
245
|
+
base_url="https://yourhost.com/path/to/api",
|
|
246
|
+
)
|
|
247
|
+
await client.api_keys.update_existing_api_key(
|
|
248
|
+
api_key_id="string",
|
|
249
|
+
)
|
|
250
|
+
"""
|
|
251
|
+
_request: typing.Dict[str, typing.Any] = {}
|
|
252
|
+
if name is not OMIT:
|
|
253
|
+
_request["name"] = name
|
|
254
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
255
|
+
"PUT",
|
|
256
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/api-keys/{api_key_id}"),
|
|
257
|
+
json=jsonable_encoder(_request),
|
|
258
|
+
headers=self._client_wrapper.get_headers(),
|
|
259
|
+
timeout=60,
|
|
260
|
+
)
|
|
261
|
+
if 200 <= _response.status_code < 300:
|
|
262
|
+
return pydantic.parse_obj_as(ApiKey, _response.json()) # type: ignore
|
|
263
|
+
if _response.status_code == 422:
|
|
264
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
265
|
+
try:
|
|
266
|
+
_response_json = _response.json()
|
|
267
|
+
except JSONDecodeError:
|
|
268
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
269
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
270
|
+
|
|
271
|
+
async def delete_api_key(self, api_key_id: str) -> None:
|
|
272
|
+
"""
|
|
273
|
+
Delete an API Key by ID.
|
|
274
|
+
|
|
275
|
+
Parameters:
|
|
276
|
+
- api_key_id: str.
|
|
277
|
+
---
|
|
278
|
+
from platform.client import AsyncPlatformApi
|
|
279
|
+
|
|
280
|
+
client = AsyncPlatformApi(
|
|
281
|
+
token="YOUR_TOKEN",
|
|
282
|
+
base_url="https://yourhost.com/path/to/api",
|
|
283
|
+
)
|
|
284
|
+
await client.api_keys.delete_api_key(
|
|
285
|
+
api_key_id="string",
|
|
286
|
+
)
|
|
287
|
+
"""
|
|
288
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
289
|
+
"DELETE",
|
|
290
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", f"api/v1/api-keys/{api_key_id}"),
|
|
291
|
+
headers=self._client_wrapper.get_headers(),
|
|
292
|
+
timeout=60,
|
|
293
|
+
)
|
|
294
|
+
if 200 <= _response.status_code < 300:
|
|
295
|
+
return
|
|
296
|
+
if _response.status_code == 422:
|
|
297
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
298
|
+
try:
|
|
299
|
+
_response_json = _response.json()
|
|
300
|
+
except JSONDecodeError:
|
|
301
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
302
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -0,0 +1,234 @@
|
|
|
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.v1 as pydantic # type: ignore
|
|
16
|
+
except ImportError:
|
|
17
|
+
import pydantic # type: ignore
|
|
18
|
+
|
|
19
|
+
# this is used as the default value for optional parameters
|
|
20
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BillingClient:
|
|
24
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
25
|
+
self._client_wrapper = client_wrapper
|
|
26
|
+
|
|
27
|
+
def create_checkout_session(self, *, success_url: str, cancel_url: str) -> str:
|
|
28
|
+
"""
|
|
29
|
+
Create a new checkout session.
|
|
30
|
+
|
|
31
|
+
Parameters:
|
|
32
|
+
- success_url: str.
|
|
33
|
+
|
|
34
|
+
- cancel_url: str.
|
|
35
|
+
---
|
|
36
|
+
from platform.client import PlatformApi
|
|
37
|
+
|
|
38
|
+
client = PlatformApi(
|
|
39
|
+
token="YOUR_TOKEN",
|
|
40
|
+
base_url="https://yourhost.com/path/to/api",
|
|
41
|
+
)
|
|
42
|
+
client.billing.create_checkout_session(
|
|
43
|
+
success_url="string",
|
|
44
|
+
cancel_url="string",
|
|
45
|
+
)
|
|
46
|
+
"""
|
|
47
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
48
|
+
"POST",
|
|
49
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/checkout-session"),
|
|
50
|
+
json=jsonable_encoder({"success_url": success_url, "cancel_url": cancel_url}),
|
|
51
|
+
headers=self._client_wrapper.get_headers(),
|
|
52
|
+
timeout=60,
|
|
53
|
+
)
|
|
54
|
+
if 200 <= _response.status_code < 300:
|
|
55
|
+
return pydantic.parse_obj_as(str, _response.json()) # type: ignore
|
|
56
|
+
if _response.status_code == 422:
|
|
57
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
58
|
+
try:
|
|
59
|
+
_response_json = _response.json()
|
|
60
|
+
except JSONDecodeError:
|
|
61
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
62
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
63
|
+
|
|
64
|
+
def create_customer_portal_session(self, *, return_url: str) -> str:
|
|
65
|
+
"""
|
|
66
|
+
Create a new customer portal session.
|
|
67
|
+
|
|
68
|
+
Parameters:
|
|
69
|
+
- return_url: str.
|
|
70
|
+
---
|
|
71
|
+
from platform.client import PlatformApi
|
|
72
|
+
|
|
73
|
+
client = PlatformApi(
|
|
74
|
+
token="YOUR_TOKEN",
|
|
75
|
+
base_url="https://yourhost.com/path/to/api",
|
|
76
|
+
)
|
|
77
|
+
client.billing.create_customer_portal_session(
|
|
78
|
+
return_url="string",
|
|
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/billing/customer-portal-session"),
|
|
84
|
+
json=jsonable_encoder({"return_url": return_url}),
|
|
85
|
+
headers=self._client_wrapper.get_headers(),
|
|
86
|
+
timeout=60,
|
|
87
|
+
)
|
|
88
|
+
if 200 <= _response.status_code < 300:
|
|
89
|
+
return pydantic.parse_obj_as(str, _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 stripe_webhook(self, *, stripe_signature: typing.Optional[str] = None) -> typing.Any:
|
|
99
|
+
"""
|
|
100
|
+
Stripe webhook endpoint.
|
|
101
|
+
|
|
102
|
+
Parameters:
|
|
103
|
+
- stripe_signature: typing.Optional[str].
|
|
104
|
+
---
|
|
105
|
+
from platform.client import PlatformApi
|
|
106
|
+
|
|
107
|
+
client = PlatformApi(
|
|
108
|
+
token="YOUR_TOKEN",
|
|
109
|
+
base_url="https://yourhost.com/path/to/api",
|
|
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 platform.client import AsyncPlatformApi
|
|
144
|
+
|
|
145
|
+
client = AsyncPlatformApi(
|
|
146
|
+
token="YOUR_TOKEN",
|
|
147
|
+
base_url="https://yourhost.com/path/to/api",
|
|
148
|
+
)
|
|
149
|
+
await client.billing.create_checkout_session(
|
|
150
|
+
success_url="string",
|
|
151
|
+
cancel_url="string",
|
|
152
|
+
)
|
|
153
|
+
"""
|
|
154
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
155
|
+
"POST",
|
|
156
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/checkout-session"),
|
|
157
|
+
json=jsonable_encoder({"success_url": success_url, "cancel_url": cancel_url}),
|
|
158
|
+
headers=self._client_wrapper.get_headers(),
|
|
159
|
+
timeout=60,
|
|
160
|
+
)
|
|
161
|
+
if 200 <= _response.status_code < 300:
|
|
162
|
+
return pydantic.parse_obj_as(str, _response.json()) # type: ignore
|
|
163
|
+
if _response.status_code == 422:
|
|
164
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
165
|
+
try:
|
|
166
|
+
_response_json = _response.json()
|
|
167
|
+
except JSONDecodeError:
|
|
168
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
169
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
170
|
+
|
|
171
|
+
async def create_customer_portal_session(self, *, return_url: str) -> str:
|
|
172
|
+
"""
|
|
173
|
+
Create a new customer portal session.
|
|
174
|
+
|
|
175
|
+
Parameters:
|
|
176
|
+
- return_url: str.
|
|
177
|
+
---
|
|
178
|
+
from platform.client import AsyncPlatformApi
|
|
179
|
+
|
|
180
|
+
client = AsyncPlatformApi(
|
|
181
|
+
token="YOUR_TOKEN",
|
|
182
|
+
base_url="https://yourhost.com/path/to/api",
|
|
183
|
+
)
|
|
184
|
+
await client.billing.create_customer_portal_session(
|
|
185
|
+
return_url="string",
|
|
186
|
+
)
|
|
187
|
+
"""
|
|
188
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
189
|
+
"POST",
|
|
190
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/customer-portal-session"),
|
|
191
|
+
json=jsonable_encoder({"return_url": return_url}),
|
|
192
|
+
headers=self._client_wrapper.get_headers(),
|
|
193
|
+
timeout=60,
|
|
194
|
+
)
|
|
195
|
+
if 200 <= _response.status_code < 300:
|
|
196
|
+
return pydantic.parse_obj_as(str, _response.json()) # type: ignore
|
|
197
|
+
if _response.status_code == 422:
|
|
198
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
199
|
+
try:
|
|
200
|
+
_response_json = _response.json()
|
|
201
|
+
except JSONDecodeError:
|
|
202
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
203
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
204
|
+
|
|
205
|
+
async def stripe_webhook(self, *, stripe_signature: typing.Optional[str] = None) -> typing.Any:
|
|
206
|
+
"""
|
|
207
|
+
Stripe webhook endpoint.
|
|
208
|
+
|
|
209
|
+
Parameters:
|
|
210
|
+
- stripe_signature: typing.Optional[str].
|
|
211
|
+
---
|
|
212
|
+
from platform.client import AsyncPlatformApi
|
|
213
|
+
|
|
214
|
+
client = AsyncPlatformApi(
|
|
215
|
+
token="YOUR_TOKEN",
|
|
216
|
+
base_url="https://yourhost.com/path/to/api",
|
|
217
|
+
)
|
|
218
|
+
await client.billing.stripe_webhook()
|
|
219
|
+
"""
|
|
220
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
221
|
+
"POST",
|
|
222
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v1/billing/webhook"),
|
|
223
|
+
headers=remove_none_from_dict({**self._client_wrapper.get_headers(), "stripe-signature": stripe_signature}),
|
|
224
|
+
timeout=60,
|
|
225
|
+
)
|
|
226
|
+
if 200 <= _response.status_code < 300:
|
|
227
|
+
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
|
228
|
+
if _response.status_code == 422:
|
|
229
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
|
230
|
+
try:
|
|
231
|
+
_response_json = _response.json()
|
|
232
|
+
except JSONDecodeError:
|
|
233
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
234
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|