lambdadb 0.1.3__tar.gz → 0.3.0__tar.gz
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 lambdadb might be problematic. Click here for more details.
- {lambdadb-0.1.3 → lambdadb-0.3.0}/PKG-INFO +91 -109
- {lambdadb-0.1.3 → lambdadb-0.3.0}/README-PYPI.md +88 -108
- {lambdadb-0.1.3 → lambdadb-0.3.0}/pyproject.toml +5 -1
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/_hooks/__init__.py +0 -1
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/_hooks/sdkhooks.py +4 -6
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/_hooks/types.py +8 -2
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/_version.py +4 -4
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/basesdk.py +12 -20
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/collections.py +12 -6
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/docs.py +10 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/__init__.py +0 -87
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/querycollectionop.py +0 -5
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/sdk.py +6 -11
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/sdkconfiguration.py +0 -7
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/forms.py +49 -28
- lambdadb-0.1.3/src/lambdadb/models/createprojectop.py +0 -39
- lambdadb-0.1.3/src/lambdadb/models/deleteprojectop.py +0 -52
- lambdadb-0.1.3/src/lambdadb/models/getprojectop.py +0 -39
- lambdadb-0.1.3/src/lambdadb/models/listprojectsop.py +0 -38
- lambdadb-0.1.3/src/lambdadb/models/projectresponse.py +0 -38
- lambdadb-0.1.3/src/lambdadb/models/updateprojectop.py +0 -58
- lambdadb-0.1.3/src/lambdadb/projects.py +0 -1228
- {lambdadb-0.1.3 → lambdadb-0.3.0}/LICENSE +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/py.typed +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/__init__.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/_hooks/registration.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/__init__.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/apierror.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/badrequest_error.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/internalservererror.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/resourcealreadyexists_error.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/resourcenotfound_error.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/toomanyrequests_error.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/errors/unauthenticated_error.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/httpclient.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/bulkupsertdocsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/collectionresponse.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/createcollectionop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/deletecollectionop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/deletedocsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/fetchdocsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/getbulkupsertdocsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/getcollectionop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/indexconfigs_union.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/listcollectionsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/security.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/status.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/updatecollectionop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/models/upsertdocsop.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/py.typed +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/types/__init__.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/types/basemodel.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/__init__.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/annotations.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/datetimes.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/enums.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/eventstreaming.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/headers.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/logger.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/metadata.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/queryparams.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/requestbodies.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/retries.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/security.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/serializers.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/url.py +0 -0
- {lambdadb-0.1.3 → lambdadb-0.3.0}/src/lambdadb/utils/values.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: lambdadb
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python Client SDK Generated by Speakeasy.
|
|
5
5
|
Author: Speakeasy
|
|
6
6
|
Requires-Python: >=3.9.2
|
|
@@ -9,8 +9,10 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: httpcore (>=1.0.9)
|
|
12
13
|
Requires-Dist: httpx (>=0.28.1)
|
|
13
14
|
Requires-Dist: pydantic (>=2.11.2)
|
|
15
|
+
Project-URL: Repository, https://github.com/lambdadb/lambdadb-python-client.git
|
|
14
16
|
Description-Content-Type: text/markdown
|
|
15
17
|
|
|
16
18
|
# LambdaDB Python SDK
|
|
@@ -33,21 +35,21 @@ LambdaDB API: LambdaDB Open API Spec
|
|
|
33
35
|
<!-- Start Table of Contents [toc] -->
|
|
34
36
|
## Table of Contents
|
|
35
37
|
<!-- $toc-max-depth=2 -->
|
|
36
|
-
* [LambdaDB Python SDK](
|
|
37
|
-
* [SDK Installation](
|
|
38
|
-
* [IDE Support](
|
|
39
|
-
* [SDK Example Usage](
|
|
40
|
-
* [Authentication](
|
|
41
|
-
* [Available Resources and Operations](
|
|
42
|
-
* [Retries](
|
|
43
|
-
* [Error Handling](
|
|
44
|
-
* [Server Selection](
|
|
45
|
-
* [Custom HTTP Client](
|
|
46
|
-
* [Resource Management](
|
|
47
|
-
* [Debugging](
|
|
48
|
-
* [Development](
|
|
49
|
-
* [Maturity](
|
|
50
|
-
* [Contributions](
|
|
38
|
+
* [LambdaDB Python SDK](https://github.com/lambdadb/lambdadb-python-client/blob/master/#lambdadb-python-sdk)
|
|
39
|
+
* [SDK Installation](https://github.com/lambdadb/lambdadb-python-client/blob/master/#sdk-installation)
|
|
40
|
+
* [IDE Support](https://github.com/lambdadb/lambdadb-python-client/blob/master/#ide-support)
|
|
41
|
+
* [SDK Example Usage](https://github.com/lambdadb/lambdadb-python-client/blob/master/#sdk-example-usage)
|
|
42
|
+
* [Authentication](https://github.com/lambdadb/lambdadb-python-client/blob/master/#authentication)
|
|
43
|
+
* [Available Resources and Operations](https://github.com/lambdadb/lambdadb-python-client/blob/master/#available-resources-and-operations)
|
|
44
|
+
* [Retries](https://github.com/lambdadb/lambdadb-python-client/blob/master/#retries)
|
|
45
|
+
* [Error Handling](https://github.com/lambdadb/lambdadb-python-client/blob/master/#error-handling)
|
|
46
|
+
* [Server Selection](https://github.com/lambdadb/lambdadb-python-client/blob/master/#server-selection)
|
|
47
|
+
* [Custom HTTP Client](https://github.com/lambdadb/lambdadb-python-client/blob/master/#custom-http-client)
|
|
48
|
+
* [Resource Management](https://github.com/lambdadb/lambdadb-python-client/blob/master/#resource-management)
|
|
49
|
+
* [Debugging](https://github.com/lambdadb/lambdadb-python-client/blob/master/#debugging)
|
|
50
|
+
* [Development](https://github.com/lambdadb/lambdadb-python-client/blob/master/#development)
|
|
51
|
+
* [Maturity](https://github.com/lambdadb/lambdadb-python-client/blob/master/#maturity)
|
|
52
|
+
* [Contributions](https://github.com/lambdadb/lambdadb-python-client/blob/master/#contributions)
|
|
51
53
|
|
|
52
54
|
<!-- End Table of Contents [toc] -->
|
|
53
55
|
|
|
@@ -96,9 +98,9 @@ It's also possible to write a standalone Python script without needing to set up
|
|
|
96
98
|
# ]
|
|
97
99
|
# ///
|
|
98
100
|
|
|
99
|
-
from lambdadb import
|
|
101
|
+
from lambdadb import LambdaDB
|
|
100
102
|
|
|
101
|
-
sdk =
|
|
103
|
+
sdk = LambdaDB(
|
|
102
104
|
# SDK arguments
|
|
103
105
|
)
|
|
104
106
|
|
|
@@ -126,14 +128,14 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
|
|
|
126
128
|
|
|
127
129
|
```python
|
|
128
130
|
# Synchronous Example
|
|
129
|
-
from lambdadb import
|
|
131
|
+
from lambdadb import LambdaDB
|
|
130
132
|
|
|
131
133
|
|
|
132
|
-
with
|
|
134
|
+
with LambdaDB(
|
|
135
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
136
|
+
) as lambda_db:
|
|
133
137
|
|
|
134
|
-
res =
|
|
135
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
136
|
-
))
|
|
138
|
+
res = lambda_db.collections.list(project_name="<value>")
|
|
137
139
|
|
|
138
140
|
# Handle response
|
|
139
141
|
print(res)
|
|
@@ -145,15 +147,15 @@ The same SDK client can also be used to make asychronous requests by importing a
|
|
|
145
147
|
```python
|
|
146
148
|
# Asynchronous Example
|
|
147
149
|
import asyncio
|
|
148
|
-
from lambdadb import
|
|
150
|
+
from lambdadb import LambdaDB
|
|
149
151
|
|
|
150
152
|
async def main():
|
|
151
153
|
|
|
152
|
-
async with
|
|
154
|
+
async with LambdaDB(
|
|
155
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
156
|
+
) as lambda_db:
|
|
153
157
|
|
|
154
|
-
res = await
|
|
155
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
156
|
-
))
|
|
158
|
+
res = await lambda_db.collections.list_async(project_name="<value>")
|
|
157
159
|
|
|
158
160
|
# Handle response
|
|
159
161
|
print(res)
|
|
@@ -175,32 +177,14 @@ This SDK supports the following security scheme globally:
|
|
|
175
177
|
|
|
176
178
|
To authenticate with the API the `project_api_key` parameter must be set when initializing the SDK client instance. For example:
|
|
177
179
|
```python
|
|
178
|
-
from lambdadb import
|
|
180
|
+
from lambdadb import LambdaDB
|
|
179
181
|
|
|
180
182
|
|
|
181
|
-
with
|
|
183
|
+
with LambdaDB(
|
|
182
184
|
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
183
|
-
) as
|
|
185
|
+
) as lambda_db:
|
|
184
186
|
|
|
185
|
-
res =
|
|
186
|
-
|
|
187
|
-
# Handle response
|
|
188
|
-
print(res)
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Per-Operation Security Schemes
|
|
193
|
-
|
|
194
|
-
Some operations in this SDK require the security scheme to be specified at the request level. For example:
|
|
195
|
-
```python
|
|
196
|
-
from lambdadb import Lambdadb, models
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
with Lambdadb() as l_client:
|
|
200
|
-
|
|
201
|
-
res = l_client.projects.list(security=models.ListProjectsSecurity(
|
|
202
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
203
|
-
))
|
|
187
|
+
res = lambda_db.collections.list(project_name="<value>")
|
|
204
188
|
|
|
205
189
|
# Handle response
|
|
206
190
|
print(res)
|
|
@@ -214,31 +198,23 @@ with Lambdadb() as l_client:
|
|
|
214
198
|
<details open>
|
|
215
199
|
<summary>Available methods</summary>
|
|
216
200
|
|
|
201
|
+
### [collections](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md)
|
|
217
202
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* [
|
|
221
|
-
* [
|
|
222
|
-
* [
|
|
223
|
-
* [
|
|
224
|
-
* [update](docs/sdks/projects/README.md#update) - Configure an existing project
|
|
203
|
+
* [list](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#list) - List all collections in an existing project.
|
|
204
|
+
* [create](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#create) - Create an collection.
|
|
205
|
+
* [delete](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#delete) - Delete an existing collection.
|
|
206
|
+
* [get](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#get) - Get metadata of an existing collection.
|
|
207
|
+
* [update](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#update) - Configure an collection.
|
|
208
|
+
* [query](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/collections/README.md#query) - Search an collection with a query and return the most similar documents.
|
|
225
209
|
|
|
226
|
-
#### [
|
|
210
|
+
#### [collections.docs](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md)
|
|
227
211
|
|
|
228
|
-
* [
|
|
229
|
-
* [
|
|
230
|
-
* [
|
|
231
|
-
* [
|
|
232
|
-
* [
|
|
233
|
-
* [query](docs/sdks/collections/README.md#query) - Search an collection with a query and return the most similar documents.
|
|
212
|
+
* [upsert](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md#upsert) - Upsert documents into an collection. Note that the maximum supported payload size is 6MB.
|
|
213
|
+
* [get_bulk_upsert](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md#get_bulk_upsert) - Request required info to upload documents.
|
|
214
|
+
* [bulk_upsert](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md#bulk_upsert) - Bulk upsert documents into an collection. Note that the maximum supported object size is 200MB.
|
|
215
|
+
* [delete](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md#delete) - Delete documents by document IDs or query filter from an collection.
|
|
216
|
+
* [fetch](https://github.com/lambdadb/lambdadb-python-client/blob/master/docs/sdks/docs/README.md#fetch) - Lookup and return documents by document IDs from an collection.
|
|
234
217
|
|
|
235
|
-
#### [projects.collections.docs](docs/sdks/docs/README.md)
|
|
236
|
-
|
|
237
|
-
* [upsert](docs/sdks/docs/README.md#upsert) - Upsert documents into an collection. Note that the maximum supported payload size is 6MB.
|
|
238
|
-
* [get_bulk_upsert](docs/sdks/docs/README.md#get_bulk_upsert) - Request required info to upload documents.
|
|
239
|
-
* [bulk_upsert](docs/sdks/docs/README.md#bulk_upsert) - Bulk upsert documents into an collection. Note that the maximum supported object size is 200MB.
|
|
240
|
-
* [delete](docs/sdks/docs/README.md#delete) - Delete documents by document IDs or query filter from an collection.
|
|
241
|
-
* [fetch](docs/sdks/docs/README.md#fetch) - Lookup and return documents by document IDs from an collection.
|
|
242
218
|
|
|
243
219
|
</details>
|
|
244
220
|
<!-- End Available Resources and Operations [operations] -->
|
|
@@ -250,15 +226,15 @@ Some of the endpoints in this SDK support retries. If you use the SDK without an
|
|
|
250
226
|
|
|
251
227
|
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
|
252
228
|
```python
|
|
253
|
-
from lambdadb import
|
|
229
|
+
from lambdadb import LambdaDB
|
|
254
230
|
from lambdadb.utils import BackoffStrategy, RetryConfig
|
|
255
231
|
|
|
256
232
|
|
|
257
|
-
with
|
|
233
|
+
with LambdaDB(
|
|
234
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
235
|
+
) as lambda_db:
|
|
258
236
|
|
|
259
|
-
res =
|
|
260
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
261
|
-
),
|
|
237
|
+
res = lambda_db.collections.list(project_name="<value>",
|
|
262
238
|
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
263
239
|
|
|
264
240
|
# Handle response
|
|
@@ -268,17 +244,16 @@ with Lambdadb() as l_client:
|
|
|
268
244
|
|
|
269
245
|
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
|
270
246
|
```python
|
|
271
|
-
from lambdadb import
|
|
247
|
+
from lambdadb import LambdaDB
|
|
272
248
|
from lambdadb.utils import BackoffStrategy, RetryConfig
|
|
273
249
|
|
|
274
250
|
|
|
275
|
-
with
|
|
251
|
+
with LambdaDB(
|
|
276
252
|
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
|
277
|
-
|
|
253
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
254
|
+
) as lambda_db:
|
|
278
255
|
|
|
279
|
-
res =
|
|
280
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
281
|
-
))
|
|
256
|
+
res = lambda_db.collections.list(project_name="<value>")
|
|
282
257
|
|
|
283
258
|
# Handle response
|
|
284
259
|
print(res)
|
|
@@ -302,26 +277,27 @@ By default, an API error will raise a errors.APIError exception, which has the f
|
|
|
302
277
|
|
|
303
278
|
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `list_async` method may raise the following exceptions:
|
|
304
279
|
|
|
305
|
-
| Error Type
|
|
306
|
-
|
|
|
307
|
-
| errors.UnauthenticatedError
|
|
308
|
-
| errors.
|
|
309
|
-
| errors.
|
|
310
|
-
| errors.
|
|
280
|
+
| Error Type | Status Code | Content Type |
|
|
281
|
+
| ---------------------------- | ----------- | ---------------- |
|
|
282
|
+
| errors.UnauthenticatedError | 401 | application/json |
|
|
283
|
+
| errors.ResourceNotFoundError | 404 | application/json |
|
|
284
|
+
| errors.TooManyRequestsError | 429 | application/json |
|
|
285
|
+
| errors.InternalServerError | 500 | application/json |
|
|
286
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
311
287
|
|
|
312
288
|
### Example
|
|
313
289
|
|
|
314
290
|
```python
|
|
315
|
-
from lambdadb import
|
|
291
|
+
from lambdadb import LambdaDB, errors
|
|
316
292
|
|
|
317
293
|
|
|
318
|
-
with
|
|
294
|
+
with LambdaDB(
|
|
295
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
296
|
+
) as lambda_db:
|
|
319
297
|
res = None
|
|
320
298
|
try:
|
|
321
299
|
|
|
322
|
-
res =
|
|
323
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
324
|
-
))
|
|
300
|
+
res = lambda_db.collections.list(project_name="<value>")
|
|
325
301
|
|
|
326
302
|
# Handle response
|
|
327
303
|
print(res)
|
|
@@ -329,6 +305,9 @@ with Lambdadb() as l_client:
|
|
|
329
305
|
except errors.UnauthenticatedError as e:
|
|
330
306
|
# handle e.data: errors.UnauthenticatedErrorData
|
|
331
307
|
raise(e)
|
|
308
|
+
except errors.ResourceNotFoundError as e:
|
|
309
|
+
# handle e.data: errors.ResourceNotFoundErrorData
|
|
310
|
+
raise(e)
|
|
332
311
|
except errors.TooManyRequestsError as e:
|
|
333
312
|
# handle e.data: errors.TooManyRequestsErrorData
|
|
334
313
|
raise(e)
|
|
@@ -348,16 +327,15 @@ with Lambdadb() as l_client:
|
|
|
348
327
|
|
|
349
328
|
The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
|
350
329
|
```python
|
|
351
|
-
from lambdadb import
|
|
330
|
+
from lambdadb import LambdaDB
|
|
352
331
|
|
|
353
332
|
|
|
354
|
-
with
|
|
333
|
+
with LambdaDB(
|
|
355
334
|
server_url="https://{baseUrl}",
|
|
356
|
-
|
|
335
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
336
|
+
) as lambda_db:
|
|
357
337
|
|
|
358
|
-
res =
|
|
359
|
-
admin_api_key="<YOUR_ADMIN_API_KEY>",
|
|
360
|
-
))
|
|
338
|
+
res = lambda_db.collections.list(project_name="<value>")
|
|
361
339
|
|
|
362
340
|
# Handle response
|
|
363
341
|
print(res)
|
|
@@ -374,16 +352,16 @@ This allows you to wrap the client with your own custom logic, such as adding cu
|
|
|
374
352
|
|
|
375
353
|
For example, you could specify a header for every request that this sdk makes as follows:
|
|
376
354
|
```python
|
|
377
|
-
from lambdadb import
|
|
355
|
+
from lambdadb import LambdaDB
|
|
378
356
|
import httpx
|
|
379
357
|
|
|
380
358
|
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
|
381
|
-
s =
|
|
359
|
+
s = LambdaDB(client=http_client)
|
|
382
360
|
```
|
|
383
361
|
|
|
384
362
|
or you could wrap the client with your own custom logic:
|
|
385
363
|
```python
|
|
386
|
-
from lambdadb import
|
|
364
|
+
from lambdadb import LambdaDB
|
|
387
365
|
from lambdadb.httpclient import AsyncHttpClient
|
|
388
366
|
import httpx
|
|
389
367
|
|
|
@@ -442,29 +420,33 @@ class CustomClient(AsyncHttpClient):
|
|
|
442
420
|
extensions=extensions,
|
|
443
421
|
)
|
|
444
422
|
|
|
445
|
-
s =
|
|
423
|
+
s = LambdaDB(async_client=CustomClient(httpx.AsyncClient()))
|
|
446
424
|
```
|
|
447
425
|
<!-- End Custom HTTP Client [http-client] -->
|
|
448
426
|
|
|
449
427
|
<!-- Start Resource Management [resource-management] -->
|
|
450
428
|
## Resource Management
|
|
451
429
|
|
|
452
|
-
The `
|
|
430
|
+
The `LambdaDB` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
|
|
453
431
|
|
|
454
432
|
[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
|
|
455
433
|
|
|
456
434
|
```python
|
|
457
|
-
from lambdadb import
|
|
435
|
+
from lambdadb import LambdaDB
|
|
458
436
|
def main():
|
|
459
437
|
|
|
460
|
-
with
|
|
438
|
+
with LambdaDB(
|
|
439
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
440
|
+
) as lambda_db:
|
|
461
441
|
# Rest of application here...
|
|
462
442
|
|
|
463
443
|
|
|
464
444
|
# Or when using async:
|
|
465
445
|
async def amain():
|
|
466
446
|
|
|
467
|
-
async with
|
|
447
|
+
async with LambdaDB(
|
|
448
|
+
project_api_key="<YOUR_PROJECT_API_KEY>",
|
|
449
|
+
) as lambda_db:
|
|
468
450
|
# Rest of application here...
|
|
469
451
|
```
|
|
470
452
|
<!-- End Resource Management [resource-management] -->
|
|
@@ -476,11 +458,11 @@ You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
|
476
458
|
|
|
477
459
|
You can pass your own logger class directly into your SDK.
|
|
478
460
|
```python
|
|
479
|
-
from lambdadb import
|
|
461
|
+
from lambdadb import LambdaDB
|
|
480
462
|
import logging
|
|
481
463
|
|
|
482
464
|
logging.basicConfig(level=logging.DEBUG)
|
|
483
|
-
s =
|
|
465
|
+
s = LambdaDB(debug_logger=logging.getLogger("lambdadb"))
|
|
484
466
|
```
|
|
485
467
|
|
|
486
468
|
You can also enable a default debug logger by setting an environment variable `LAMBDADB_DEBUG` to true.
|