lambdadb 0.3.5__py3-none-any.whl → 0.4.0__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 lambdadb might be problematic. Click here for more details.
- lambdadb/_version.py +3 -3
- lambdadb/basesdk.py +4 -4
- lambdadb/collections.py +280 -452
- lambdadb/docs.py +261 -425
- lambdadb/errors/__init__.py +9 -0
- lambdadb/errors/apierror.py +30 -14
- lambdadb/errors/badrequest_error.py +12 -6
- lambdadb/errors/internalservererror.py +12 -6
- lambdadb/errors/lambdadberror.py +26 -0
- lambdadb/errors/no_response_error.py +13 -0
- lambdadb/errors/resourcealreadyexists_error.py +12 -6
- lambdadb/errors/resourcenotfound_error.py +12 -6
- lambdadb/errors/responsevalidationerror.py +25 -0
- lambdadb/errors/toomanyrequests_error.py +12 -6
- lambdadb/errors/unauthenticated_error.py +12 -6
- lambdadb/models/__init__.py +0 -54
- lambdadb/models/bulkupsertdocsop.py +0 -9
- lambdadb/models/createcollectionop.py +2 -23
- lambdadb/models/deletecollectionop.py +0 -9
- lambdadb/models/deletedocsop.py +3 -20
- lambdadb/models/fetchdocsop.py +3 -20
- lambdadb/models/getbulkupsertdocsop.py +0 -9
- lambdadb/models/getcollectionop.py +0 -9
- lambdadb/models/listcollectionsop.py +1 -17
- lambdadb/models/querycollectionop.py +7 -40
- lambdadb/models/updatecollectionop.py +0 -9
- lambdadb/models/updatedocsop.py +3 -20
- lambdadb/models/upsertdocsop.py +3 -20
- lambdadb/sdk.py +9 -1
- lambdadb/sdkconfiguration.py +4 -3
- lambdadb/utils/__init__.py +3 -0
- lambdadb/utils/serializers.py +21 -3
- {lambdadb-0.3.5.dist-info → lambdadb-0.4.0.dist-info}/METADATA +94 -55
- lambdadb-0.4.0.dist-info/RECORD +64 -0
- lambdadb-0.3.5.dist-info/RECORD +0 -61
- {lambdadb-0.3.5.dist-info → lambdadb-0.4.0.dist-info}/LICENSE +0 -0
- {lambdadb-0.3.5.dist-info → lambdadb-0.4.0.dist-info}/WHEEL +0 -0
lambdadb/models/deletedocsop.py
CHANGED
|
@@ -4,22 +4,14 @@ from __future__ import annotations
|
|
|
4
4
|
from lambdadb.types import BaseModel
|
|
5
5
|
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import List, Optional
|
|
7
|
+
from typing import Any, Dict, List, Optional
|
|
8
8
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class FilterTypedDict(TypedDict):
|
|
12
|
-
r"""Query filter."""
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Filter(BaseModel):
|
|
16
|
-
r"""Query filter."""
|
|
17
|
-
|
|
18
|
-
|
|
19
11
|
class DeleteDocsRequestBodyTypedDict(TypedDict):
|
|
20
12
|
ids: NotRequired[List[str]]
|
|
21
13
|
r"""A list of document IDs."""
|
|
22
|
-
filter_: NotRequired[
|
|
14
|
+
filter_: NotRequired[Dict[str, Any]]
|
|
23
15
|
r"""Query filter."""
|
|
24
16
|
|
|
25
17
|
|
|
@@ -27,26 +19,17 @@ class DeleteDocsRequestBody(BaseModel):
|
|
|
27
19
|
ids: Optional[List[str]] = None
|
|
28
20
|
r"""A list of document IDs."""
|
|
29
21
|
|
|
30
|
-
filter_: Annotated[Optional[
|
|
22
|
+
filter_: Annotated[Optional[Dict[str, Any]], pydantic.Field(alias="filter")] = None
|
|
31
23
|
r"""Query filter."""
|
|
32
24
|
|
|
33
25
|
|
|
34
26
|
class DeleteDocsRequestTypedDict(TypedDict):
|
|
35
|
-
project_name: str
|
|
36
|
-
r"""Project name."""
|
|
37
27
|
collection_name: str
|
|
38
28
|
r"""Collection name."""
|
|
39
29
|
request_body: DeleteDocsRequestBodyTypedDict
|
|
40
30
|
|
|
41
31
|
|
|
42
32
|
class DeleteDocsRequest(BaseModel):
|
|
43
|
-
project_name: Annotated[
|
|
44
|
-
str,
|
|
45
|
-
pydantic.Field(alias="projectName"),
|
|
46
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
47
|
-
]
|
|
48
|
-
r"""Project name."""
|
|
49
|
-
|
|
50
33
|
collection_name: Annotated[
|
|
51
34
|
str,
|
|
52
35
|
pydantic.Field(alias="collectionName"),
|
lambdadb/models/fetchdocsop.py
CHANGED
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
from lambdadb.types import BaseModel
|
|
5
5
|
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import List, Optional
|
|
7
|
+
from typing import Any, Dict, List, Optional
|
|
8
8
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
@@ -33,21 +33,12 @@ class FetchDocsRequestBody(BaseModel):
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class FetchDocsRequestTypedDict(TypedDict):
|
|
36
|
-
project_name: str
|
|
37
|
-
r"""Project name."""
|
|
38
36
|
collection_name: str
|
|
39
37
|
r"""Collection name."""
|
|
40
38
|
request_body: FetchDocsRequestBodyTypedDict
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
class FetchDocsRequest(BaseModel):
|
|
44
|
-
project_name: Annotated[
|
|
45
|
-
str,
|
|
46
|
-
pydantic.Field(alias="projectName"),
|
|
47
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
48
|
-
]
|
|
49
|
-
r"""Project name."""
|
|
50
|
-
|
|
51
42
|
collection_name: Annotated[
|
|
52
43
|
str,
|
|
53
44
|
pydantic.Field(alias="collectionName"),
|
|
@@ -61,23 +52,15 @@ class FetchDocsRequest(BaseModel):
|
|
|
61
52
|
]
|
|
62
53
|
|
|
63
54
|
|
|
64
|
-
class FetchDocsDocDocTypedDict(TypedDict):
|
|
65
|
-
pass
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class FetchDocsDocDoc(BaseModel):
|
|
69
|
-
pass
|
|
70
|
-
|
|
71
|
-
|
|
72
55
|
class FetchDocsDocTypedDict(TypedDict):
|
|
73
56
|
collection: str
|
|
74
|
-
doc:
|
|
57
|
+
doc: Dict[str, Any]
|
|
75
58
|
|
|
76
59
|
|
|
77
60
|
class FetchDocsDoc(BaseModel):
|
|
78
61
|
collection: str
|
|
79
62
|
|
|
80
|
-
doc:
|
|
63
|
+
doc: Dict[str, Any]
|
|
81
64
|
|
|
82
65
|
|
|
83
66
|
class FetchDocsResponseTypedDict(TypedDict):
|
|
@@ -10,20 +10,11 @@ from typing_extensions import Annotated, NotRequired, TypedDict
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class GetBulkUpsertDocsRequestTypedDict(TypedDict):
|
|
13
|
-
project_name: str
|
|
14
|
-
r"""Project name."""
|
|
15
13
|
collection_name: str
|
|
16
14
|
r"""Collection name."""
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
class GetBulkUpsertDocsRequest(BaseModel):
|
|
20
|
-
project_name: Annotated[
|
|
21
|
-
str,
|
|
22
|
-
pydantic.Field(alias="projectName"),
|
|
23
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
24
|
-
]
|
|
25
|
-
r"""Project name."""
|
|
26
|
-
|
|
27
18
|
collection_name: Annotated[
|
|
28
19
|
str,
|
|
29
20
|
pydantic.Field(alias="collectionName"),
|
|
@@ -9,20 +9,11 @@ from typing_extensions import Annotated, TypedDict
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class GetCollectionRequestTypedDict(TypedDict):
|
|
12
|
-
project_name: str
|
|
13
|
-
r"""Project name."""
|
|
14
12
|
collection_name: str
|
|
15
13
|
r"""Collection name."""
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
class GetCollectionRequest(BaseModel):
|
|
19
|
-
project_name: Annotated[
|
|
20
|
-
str,
|
|
21
|
-
pydantic.Field(alias="projectName"),
|
|
22
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
23
|
-
]
|
|
24
|
-
r"""Project name."""
|
|
25
|
-
|
|
26
17
|
collection_name: Annotated[
|
|
27
18
|
str,
|
|
28
19
|
pydantic.Field(alias="collectionName"),
|
|
@@ -3,24 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .collectionresponse import CollectionResponse, CollectionResponseTypedDict
|
|
5
5
|
from lambdadb.types import BaseModel
|
|
6
|
-
from lambdadb.utils import FieldMetadata, PathParamMetadata
|
|
7
|
-
import pydantic
|
|
8
6
|
from typing import List
|
|
9
|
-
from typing_extensions import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class ListCollectionsRequestTypedDict(TypedDict):
|
|
13
|
-
project_name: str
|
|
14
|
-
r"""Project name."""
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class ListCollectionsRequest(BaseModel):
|
|
18
|
-
project_name: Annotated[
|
|
19
|
-
str,
|
|
20
|
-
pydantic.Field(alias="projectName"),
|
|
21
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
22
|
-
]
|
|
23
|
-
r"""Project name."""
|
|
7
|
+
from typing_extensions import TypedDict
|
|
24
8
|
|
|
25
9
|
|
|
26
10
|
class ListCollectionsResponseTypedDict(TypedDict):
|
|
@@ -4,36 +4,20 @@ from __future__ import annotations
|
|
|
4
4
|
from lambdadb.types import BaseModel
|
|
5
5
|
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import List, Optional
|
|
7
|
+
from typing import Any, Dict, List, Optional
|
|
8
8
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class QueryTypedDict(TypedDict):
|
|
12
|
-
r"""Query object."""
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Query(BaseModel):
|
|
16
|
-
r"""Query object."""
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class SortTypedDict(TypedDict):
|
|
20
|
-
pass
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class Sort(BaseModel):
|
|
24
|
-
pass
|
|
25
|
-
|
|
26
|
-
|
|
27
11
|
class QueryCollectionRequestBodyTypedDict(TypedDict):
|
|
28
12
|
size: int
|
|
29
13
|
r"""Number of documents to return. Note that the maximum number of documents is 100."""
|
|
30
|
-
query: NotRequired[
|
|
14
|
+
query: NotRequired[Dict[str, Any]]
|
|
31
15
|
r"""Query object."""
|
|
32
16
|
consistent_read: NotRequired[bool]
|
|
33
17
|
r"""If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value."""
|
|
34
18
|
include_vectors: NotRequired[bool]
|
|
35
19
|
r"""If your application need to include vector values in the response, set includeVectors to true."""
|
|
36
|
-
sort: NotRequired[List[
|
|
20
|
+
sort: NotRequired[List[Dict[str, Any]]]
|
|
37
21
|
r"""List of field name, sort direction pairs."""
|
|
38
22
|
fields: NotRequired[List[str]]
|
|
39
23
|
r"""List of field name to include in results"""
|
|
@@ -43,7 +27,7 @@ class QueryCollectionRequestBody(BaseModel):
|
|
|
43
27
|
size: int
|
|
44
28
|
r"""Number of documents to return. Note that the maximum number of documents is 100."""
|
|
45
29
|
|
|
46
|
-
query: Optional[
|
|
30
|
+
query: Optional[Dict[str, Any]] = None
|
|
47
31
|
r"""Query object."""
|
|
48
32
|
|
|
49
33
|
consistent_read: Annotated[
|
|
@@ -56,7 +40,7 @@ class QueryCollectionRequestBody(BaseModel):
|
|
|
56
40
|
] = False
|
|
57
41
|
r"""If your application need to include vector values in the response, set includeVectors to true."""
|
|
58
42
|
|
|
59
|
-
sort: Optional[List[
|
|
43
|
+
sort: Optional[List[Dict[str, Any]]] = None
|
|
60
44
|
r"""List of field name, sort direction pairs."""
|
|
61
45
|
|
|
62
46
|
fields: Optional[List[str]] = None
|
|
@@ -64,21 +48,12 @@ class QueryCollectionRequestBody(BaseModel):
|
|
|
64
48
|
|
|
65
49
|
|
|
66
50
|
class QueryCollectionRequestTypedDict(TypedDict):
|
|
67
|
-
project_name: str
|
|
68
|
-
r"""Project name."""
|
|
69
51
|
collection_name: str
|
|
70
52
|
r"""Collection name."""
|
|
71
53
|
request_body: QueryCollectionRequestBodyTypedDict
|
|
72
54
|
|
|
73
55
|
|
|
74
56
|
class QueryCollectionRequest(BaseModel):
|
|
75
|
-
project_name: Annotated[
|
|
76
|
-
str,
|
|
77
|
-
pydantic.Field(alias="projectName"),
|
|
78
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
79
|
-
]
|
|
80
|
-
r"""Project name."""
|
|
81
|
-
|
|
82
57
|
collection_name: Annotated[
|
|
83
58
|
str,
|
|
84
59
|
pydantic.Field(alias="collectionName"),
|
|
@@ -92,20 +67,12 @@ class QueryCollectionRequest(BaseModel):
|
|
|
92
67
|
]
|
|
93
68
|
|
|
94
69
|
|
|
95
|
-
class QueryCollectionDocDocTypedDict(TypedDict):
|
|
96
|
-
pass
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class QueryCollectionDocDoc(BaseModel):
|
|
100
|
-
pass
|
|
101
|
-
|
|
102
|
-
|
|
103
70
|
class QueryCollectionDocTypedDict(TypedDict):
|
|
104
71
|
collection: str
|
|
105
72
|
r"""Collection name."""
|
|
106
73
|
score: float
|
|
107
74
|
r"""Document similarity score."""
|
|
108
|
-
doc:
|
|
75
|
+
doc: Dict[str, Any]
|
|
109
76
|
|
|
110
77
|
|
|
111
78
|
class QueryCollectionDoc(BaseModel):
|
|
@@ -115,7 +82,7 @@ class QueryCollectionDoc(BaseModel):
|
|
|
115
82
|
score: float
|
|
116
83
|
r"""Document similarity score."""
|
|
117
84
|
|
|
118
|
-
doc:
|
|
85
|
+
doc: Dict[str, Any]
|
|
119
86
|
|
|
120
87
|
|
|
121
88
|
class QueryCollectionResponseTypedDict(TypedDict):
|
|
@@ -21,21 +21,12 @@ class UpdateCollectionRequestBody(BaseModel):
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class UpdateCollectionRequestTypedDict(TypedDict):
|
|
24
|
-
project_name: str
|
|
25
|
-
r"""Project name."""
|
|
26
24
|
collection_name: str
|
|
27
25
|
r"""Collection name."""
|
|
28
26
|
request_body: UpdateCollectionRequestBodyTypedDict
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
class UpdateCollectionRequest(BaseModel):
|
|
32
|
-
project_name: Annotated[
|
|
33
|
-
str,
|
|
34
|
-
pydantic.Field(alias="projectName"),
|
|
35
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
36
|
-
]
|
|
37
|
-
r"""Project name."""
|
|
38
|
-
|
|
39
30
|
collection_name: Annotated[
|
|
40
31
|
str,
|
|
41
32
|
pydantic.Field(alias="collectionName"),
|
lambdadb/models/updatedocsop.py
CHANGED
|
@@ -4,44 +4,27 @@ from __future__ import annotations
|
|
|
4
4
|
from lambdadb.types import BaseModel
|
|
5
5
|
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import List
|
|
7
|
+
from typing import Any, Dict, List
|
|
8
8
|
from typing_extensions import Annotated, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class UpdateDocsDocTypedDict(TypedDict):
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class UpdateDocsDoc(BaseModel):
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
11
|
class UpdateDocsRequestBodyTypedDict(TypedDict):
|
|
20
|
-
docs: List[
|
|
12
|
+
docs: List[Dict[str, Any]]
|
|
21
13
|
r"""A list of documents to update. Each document must contain 'id' field to be updated."""
|
|
22
14
|
|
|
23
15
|
|
|
24
16
|
class UpdateDocsRequestBody(BaseModel):
|
|
25
|
-
docs: List[
|
|
17
|
+
docs: List[Dict[str, Any]]
|
|
26
18
|
r"""A list of documents to update. Each document must contain 'id' field to be updated."""
|
|
27
19
|
|
|
28
20
|
|
|
29
21
|
class UpdateDocsRequestTypedDict(TypedDict):
|
|
30
|
-
project_name: str
|
|
31
|
-
r"""Project name."""
|
|
32
22
|
collection_name: str
|
|
33
23
|
r"""Collection name."""
|
|
34
24
|
request_body: UpdateDocsRequestBodyTypedDict
|
|
35
25
|
|
|
36
26
|
|
|
37
27
|
class UpdateDocsRequest(BaseModel):
|
|
38
|
-
project_name: Annotated[
|
|
39
|
-
str,
|
|
40
|
-
pydantic.Field(alias="projectName"),
|
|
41
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
42
|
-
]
|
|
43
|
-
r"""Project name."""
|
|
44
|
-
|
|
45
28
|
collection_name: Annotated[
|
|
46
29
|
str,
|
|
47
30
|
pydantic.Field(alias="collectionName"),
|
lambdadb/models/upsertdocsop.py
CHANGED
|
@@ -4,44 +4,27 @@ from __future__ import annotations
|
|
|
4
4
|
from lambdadb.types import BaseModel
|
|
5
5
|
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import List
|
|
7
|
+
from typing import Any, Dict, List
|
|
8
8
|
from typing_extensions import Annotated, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class UpsertDocsDocTypedDict(TypedDict):
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class UpsertDocsDoc(BaseModel):
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
11
|
class UpsertDocsRequestBodyTypedDict(TypedDict):
|
|
20
|
-
docs: List[
|
|
12
|
+
docs: List[Dict[str, Any]]
|
|
21
13
|
r"""A list of documents to upsert."""
|
|
22
14
|
|
|
23
15
|
|
|
24
16
|
class UpsertDocsRequestBody(BaseModel):
|
|
25
|
-
docs: List[
|
|
17
|
+
docs: List[Dict[str, Any]]
|
|
26
18
|
r"""A list of documents to upsert."""
|
|
27
19
|
|
|
28
20
|
|
|
29
21
|
class UpsertDocsRequestTypedDict(TypedDict):
|
|
30
|
-
project_name: str
|
|
31
|
-
r"""Project name."""
|
|
32
22
|
collection_name: str
|
|
33
23
|
r"""Collection name."""
|
|
34
24
|
request_body: UpsertDocsRequestBodyTypedDict
|
|
35
25
|
|
|
36
26
|
|
|
37
27
|
class UpsertDocsRequest(BaseModel):
|
|
38
|
-
project_name: Annotated[
|
|
39
|
-
str,
|
|
40
|
-
pydantic.Field(alias="projectName"),
|
|
41
|
-
FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
|
|
42
|
-
]
|
|
43
|
-
r"""Project name."""
|
|
44
|
-
|
|
45
28
|
collection_name: Annotated[
|
|
46
29
|
str,
|
|
47
30
|
pydantic.Field(alias="collectionName"),
|
lambdadb/sdk.py
CHANGED
|
@@ -10,7 +10,7 @@ import importlib
|
|
|
10
10
|
from lambdadb import models, utils
|
|
11
11
|
from lambdadb._hooks import SDKHooks
|
|
12
12
|
from lambdadb.types import OptionalNullable, UNSET
|
|
13
|
-
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
|
13
|
+
from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast
|
|
14
14
|
import weakref
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
@@ -30,6 +30,7 @@ class LambdaDB(BaseSDK):
|
|
|
30
30
|
project_api_key: Optional[
|
|
31
31
|
Union[Optional[str], Callable[[], Optional[str]]]
|
|
32
32
|
] = None,
|
|
33
|
+
base_url: Optional[str] = None,
|
|
33
34
|
server_idx: Optional[int] = None,
|
|
34
35
|
server_url: Optional[str] = None,
|
|
35
36
|
url_params: Optional[Dict[str, str]] = None,
|
|
@@ -42,6 +43,7 @@ class LambdaDB(BaseSDK):
|
|
|
42
43
|
r"""Instantiates the SDK configuring it with the provided parameters.
|
|
43
44
|
|
|
44
45
|
:param project_api_key: The project_api_key required for authentication
|
|
46
|
+
:param base_url: Allows setting the baseUrl variable for url substitution
|
|
45
47
|
:param server_idx: The index of the server to use for all methods
|
|
46
48
|
:param server_url: The server URL to use for all methods
|
|
47
49
|
:param url_params: Parameters to optionally template the server URL with
|
|
@@ -81,6 +83,11 @@ class LambdaDB(BaseSDK):
|
|
|
81
83
|
if server_url is not None:
|
|
82
84
|
if url_params is not None:
|
|
83
85
|
server_url = utils.template_url(server_url, url_params)
|
|
86
|
+
server_defaults: List[Dict[str, str]] = [
|
|
87
|
+
{
|
|
88
|
+
"baseUrl": base_url or "api.lambdadb.com/projects/default",
|
|
89
|
+
},
|
|
90
|
+
]
|
|
84
91
|
|
|
85
92
|
BaseSDK.__init__(
|
|
86
93
|
self,
|
|
@@ -92,6 +99,7 @@ class LambdaDB(BaseSDK):
|
|
|
92
99
|
security=security,
|
|
93
100
|
server_url=server_url,
|
|
94
101
|
server_idx=server_idx,
|
|
102
|
+
server_defaults=server_defaults,
|
|
95
103
|
retry_config=retry_config,
|
|
96
104
|
timeout_ms=timeout_ms,
|
|
97
105
|
debug_logger=debug_logger,
|
lambdadb/sdkconfiguration.py
CHANGED
|
@@ -8,11 +8,11 @@ from ._version import (
|
|
|
8
8
|
)
|
|
9
9
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
10
10
|
from .utils import Logger, RetryConfig, remove_suffix
|
|
11
|
-
from dataclasses import dataclass
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
12
|
from lambdadb import models
|
|
13
13
|
from lambdadb.types import OptionalNullable, UNSET
|
|
14
14
|
from pydantic import Field
|
|
15
|
-
from typing import Callable, Dict, Optional, Tuple, Union
|
|
15
|
+
from typing import Callable, Dict, List, Optional, Tuple, Union
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
SERVERS = [
|
|
@@ -32,6 +32,7 @@ class SDKConfiguration:
|
|
|
32
32
|
security: Optional[Union[models.Security, Callable[[], models.Security]]] = None
|
|
33
33
|
server_url: Optional[str] = ""
|
|
34
34
|
server_idx: Optional[int] = 0
|
|
35
|
+
server_defaults: List[Dict[str, str]] = field(default_factory=List)
|
|
35
36
|
language: str = "python"
|
|
36
37
|
openapi_doc_version: str = __openapi_doc_version__
|
|
37
38
|
sdk_version: str = __version__
|
|
@@ -46,4 +47,4 @@ class SDKConfiguration:
|
|
|
46
47
|
if self.server_idx is None:
|
|
47
48
|
self.server_idx = 0
|
|
48
49
|
|
|
49
|
-
return SERVERS[self.server_idx],
|
|
50
|
+
return SERVERS[self.server_idx], self.server_defaults[self.server_idx]
|
lambdadb/utils/__init__.py
CHANGED
|
@@ -29,6 +29,7 @@ if TYPE_CHECKING:
|
|
|
29
29
|
marshal_json,
|
|
30
30
|
unmarshal,
|
|
31
31
|
unmarshal_json,
|
|
32
|
+
unmarshal_json_response,
|
|
32
33
|
serialize_decimal,
|
|
33
34
|
serialize_float,
|
|
34
35
|
serialize_int,
|
|
@@ -98,6 +99,7 @@ __all__ = [
|
|
|
98
99
|
"template_url",
|
|
99
100
|
"unmarshal",
|
|
100
101
|
"unmarshal_json",
|
|
102
|
+
"unmarshal_json_response",
|
|
101
103
|
"validate_decimal",
|
|
102
104
|
"validate_const",
|
|
103
105
|
"validate_float",
|
|
@@ -152,6 +154,7 @@ _dynamic_imports: dict[str, str] = {
|
|
|
152
154
|
"template_url": ".url",
|
|
153
155
|
"unmarshal": ".serializers",
|
|
154
156
|
"unmarshal_json": ".serializers",
|
|
157
|
+
"unmarshal_json_response": ".serializers",
|
|
155
158
|
"validate_decimal": ".serializers",
|
|
156
159
|
"validate_const": ".serializers",
|
|
157
160
|
"validate_float": ".serializers",
|
lambdadb/utils/serializers.py
CHANGED
|
@@ -4,7 +4,7 @@ from decimal import Decimal
|
|
|
4
4
|
import functools
|
|
5
5
|
import json
|
|
6
6
|
import typing
|
|
7
|
-
from typing import Any, Dict, List, Tuple, Union, get_args
|
|
7
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, get_args
|
|
8
8
|
import typing_extensions
|
|
9
9
|
from typing_extensions import get_origin
|
|
10
10
|
|
|
@@ -13,6 +13,7 @@ from pydantic import ConfigDict, create_model
|
|
|
13
13
|
from pydantic_core import from_json
|
|
14
14
|
|
|
15
15
|
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
|
16
|
+
from lambdadb import errors
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
def serialize_decimal(as_str: bool):
|
|
@@ -140,6 +141,22 @@ def unmarshal_json(raw, typ: Any) -> Any:
|
|
|
140
141
|
return unmarshal(from_json(raw), typ)
|
|
141
142
|
|
|
142
143
|
|
|
144
|
+
def unmarshal_json_response(
|
|
145
|
+
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
|
146
|
+
) -> Any:
|
|
147
|
+
if body is None:
|
|
148
|
+
body = http_res.text
|
|
149
|
+
try:
|
|
150
|
+
return unmarshal_json(body, typ)
|
|
151
|
+
except Exception as e:
|
|
152
|
+
raise errors.ResponseValidationError(
|
|
153
|
+
"Response validation failed",
|
|
154
|
+
http_res,
|
|
155
|
+
e,
|
|
156
|
+
body,
|
|
157
|
+
) from e
|
|
158
|
+
|
|
159
|
+
|
|
143
160
|
def unmarshal(val, typ: Any) -> Any:
|
|
144
161
|
unmarshaller = create_model(
|
|
145
162
|
"Unmarshaller",
|
|
@@ -192,7 +209,9 @@ def is_union(obj: object) -> bool:
|
|
|
192
209
|
"""
|
|
193
210
|
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
|
194
211
|
"""
|
|
195
|
-
return any(
|
|
212
|
+
return any(
|
|
213
|
+
obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
|
|
214
|
+
)
|
|
196
215
|
|
|
197
216
|
|
|
198
217
|
def stream_to_text(stream: httpx.Response) -> str:
|
|
@@ -245,4 +264,3 @@ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
|
|
245
264
|
f"Neither typing nor typing_extensions has an object called {name!r}"
|
|
246
265
|
)
|
|
247
266
|
return result
|
|
248
|
-
|