lambdadb 0.1.2__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.

Files changed (66) hide show
  1. lambdadb/__init__.py +17 -0
  2. lambdadb/_hooks/__init__.py +5 -0
  3. lambdadb/_hooks/registration.py +13 -0
  4. lambdadb/_hooks/sdkhooks.py +76 -0
  5. lambdadb/_hooks/types.py +106 -0
  6. lambdadb/_version.py +15 -0
  7. lambdadb/basesdk.py +358 -0
  8. lambdadb/collections.py +1630 -0
  9. lambdadb/docs.py +1328 -0
  10. lambdadb/errors/__init__.py +74 -0
  11. lambdadb/errors/apierror.py +22 -0
  12. lambdadb/errors/badrequest_error.py +20 -0
  13. lambdadb/errors/internalservererror.py +20 -0
  14. lambdadb/errors/resourcealreadyexists_error.py +20 -0
  15. lambdadb/errors/resourcenotfound_error.py +20 -0
  16. lambdadb/errors/toomanyrequests_error.py +20 -0
  17. lambdadb/errors/unauthenticated_error.py +20 -0
  18. lambdadb/httpclient.py +126 -0
  19. lambdadb/models/__init__.py +420 -0
  20. lambdadb/models/bulkupsertdocsop.py +59 -0
  21. lambdadb/models/collectionresponse.py +64 -0
  22. lambdadb/models/createcollectionop.py +64 -0
  23. lambdadb/models/createprojectop.py +39 -0
  24. lambdadb/models/deletecollectionop.py +43 -0
  25. lambdadb/models/deletedocsop.py +88 -0
  26. lambdadb/models/deleteprojectop.py +52 -0
  27. lambdadb/models/fetchdocsop.py +102 -0
  28. lambdadb/models/getbulkupsertdocsop.py +82 -0
  29. lambdadb/models/getcollectionop.py +30 -0
  30. lambdadb/models/getprojectop.py +39 -0
  31. lambdadb/models/indexconfigs_union.py +95 -0
  32. lambdadb/models/listcollectionsop.py +35 -0
  33. lambdadb/models/listprojectsop.py +38 -0
  34. lambdadb/models/projectresponse.py +38 -0
  35. lambdadb/models/querycollectionop.py +152 -0
  36. lambdadb/models/security.py +25 -0
  37. lambdadb/models/status.py +12 -0
  38. lambdadb/models/updatecollectionop.py +48 -0
  39. lambdadb/models/updateprojectop.py +58 -0
  40. lambdadb/models/upsertdocsop.py +67 -0
  41. lambdadb/projects.py +1228 -0
  42. lambdadb/py.typed +1 -0
  43. lambdadb/sdk.py +170 -0
  44. lambdadb/sdkconfiguration.py +56 -0
  45. lambdadb/types/__init__.py +21 -0
  46. lambdadb/types/basemodel.py +39 -0
  47. lambdadb/utils/__init__.py +187 -0
  48. lambdadb/utils/annotations.py +55 -0
  49. lambdadb/utils/datetimes.py +23 -0
  50. lambdadb/utils/enums.py +74 -0
  51. lambdadb/utils/eventstreaming.py +238 -0
  52. lambdadb/utils/forms.py +202 -0
  53. lambdadb/utils/headers.py +136 -0
  54. lambdadb/utils/logger.py +27 -0
  55. lambdadb/utils/metadata.py +118 -0
  56. lambdadb/utils/queryparams.py +205 -0
  57. lambdadb/utils/requestbodies.py +66 -0
  58. lambdadb/utils/retries.py +217 -0
  59. lambdadb/utils/security.py +192 -0
  60. lambdadb/utils/serializers.py +248 -0
  61. lambdadb/utils/url.py +155 -0
  62. lambdadb/utils/values.py +137 -0
  63. lambdadb-0.1.2.dist-info/LICENSE +201 -0
  64. lambdadb-0.1.2.dist-info/METADATA +514 -0
  65. lambdadb-0.1.2.dist-info/RECORD +66 -0
  66. lambdadb-0.1.2.dist-info/WHEEL +4 -0
@@ -0,0 +1,74 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import TYPE_CHECKING
4
+ from importlib import import_module
5
+
6
+ if TYPE_CHECKING:
7
+ from .apierror import APIError
8
+ from .badrequest_error import BadRequestError, BadRequestErrorData
9
+ from .internalservererror import InternalServerError, InternalServerErrorData
10
+ from .resourcealreadyexists_error import (
11
+ ResourceAlreadyExistsError,
12
+ ResourceAlreadyExistsErrorData,
13
+ )
14
+ from .resourcenotfound_error import ResourceNotFoundError, ResourceNotFoundErrorData
15
+ from .toomanyrequests_error import TooManyRequestsError, TooManyRequestsErrorData
16
+ from .unauthenticated_error import UnauthenticatedError, UnauthenticatedErrorData
17
+
18
+ __all__ = [
19
+ "APIError",
20
+ "BadRequestError",
21
+ "BadRequestErrorData",
22
+ "InternalServerError",
23
+ "InternalServerErrorData",
24
+ "ResourceAlreadyExistsError",
25
+ "ResourceAlreadyExistsErrorData",
26
+ "ResourceNotFoundError",
27
+ "ResourceNotFoundErrorData",
28
+ "TooManyRequestsError",
29
+ "TooManyRequestsErrorData",
30
+ "UnauthenticatedError",
31
+ "UnauthenticatedErrorData",
32
+ ]
33
+
34
+ _dynamic_imports: dict[str, str] = {
35
+ "APIError": ".apierror",
36
+ "BadRequestError": ".badrequest_error",
37
+ "BadRequestErrorData": ".badrequest_error",
38
+ "InternalServerError": ".internalservererror",
39
+ "InternalServerErrorData": ".internalservererror",
40
+ "ResourceAlreadyExistsError": ".resourcealreadyexists_error",
41
+ "ResourceAlreadyExistsErrorData": ".resourcealreadyexists_error",
42
+ "ResourceNotFoundError": ".resourcenotfound_error",
43
+ "ResourceNotFoundErrorData": ".resourcenotfound_error",
44
+ "TooManyRequestsError": ".toomanyrequests_error",
45
+ "TooManyRequestsErrorData": ".toomanyrequests_error",
46
+ "UnauthenticatedError": ".unauthenticated_error",
47
+ "UnauthenticatedErrorData": ".unauthenticated_error",
48
+ }
49
+
50
+
51
+ def __getattr__(attr_name: str) -> object:
52
+ module_name = _dynamic_imports.get(attr_name)
53
+ if module_name is None:
54
+ raise AttributeError(
55
+ f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
56
+ )
57
+
58
+ try:
59
+ module = import_module(module_name, __package__)
60
+ result = getattr(module, attr_name)
61
+ return result
62
+ except ImportError as e:
63
+ raise ImportError(
64
+ f"Failed to import {attr_name} from {module_name}: {e}"
65
+ ) from e
66
+ except AttributeError as e:
67
+ raise AttributeError(
68
+ f"Failed to get {attr_name} from {module_name}: {e}"
69
+ ) from e
70
+
71
+
72
+ def __dir__():
73
+ lazy_attrs = list(_dynamic_imports.keys())
74
+ return sorted(lazy_attrs)
@@ -0,0 +1,22 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Optional
5
+ import httpx
6
+
7
+
8
+ @dataclass
9
+ class APIError(Exception):
10
+ """Represents an error returned by the API."""
11
+
12
+ message: str
13
+ status_code: int = -1
14
+ body: str = ""
15
+ raw_response: Optional[httpx.Response] = None
16
+
17
+ def __str__(self):
18
+ body = ""
19
+ if len(self.body) > 0:
20
+ body = f"\n{self.body}"
21
+
22
+ return f"{self.message}: Status {self.status_code}{body}"
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class BadRequestErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class BadRequestError(Exception):
14
+ data: BadRequestErrorData
15
+
16
+ def __init__(self, data: BadRequestErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, BadRequestErrorData)
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class InternalServerErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class InternalServerError(Exception):
14
+ data: InternalServerErrorData
15
+
16
+ def __init__(self, data: InternalServerErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, InternalServerErrorData)
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class ResourceAlreadyExistsErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class ResourceAlreadyExistsError(Exception):
14
+ data: ResourceAlreadyExistsErrorData
15
+
16
+ def __init__(self, data: ResourceAlreadyExistsErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, ResourceAlreadyExistsErrorData)
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class ResourceNotFoundErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class ResourceNotFoundError(Exception):
14
+ data: ResourceNotFoundErrorData
15
+
16
+ def __init__(self, data: ResourceNotFoundErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, ResourceNotFoundErrorData)
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class TooManyRequestsErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class TooManyRequestsError(Exception):
14
+ data: TooManyRequestsErrorData
15
+
16
+ def __init__(self, data: TooManyRequestsErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, TooManyRequestsErrorData)
@@ -0,0 +1,20 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from lambdadb import utils
5
+ from lambdadb.types import BaseModel
6
+ from typing import Optional
7
+
8
+
9
+ class UnauthenticatedErrorData(BaseModel):
10
+ message: Optional[str] = None
11
+
12
+
13
+ class UnauthenticatedError(Exception):
14
+ data: UnauthenticatedErrorData
15
+
16
+ def __init__(self, data: UnauthenticatedErrorData):
17
+ self.data = data
18
+
19
+ def __str__(self) -> str:
20
+ return utils.marshal_json(self.data, UnauthenticatedErrorData)
lambdadb/httpclient.py ADDED
@@ -0,0 +1,126 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ # pyright: reportReturnType = false
4
+ import asyncio
5
+ from typing_extensions import Protocol, runtime_checkable
6
+ import httpx
7
+ from typing import Any, Optional, Union
8
+
9
+
10
+ @runtime_checkable
11
+ class HttpClient(Protocol):
12
+ def send(
13
+ self,
14
+ request: httpx.Request,
15
+ *,
16
+ stream: bool = False,
17
+ auth: Union[
18
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
19
+ ] = httpx.USE_CLIENT_DEFAULT,
20
+ follow_redirects: Union[
21
+ bool, httpx._client.UseClientDefault
22
+ ] = httpx.USE_CLIENT_DEFAULT,
23
+ ) -> httpx.Response:
24
+ pass
25
+
26
+ def build_request(
27
+ self,
28
+ method: str,
29
+ url: httpx._types.URLTypes,
30
+ *,
31
+ content: Optional[httpx._types.RequestContent] = None,
32
+ data: Optional[httpx._types.RequestData] = None,
33
+ files: Optional[httpx._types.RequestFiles] = None,
34
+ json: Optional[Any] = None,
35
+ params: Optional[httpx._types.QueryParamTypes] = None,
36
+ headers: Optional[httpx._types.HeaderTypes] = None,
37
+ cookies: Optional[httpx._types.CookieTypes] = None,
38
+ timeout: Union[
39
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
40
+ ] = httpx.USE_CLIENT_DEFAULT,
41
+ extensions: Optional[httpx._types.RequestExtensions] = None,
42
+ ) -> httpx.Request:
43
+ pass
44
+
45
+ def close(self) -> None:
46
+ pass
47
+
48
+
49
+ @runtime_checkable
50
+ class AsyncHttpClient(Protocol):
51
+ async def send(
52
+ self,
53
+ request: httpx.Request,
54
+ *,
55
+ stream: bool = False,
56
+ auth: Union[
57
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
58
+ ] = httpx.USE_CLIENT_DEFAULT,
59
+ follow_redirects: Union[
60
+ bool, httpx._client.UseClientDefault
61
+ ] = httpx.USE_CLIENT_DEFAULT,
62
+ ) -> httpx.Response:
63
+ pass
64
+
65
+ def build_request(
66
+ self,
67
+ method: str,
68
+ url: httpx._types.URLTypes,
69
+ *,
70
+ content: Optional[httpx._types.RequestContent] = None,
71
+ data: Optional[httpx._types.RequestData] = None,
72
+ files: Optional[httpx._types.RequestFiles] = None,
73
+ json: Optional[Any] = None,
74
+ params: Optional[httpx._types.QueryParamTypes] = None,
75
+ headers: Optional[httpx._types.HeaderTypes] = None,
76
+ cookies: Optional[httpx._types.CookieTypes] = None,
77
+ timeout: Union[
78
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
79
+ ] = httpx.USE_CLIENT_DEFAULT,
80
+ extensions: Optional[httpx._types.RequestExtensions] = None,
81
+ ) -> httpx.Request:
82
+ pass
83
+
84
+ async def aclose(self) -> None:
85
+ pass
86
+
87
+
88
+ class ClientOwner(Protocol):
89
+ client: Union[HttpClient, None]
90
+ async_client: Union[AsyncHttpClient, None]
91
+
92
+
93
+ def close_clients(
94
+ owner: ClientOwner,
95
+ sync_client: Union[HttpClient, None],
96
+ sync_client_supplied: bool,
97
+ async_client: Union[AsyncHttpClient, None],
98
+ async_client_supplied: bool,
99
+ ) -> None:
100
+ """
101
+ A finalizer function that is meant to be used with weakref.finalize to close
102
+ httpx clients used by an SDK so that underlying resources can be garbage
103
+ collected.
104
+ """
105
+
106
+ # Unset the client/async_client properties so there are no more references
107
+ # to them from the owning SDK instance and they can be reaped.
108
+ owner.client = None
109
+ owner.async_client = None
110
+
111
+ if sync_client is not None and not sync_client_supplied:
112
+ try:
113
+ sync_client.close()
114
+ except Exception:
115
+ pass
116
+
117
+ if async_client is not None and not async_client_supplied:
118
+ try:
119
+ loop = asyncio.get_running_loop()
120
+ asyncio.run_coroutine_threadsafe(async_client.aclose(), loop)
121
+ except RuntimeError:
122
+ try:
123
+ asyncio.run(async_client.aclose())
124
+ except RuntimeError:
125
+ # best effort
126
+ pass