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.
- lambdadb/__init__.py +17 -0
- lambdadb/_hooks/__init__.py +5 -0
- lambdadb/_hooks/registration.py +13 -0
- lambdadb/_hooks/sdkhooks.py +76 -0
- lambdadb/_hooks/types.py +106 -0
- lambdadb/_version.py +15 -0
- lambdadb/basesdk.py +358 -0
- lambdadb/collections.py +1630 -0
- lambdadb/docs.py +1328 -0
- lambdadb/errors/__init__.py +74 -0
- lambdadb/errors/apierror.py +22 -0
- lambdadb/errors/badrequest_error.py +20 -0
- lambdadb/errors/internalservererror.py +20 -0
- lambdadb/errors/resourcealreadyexists_error.py +20 -0
- lambdadb/errors/resourcenotfound_error.py +20 -0
- lambdadb/errors/toomanyrequests_error.py +20 -0
- lambdadb/errors/unauthenticated_error.py +20 -0
- lambdadb/httpclient.py +126 -0
- lambdadb/models/__init__.py +420 -0
- lambdadb/models/bulkupsertdocsop.py +59 -0
- lambdadb/models/collectionresponse.py +64 -0
- lambdadb/models/createcollectionop.py +64 -0
- lambdadb/models/createprojectop.py +39 -0
- lambdadb/models/deletecollectionop.py +43 -0
- lambdadb/models/deletedocsop.py +88 -0
- lambdadb/models/deleteprojectop.py +52 -0
- lambdadb/models/fetchdocsop.py +102 -0
- lambdadb/models/getbulkupsertdocsop.py +82 -0
- lambdadb/models/getcollectionop.py +30 -0
- lambdadb/models/getprojectop.py +39 -0
- lambdadb/models/indexconfigs_union.py +95 -0
- lambdadb/models/listcollectionsop.py +35 -0
- lambdadb/models/listprojectsop.py +38 -0
- lambdadb/models/projectresponse.py +38 -0
- lambdadb/models/querycollectionop.py +152 -0
- lambdadb/models/security.py +25 -0
- lambdadb/models/status.py +12 -0
- lambdadb/models/updatecollectionop.py +48 -0
- lambdadb/models/updateprojectop.py +58 -0
- lambdadb/models/upsertdocsop.py +67 -0
- lambdadb/projects.py +1228 -0
- lambdadb/py.typed +1 -0
- lambdadb/sdk.py +170 -0
- lambdadb/sdkconfiguration.py +56 -0
- lambdadb/types/__init__.py +21 -0
- lambdadb/types/basemodel.py +39 -0
- lambdadb/utils/__init__.py +187 -0
- lambdadb/utils/annotations.py +55 -0
- lambdadb/utils/datetimes.py +23 -0
- lambdadb/utils/enums.py +74 -0
- lambdadb/utils/eventstreaming.py +238 -0
- lambdadb/utils/forms.py +202 -0
- lambdadb/utils/headers.py +136 -0
- lambdadb/utils/logger.py +27 -0
- lambdadb/utils/metadata.py +118 -0
- lambdadb/utils/queryparams.py +205 -0
- lambdadb/utils/requestbodies.py +66 -0
- lambdadb/utils/retries.py +217 -0
- lambdadb/utils/security.py +192 -0
- lambdadb/utils/serializers.py +248 -0
- lambdadb/utils/url.py +155 -0
- lambdadb/utils/values.py +137 -0
- lambdadb-0.1.2.dist-info/LICENSE +201 -0
- lambdadb-0.1.2.dist-info/METADATA +514 -0
- lambdadb-0.1.2.dist-info/RECORD +66 -0
- lambdadb-0.1.2.dist-info/WHEEL +4 -0
lambdadb/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561. The package enables type hints.
|
lambdadb/sdk.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
|
|
5
|
+
from .sdkconfiguration import SDKConfiguration
|
|
6
|
+
from .utils.logger import Logger, get_default_logger
|
|
7
|
+
from .utils.retries import RetryConfig
|
|
8
|
+
import httpx
|
|
9
|
+
import importlib
|
|
10
|
+
from lambdadb import models, utils
|
|
11
|
+
from lambdadb._hooks import SDKHooks
|
|
12
|
+
from lambdadb.types import OptionalNullable, UNSET
|
|
13
|
+
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
|
14
|
+
import weakref
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from lambdadb.projects import Projects
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Lambdadb(BaseSDK):
|
|
21
|
+
r"""LambdaDB API: LambdaDB Open API Spec"""
|
|
22
|
+
|
|
23
|
+
projects: "Projects"
|
|
24
|
+
_sub_sdk_map = {
|
|
25
|
+
"projects": ("lambdadb.projects", "Projects"),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
project_api_key: Optional[
|
|
31
|
+
Union[Optional[str], Callable[[], Optional[str]]]
|
|
32
|
+
] = None,
|
|
33
|
+
server_idx: Optional[int] = None,
|
|
34
|
+
server_url: Optional[str] = None,
|
|
35
|
+
url_params: Optional[Dict[str, str]] = None,
|
|
36
|
+
client: Optional[HttpClient] = None,
|
|
37
|
+
async_client: Optional[AsyncHttpClient] = None,
|
|
38
|
+
retry_config: OptionalNullable[RetryConfig] = UNSET,
|
|
39
|
+
timeout_ms: Optional[int] = None,
|
|
40
|
+
debug_logger: Optional[Logger] = None,
|
|
41
|
+
) -> None:
|
|
42
|
+
r"""Instantiates the SDK configuring it with the provided parameters.
|
|
43
|
+
|
|
44
|
+
:param project_api_key: The project_api_key required for authentication
|
|
45
|
+
:param server_idx: The index of the server to use for all methods
|
|
46
|
+
:param server_url: The server URL to use for all methods
|
|
47
|
+
:param url_params: Parameters to optionally template the server URL with
|
|
48
|
+
:param client: The HTTP client to use for all synchronous methods
|
|
49
|
+
:param async_client: The Async HTTP client to use for all asynchronous methods
|
|
50
|
+
:param retry_config: The retry configuration to use for all supported methods
|
|
51
|
+
:param timeout_ms: Optional request timeout applied to each operation in milliseconds
|
|
52
|
+
"""
|
|
53
|
+
client_supplied = True
|
|
54
|
+
if client is None:
|
|
55
|
+
client = httpx.Client()
|
|
56
|
+
client_supplied = False
|
|
57
|
+
|
|
58
|
+
assert issubclass(
|
|
59
|
+
type(client), HttpClient
|
|
60
|
+
), "The provided client must implement the HttpClient protocol."
|
|
61
|
+
|
|
62
|
+
async_client_supplied = True
|
|
63
|
+
if async_client is None:
|
|
64
|
+
async_client = httpx.AsyncClient()
|
|
65
|
+
async_client_supplied = False
|
|
66
|
+
|
|
67
|
+
if debug_logger is None:
|
|
68
|
+
debug_logger = get_default_logger()
|
|
69
|
+
|
|
70
|
+
assert issubclass(
|
|
71
|
+
type(async_client), AsyncHttpClient
|
|
72
|
+
), "The provided async_client must implement the AsyncHttpClient protocol."
|
|
73
|
+
|
|
74
|
+
security: Any = None
|
|
75
|
+
if callable(project_api_key):
|
|
76
|
+
# pylint: disable=unnecessary-lambda-assignment
|
|
77
|
+
security = lambda: models.Security(project_api_key=project_api_key())
|
|
78
|
+
else:
|
|
79
|
+
security = models.Security(project_api_key=project_api_key)
|
|
80
|
+
|
|
81
|
+
if server_url is not None:
|
|
82
|
+
if url_params is not None:
|
|
83
|
+
server_url = utils.template_url(server_url, url_params)
|
|
84
|
+
|
|
85
|
+
BaseSDK.__init__(
|
|
86
|
+
self,
|
|
87
|
+
SDKConfiguration(
|
|
88
|
+
client=client,
|
|
89
|
+
client_supplied=client_supplied,
|
|
90
|
+
async_client=async_client,
|
|
91
|
+
async_client_supplied=async_client_supplied,
|
|
92
|
+
security=security,
|
|
93
|
+
server_url=server_url,
|
|
94
|
+
server_idx=server_idx,
|
|
95
|
+
retry_config=retry_config,
|
|
96
|
+
timeout_ms=timeout_ms,
|
|
97
|
+
debug_logger=debug_logger,
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
hooks = SDKHooks()
|
|
102
|
+
|
|
103
|
+
current_server_url, *_ = self.sdk_configuration.get_server_details()
|
|
104
|
+
server_url, self.sdk_configuration.client = hooks.sdk_init(
|
|
105
|
+
current_server_url, client
|
|
106
|
+
)
|
|
107
|
+
if current_server_url != server_url:
|
|
108
|
+
self.sdk_configuration.server_url = server_url
|
|
109
|
+
|
|
110
|
+
# pylint: disable=protected-access
|
|
111
|
+
self.sdk_configuration.__dict__["_hooks"] = hooks
|
|
112
|
+
|
|
113
|
+
weakref.finalize(
|
|
114
|
+
self,
|
|
115
|
+
close_clients,
|
|
116
|
+
cast(ClientOwner, self.sdk_configuration),
|
|
117
|
+
self.sdk_configuration.client,
|
|
118
|
+
self.sdk_configuration.client_supplied,
|
|
119
|
+
self.sdk_configuration.async_client,
|
|
120
|
+
self.sdk_configuration.async_client_supplied,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
def __getattr__(self, name: str):
|
|
124
|
+
if name in self._sub_sdk_map:
|
|
125
|
+
module_path, class_name = self._sub_sdk_map[name]
|
|
126
|
+
try:
|
|
127
|
+
module = importlib.import_module(module_path)
|
|
128
|
+
klass = getattr(module, class_name)
|
|
129
|
+
instance = klass(self.sdk_configuration)
|
|
130
|
+
setattr(self, name, instance)
|
|
131
|
+
return instance
|
|
132
|
+
except ImportError as e:
|
|
133
|
+
raise AttributeError(
|
|
134
|
+
f"Failed to import module {module_path} for attribute {name}: {e}"
|
|
135
|
+
) from e
|
|
136
|
+
except AttributeError as e:
|
|
137
|
+
raise AttributeError(
|
|
138
|
+
f"Failed to find class {class_name} in module {module_path} for attribute {name}: {e}"
|
|
139
|
+
) from e
|
|
140
|
+
|
|
141
|
+
raise AttributeError(
|
|
142
|
+
f"'{type(self).__name__}' object has no attribute '{name}'"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
def __dir__(self):
|
|
146
|
+
default_attrs = list(super().__dir__())
|
|
147
|
+
lazy_attrs = list(self._sub_sdk_map.keys())
|
|
148
|
+
return sorted(list(set(default_attrs + lazy_attrs)))
|
|
149
|
+
|
|
150
|
+
def __enter__(self):
|
|
151
|
+
return self
|
|
152
|
+
|
|
153
|
+
async def __aenter__(self):
|
|
154
|
+
return self
|
|
155
|
+
|
|
156
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
157
|
+
if (
|
|
158
|
+
self.sdk_configuration.client is not None
|
|
159
|
+
and not self.sdk_configuration.client_supplied
|
|
160
|
+
):
|
|
161
|
+
self.sdk_configuration.client.close()
|
|
162
|
+
self.sdk_configuration.client = None
|
|
163
|
+
|
|
164
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
165
|
+
if (
|
|
166
|
+
self.sdk_configuration.async_client is not None
|
|
167
|
+
and not self.sdk_configuration.async_client_supplied
|
|
168
|
+
):
|
|
169
|
+
await self.sdk_configuration.async_client.aclose()
|
|
170
|
+
self.sdk_configuration.async_client = None
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from ._hooks import SDKHooks
|
|
4
|
+
from ._version import (
|
|
5
|
+
__gen_version__,
|
|
6
|
+
__openapi_doc_version__,
|
|
7
|
+
__user_agent__,
|
|
8
|
+
__version__,
|
|
9
|
+
)
|
|
10
|
+
from .httpclient import AsyncHttpClient, HttpClient
|
|
11
|
+
from .utils import Logger, RetryConfig, remove_suffix
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from lambdadb import models
|
|
14
|
+
from lambdadb.types import OptionalNullable, UNSET
|
|
15
|
+
from pydantic import Field
|
|
16
|
+
from typing import Callable, Dict, Optional, Tuple, Union
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
SERVERS = [
|
|
20
|
+
"https://{baseUrl}",
|
|
21
|
+
# LambdaDB API endpoints
|
|
22
|
+
]
|
|
23
|
+
"""Contains the list of servers available to the SDK"""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class SDKConfiguration:
|
|
28
|
+
client: Union[HttpClient, None]
|
|
29
|
+
client_supplied: bool
|
|
30
|
+
async_client: Union[AsyncHttpClient, None]
|
|
31
|
+
async_client_supplied: bool
|
|
32
|
+
debug_logger: Logger
|
|
33
|
+
security: Optional[Union[models.Security, Callable[[], models.Security]]] = None
|
|
34
|
+
server_url: Optional[str] = ""
|
|
35
|
+
server_idx: Optional[int] = 0
|
|
36
|
+
language: str = "python"
|
|
37
|
+
openapi_doc_version: str = __openapi_doc_version__
|
|
38
|
+
sdk_version: str = __version__
|
|
39
|
+
gen_version: str = __gen_version__
|
|
40
|
+
user_agent: str = __user_agent__
|
|
41
|
+
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
42
|
+
timeout_ms: Optional[int] = None
|
|
43
|
+
|
|
44
|
+
def __post_init__(self):
|
|
45
|
+
self._hooks = SDKHooks()
|
|
46
|
+
|
|
47
|
+
def get_server_details(self) -> Tuple[str, Dict[str, str]]:
|
|
48
|
+
if self.server_url is not None and self.server_url:
|
|
49
|
+
return remove_suffix(self.server_url, "/"), {}
|
|
50
|
+
if self.server_idx is None:
|
|
51
|
+
self.server_idx = 0
|
|
52
|
+
|
|
53
|
+
return SERVERS[self.server_idx], {}
|
|
54
|
+
|
|
55
|
+
def get_hooks(self) -> SDKHooks:
|
|
56
|
+
return self._hooks
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basemodel import (
|
|
4
|
+
BaseModel,
|
|
5
|
+
Nullable,
|
|
6
|
+
OptionalNullable,
|
|
7
|
+
UnrecognizedInt,
|
|
8
|
+
UnrecognizedStr,
|
|
9
|
+
UNSET,
|
|
10
|
+
UNSET_SENTINEL,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"BaseModel",
|
|
15
|
+
"Nullable",
|
|
16
|
+
"OptionalNullable",
|
|
17
|
+
"UnrecognizedInt",
|
|
18
|
+
"UnrecognizedStr",
|
|
19
|
+
"UNSET",
|
|
20
|
+
"UNSET_SENTINEL",
|
|
21
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from pydantic import ConfigDict, model_serializer
|
|
4
|
+
from pydantic import BaseModel as PydanticBaseModel
|
|
5
|
+
from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
|
|
6
|
+
from typing_extensions import TypeAliasType, TypeAlias
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseModel(PydanticBaseModel):
|
|
10
|
+
model_config = ConfigDict(
|
|
11
|
+
populate_by_name=True, arbitrary_types_allowed=True, protected_namespaces=()
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Unset(BaseModel):
|
|
16
|
+
@model_serializer(mode="plain")
|
|
17
|
+
def serialize_model(self):
|
|
18
|
+
return UNSET_SENTINEL
|
|
19
|
+
|
|
20
|
+
def __bool__(self) -> Literal[False]:
|
|
21
|
+
return False
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
UNSET = Unset()
|
|
25
|
+
UNSET_SENTINEL = "~?~unset~?~sentinel~?~"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
T = TypeVar("T")
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
Nullable: TypeAlias = Union[T, None]
|
|
31
|
+
OptionalNullable: TypeAlias = Union[Optional[Nullable[T]], Unset]
|
|
32
|
+
else:
|
|
33
|
+
Nullable = TypeAliasType("Nullable", Union[T, None], type_params=(T,))
|
|
34
|
+
OptionalNullable = TypeAliasType(
|
|
35
|
+
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
UnrecognizedInt: TypeAlias = int
|
|
39
|
+
UnrecognizedStr: TypeAlias = str
|
|
@@ -0,0 +1,187 @@
|
|
|
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 .annotations import get_discriminator
|
|
8
|
+
from .datetimes import parse_datetime
|
|
9
|
+
from .enums import OpenEnumMeta
|
|
10
|
+
from .headers import get_headers, get_response_headers
|
|
11
|
+
from .metadata import (
|
|
12
|
+
FieldMetadata,
|
|
13
|
+
find_metadata,
|
|
14
|
+
FormMetadata,
|
|
15
|
+
HeaderMetadata,
|
|
16
|
+
MultipartFormMetadata,
|
|
17
|
+
PathParamMetadata,
|
|
18
|
+
QueryParamMetadata,
|
|
19
|
+
RequestMetadata,
|
|
20
|
+
SecurityMetadata,
|
|
21
|
+
)
|
|
22
|
+
from .queryparams import get_query_params
|
|
23
|
+
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
|
24
|
+
from .requestbodies import serialize_request_body, SerializedRequestBody
|
|
25
|
+
from .security import get_security, get_security_from_env
|
|
26
|
+
|
|
27
|
+
from .serializers import (
|
|
28
|
+
get_pydantic_model,
|
|
29
|
+
marshal_json,
|
|
30
|
+
unmarshal,
|
|
31
|
+
unmarshal_json,
|
|
32
|
+
serialize_decimal,
|
|
33
|
+
serialize_float,
|
|
34
|
+
serialize_int,
|
|
35
|
+
stream_to_text,
|
|
36
|
+
stream_to_text_async,
|
|
37
|
+
stream_to_bytes,
|
|
38
|
+
stream_to_bytes_async,
|
|
39
|
+
validate_const,
|
|
40
|
+
validate_decimal,
|
|
41
|
+
validate_float,
|
|
42
|
+
validate_int,
|
|
43
|
+
validate_open_enum,
|
|
44
|
+
)
|
|
45
|
+
from .url import generate_url, template_url, remove_suffix
|
|
46
|
+
from .values import (
|
|
47
|
+
get_global_from_env,
|
|
48
|
+
match_content_type,
|
|
49
|
+
match_status_codes,
|
|
50
|
+
match_response,
|
|
51
|
+
cast_partial,
|
|
52
|
+
)
|
|
53
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"BackoffStrategy",
|
|
57
|
+
"FieldMetadata",
|
|
58
|
+
"find_metadata",
|
|
59
|
+
"FormMetadata",
|
|
60
|
+
"generate_url",
|
|
61
|
+
"get_body_content",
|
|
62
|
+
"get_default_logger",
|
|
63
|
+
"get_discriminator",
|
|
64
|
+
"parse_datetime",
|
|
65
|
+
"get_global_from_env",
|
|
66
|
+
"get_headers",
|
|
67
|
+
"get_pydantic_model",
|
|
68
|
+
"get_query_params",
|
|
69
|
+
"get_response_headers",
|
|
70
|
+
"get_security",
|
|
71
|
+
"get_security_from_env",
|
|
72
|
+
"HeaderMetadata",
|
|
73
|
+
"Logger",
|
|
74
|
+
"marshal_json",
|
|
75
|
+
"match_content_type",
|
|
76
|
+
"match_status_codes",
|
|
77
|
+
"match_response",
|
|
78
|
+
"MultipartFormMetadata",
|
|
79
|
+
"OpenEnumMeta",
|
|
80
|
+
"PathParamMetadata",
|
|
81
|
+
"QueryParamMetadata",
|
|
82
|
+
"remove_suffix",
|
|
83
|
+
"Retries",
|
|
84
|
+
"retry",
|
|
85
|
+
"retry_async",
|
|
86
|
+
"RetryConfig",
|
|
87
|
+
"RequestMetadata",
|
|
88
|
+
"SecurityMetadata",
|
|
89
|
+
"serialize_decimal",
|
|
90
|
+
"serialize_float",
|
|
91
|
+
"serialize_int",
|
|
92
|
+
"serialize_request_body",
|
|
93
|
+
"SerializedRequestBody",
|
|
94
|
+
"stream_to_text",
|
|
95
|
+
"stream_to_text_async",
|
|
96
|
+
"stream_to_bytes",
|
|
97
|
+
"stream_to_bytes_async",
|
|
98
|
+
"template_url",
|
|
99
|
+
"unmarshal",
|
|
100
|
+
"unmarshal_json",
|
|
101
|
+
"validate_decimal",
|
|
102
|
+
"validate_const",
|
|
103
|
+
"validate_float",
|
|
104
|
+
"validate_int",
|
|
105
|
+
"validate_open_enum",
|
|
106
|
+
"cast_partial",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
_dynamic_imports: dict[str, str] = {
|
|
110
|
+
"BackoffStrategy": ".retries",
|
|
111
|
+
"FieldMetadata": ".metadata",
|
|
112
|
+
"find_metadata": ".metadata",
|
|
113
|
+
"FormMetadata": ".metadata",
|
|
114
|
+
"generate_url": ".url",
|
|
115
|
+
"get_body_content": ".logger",
|
|
116
|
+
"get_default_logger": ".logger",
|
|
117
|
+
"get_discriminator": ".annotations",
|
|
118
|
+
"parse_datetime": ".datetimes",
|
|
119
|
+
"get_global_from_env": ".values",
|
|
120
|
+
"get_headers": ".headers",
|
|
121
|
+
"get_pydantic_model": ".serializers",
|
|
122
|
+
"get_query_params": ".queryparams",
|
|
123
|
+
"get_response_headers": ".headers",
|
|
124
|
+
"get_security": ".security",
|
|
125
|
+
"get_security_from_env": ".security",
|
|
126
|
+
"HeaderMetadata": ".metadata",
|
|
127
|
+
"Logger": ".logger",
|
|
128
|
+
"marshal_json": ".serializers",
|
|
129
|
+
"match_content_type": ".values",
|
|
130
|
+
"match_status_codes": ".values",
|
|
131
|
+
"match_response": ".values",
|
|
132
|
+
"MultipartFormMetadata": ".metadata",
|
|
133
|
+
"OpenEnumMeta": ".enums",
|
|
134
|
+
"PathParamMetadata": ".metadata",
|
|
135
|
+
"QueryParamMetadata": ".metadata",
|
|
136
|
+
"remove_suffix": ".url",
|
|
137
|
+
"Retries": ".retries",
|
|
138
|
+
"retry": ".retries",
|
|
139
|
+
"retry_async": ".retries",
|
|
140
|
+
"RetryConfig": ".retries",
|
|
141
|
+
"RequestMetadata": ".metadata",
|
|
142
|
+
"SecurityMetadata": ".metadata",
|
|
143
|
+
"serialize_decimal": ".serializers",
|
|
144
|
+
"serialize_float": ".serializers",
|
|
145
|
+
"serialize_int": ".serializers",
|
|
146
|
+
"serialize_request_body": ".requestbodies",
|
|
147
|
+
"SerializedRequestBody": ".requestbodies",
|
|
148
|
+
"stream_to_text": ".serializers",
|
|
149
|
+
"stream_to_text_async": ".serializers",
|
|
150
|
+
"stream_to_bytes": ".serializers",
|
|
151
|
+
"stream_to_bytes_async": ".serializers",
|
|
152
|
+
"template_url": ".url",
|
|
153
|
+
"unmarshal": ".serializers",
|
|
154
|
+
"unmarshal_json": ".serializers",
|
|
155
|
+
"validate_decimal": ".serializers",
|
|
156
|
+
"validate_const": ".serializers",
|
|
157
|
+
"validate_float": ".serializers",
|
|
158
|
+
"validate_int": ".serializers",
|
|
159
|
+
"validate_open_enum": ".serializers",
|
|
160
|
+
"cast_partial": ".values",
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def __getattr__(attr_name: str) -> object:
|
|
165
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
166
|
+
if module_name is None:
|
|
167
|
+
raise AttributeError(
|
|
168
|
+
f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
module = import_module(module_name, __package__)
|
|
173
|
+
result = getattr(module, attr_name)
|
|
174
|
+
return result
|
|
175
|
+
except ImportError as e:
|
|
176
|
+
raise ImportError(
|
|
177
|
+
f"Failed to import {attr_name} from {module_name}: {e}"
|
|
178
|
+
) from e
|
|
179
|
+
except AttributeError as e:
|
|
180
|
+
raise AttributeError(
|
|
181
|
+
f"Failed to get {attr_name} from {module_name}: {e}"
|
|
182
|
+
) from e
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def __dir__():
|
|
186
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
187
|
+
return sorted(lazy_attrs)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
7
|
+
"""
|
|
8
|
+
Recursively search for the discriminator attribute in a model.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
model (Any): The model to search within.
|
|
12
|
+
fieldname (str): The name of the field to search for.
|
|
13
|
+
key (str): The key to search for in dictionaries.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
str: The name of the discriminator attribute.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
ValueError: If the discriminator attribute is not found.
|
|
20
|
+
"""
|
|
21
|
+
upper_fieldname = fieldname.upper()
|
|
22
|
+
|
|
23
|
+
def get_field_discriminator(field: Any) -> Optional[str]:
|
|
24
|
+
"""Search for the discriminator attribute in a given field."""
|
|
25
|
+
|
|
26
|
+
if isinstance(field, dict):
|
|
27
|
+
if key in field:
|
|
28
|
+
return f'{field[key]}'
|
|
29
|
+
|
|
30
|
+
if hasattr(field, fieldname):
|
|
31
|
+
attr = getattr(field, fieldname)
|
|
32
|
+
if isinstance(attr, Enum):
|
|
33
|
+
return f'{attr.value}'
|
|
34
|
+
return f'{attr}'
|
|
35
|
+
|
|
36
|
+
if hasattr(field, upper_fieldname):
|
|
37
|
+
attr = getattr(field, upper_fieldname)
|
|
38
|
+
if isinstance(attr, Enum):
|
|
39
|
+
return f'{attr.value}'
|
|
40
|
+
return f'{attr}'
|
|
41
|
+
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if isinstance(model, list):
|
|
46
|
+
for field in model:
|
|
47
|
+
discriminator = get_field_discriminator(field)
|
|
48
|
+
if discriminator is not None:
|
|
49
|
+
return discriminator
|
|
50
|
+
|
|
51
|
+
discriminator = get_field_discriminator(model)
|
|
52
|
+
if discriminator is not None:
|
|
53
|
+
return discriminator
|
|
54
|
+
|
|
55
|
+
raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def parse_datetime(datetime_string: str) -> datetime:
|
|
8
|
+
"""
|
|
9
|
+
Convert a RFC 3339 / ISO 8601 formatted string into a datetime object.
|
|
10
|
+
Python versions 3.11 and later support parsing RFC 3339 directly with
|
|
11
|
+
datetime.fromisoformat(), but for earlier versions, this function
|
|
12
|
+
encapsulates the necessary extra logic.
|
|
13
|
+
"""
|
|
14
|
+
# Python 3.11 and later can parse RFC 3339 directly
|
|
15
|
+
if sys.version_info >= (3, 11):
|
|
16
|
+
return datetime.fromisoformat(datetime_string)
|
|
17
|
+
|
|
18
|
+
# For Python 3.10 and earlier, a common ValueError is trailing 'Z' suffix,
|
|
19
|
+
# so fix that upfront.
|
|
20
|
+
if datetime_string.endswith("Z"):
|
|
21
|
+
datetime_string = datetime_string[:-1] + "+00:00"
|
|
22
|
+
|
|
23
|
+
return datetime.fromisoformat(datetime_string)
|
lambdadb/utils/enums.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
class OpenEnumMeta(enum.EnumMeta):
|
|
7
|
+
# The __call__ method `boundary` kwarg was added in 3.11 and must be present
|
|
8
|
+
# for pyright. Refer also: https://github.com/pylint-dev/pylint/issues/9622
|
|
9
|
+
# pylint: disable=unexpected-keyword-arg
|
|
10
|
+
# The __call__ method `values` varg must be named for pyright.
|
|
11
|
+
# pylint: disable=keyword-arg-before-vararg
|
|
12
|
+
|
|
13
|
+
if sys.version_info >= (3, 11):
|
|
14
|
+
def __call__(
|
|
15
|
+
cls, value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None
|
|
16
|
+
):
|
|
17
|
+
# The `type` kwarg also happens to be a built-in that pylint flags as
|
|
18
|
+
# redeclared. Safe to ignore this lint rule with this scope.
|
|
19
|
+
# pylint: disable=redefined-builtin
|
|
20
|
+
|
|
21
|
+
if names is not None:
|
|
22
|
+
return super().__call__(
|
|
23
|
+
value,
|
|
24
|
+
names=names,
|
|
25
|
+
*values,
|
|
26
|
+
module=module,
|
|
27
|
+
qualname=qualname,
|
|
28
|
+
type=type,
|
|
29
|
+
start=start,
|
|
30
|
+
boundary=boundary,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
return super().__call__(
|
|
35
|
+
value,
|
|
36
|
+
names=names, # pyright: ignore[reportArgumentType]
|
|
37
|
+
*values,
|
|
38
|
+
module=module,
|
|
39
|
+
qualname=qualname,
|
|
40
|
+
type=type,
|
|
41
|
+
start=start,
|
|
42
|
+
boundary=boundary,
|
|
43
|
+
)
|
|
44
|
+
except ValueError:
|
|
45
|
+
return value
|
|
46
|
+
else:
|
|
47
|
+
def __call__(
|
|
48
|
+
cls, value, names=None, *, module=None, qualname=None, type=None, start=1
|
|
49
|
+
):
|
|
50
|
+
# The `type` kwarg also happens to be a built-in that pylint flags as
|
|
51
|
+
# redeclared. Safe to ignore this lint rule with this scope.
|
|
52
|
+
# pylint: disable=redefined-builtin
|
|
53
|
+
|
|
54
|
+
if names is not None:
|
|
55
|
+
return super().__call__(
|
|
56
|
+
value,
|
|
57
|
+
names=names,
|
|
58
|
+
module=module,
|
|
59
|
+
qualname=qualname,
|
|
60
|
+
type=type,
|
|
61
|
+
start=start,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
try:
|
|
65
|
+
return super().__call__(
|
|
66
|
+
value,
|
|
67
|
+
names=names, # pyright: ignore[reportArgumentType]
|
|
68
|
+
module=module,
|
|
69
|
+
qualname=qualname,
|
|
70
|
+
type=type,
|
|
71
|
+
start=start,
|
|
72
|
+
)
|
|
73
|
+
except ValueError:
|
|
74
|
+
return value
|