zillow-rapidapi-client 0.1.3__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.
- zillow_rapidapi_client/__init__.py +18 -0
- zillow_rapidapi_client/_hooks/__init__.py +5 -0
- zillow_rapidapi_client/_hooks/registration.py +13 -0
- zillow_rapidapi_client/_hooks/sdkhooks.py +76 -0
- zillow_rapidapi_client/_hooks/types.py +106 -0
- zillow_rapidapi_client/_version.py +15 -0
- zillow_rapidapi_client/basesdk.py +358 -0
- zillow_rapidapi_client/httpclient.py +134 -0
- zillow_rapidapi_client/models/__init__.py +40 -0
- zillow_rapidapi_client/models/apierror.py +22 -0
- zillow_rapidapi_client/models/property.py +163 -0
- zillow_rapidapi_client/models/propertyextendedsearchop.py +106 -0
- zillow_rapidapi_client/models/propertysearchresponse.py +32 -0
- zillow_rapidapi_client/properties.py +221 -0
- zillow_rapidapi_client/py.typed +1 -0
- zillow_rapidapi_client/sdk.py +114 -0
- zillow_rapidapi_client/sdkconfiguration.py +52 -0
- zillow_rapidapi_client/types/__init__.py +21 -0
- zillow_rapidapi_client/types/basemodel.py +39 -0
- zillow_rapidapi_client/utils/__init__.py +99 -0
- zillow_rapidapi_client/utils/annotations.py +55 -0
- zillow_rapidapi_client/utils/enums.py +34 -0
- zillow_rapidapi_client/utils/eventstreaming.py +238 -0
- zillow_rapidapi_client/utils/forms.py +202 -0
- zillow_rapidapi_client/utils/headers.py +136 -0
- zillow_rapidapi_client/utils/logger.py +27 -0
- zillow_rapidapi_client/utils/metadata.py +118 -0
- zillow_rapidapi_client/utils/queryparams.py +205 -0
- zillow_rapidapi_client/utils/requestbodies.py +66 -0
- zillow_rapidapi_client/utils/retries.py +217 -0
- zillow_rapidapi_client/utils/security.py +174 -0
- zillow_rapidapi_client/utils/serializers.py +215 -0
- zillow_rapidapi_client/utils/url.py +155 -0
- zillow_rapidapi_client/utils/values.py +137 -0
- zillow_rapidapi_client-0.1.3.dist-info/METADATA +419 -0
- zillow_rapidapi_client-0.1.3.dist-info/RECORD +37 -0
- zillow_rapidapi_client-0.1.3.dist-info/WHEEL +4 -0
@@ -0,0 +1,221 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from .basesdk import BaseSDK
|
4
|
+
from typing import Mapping, Optional
|
5
|
+
from zillow_rapidapi_client import models, utils
|
6
|
+
from zillow_rapidapi_client._hooks import HookContext
|
7
|
+
from zillow_rapidapi_client.types import OptionalNullable, UNSET
|
8
|
+
|
9
|
+
|
10
|
+
class Properties(BaseSDK):
|
11
|
+
def extended_search(
|
12
|
+
self,
|
13
|
+
*,
|
14
|
+
location: Optional[str] = None,
|
15
|
+
page: Optional[int] = None,
|
16
|
+
status_type: Optional[models.StatusType] = None,
|
17
|
+
home_type: Optional[models.HomeType] = None,
|
18
|
+
sort: Optional[models.Sort] = None,
|
19
|
+
min_price: Optional[float] = None,
|
20
|
+
max_price: Optional[float] = None,
|
21
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
22
|
+
server_url: Optional[str] = None,
|
23
|
+
timeout_ms: Optional[int] = None,
|
24
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
25
|
+
) -> models.PropertySearchResponse:
|
26
|
+
r"""Search for properties
|
27
|
+
|
28
|
+
:param location: Location details (address, county, neighborhood, or Zip code). Required if polygon or coordinates are empty.
|
29
|
+
:param page: Page number for paginated results. Max value is 20.
|
30
|
+
:param status_type: Property status type.
|
31
|
+
:param home_type: Property type. Comma-separated list.
|
32
|
+
:param sort: Sorting order.
|
33
|
+
:param min_price: Minimum price filter.
|
34
|
+
:param max_price: Maximum price filter.
|
35
|
+
:param retries: Override the default retry configuration for this method
|
36
|
+
:param server_url: Override the default server URL for this method
|
37
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
38
|
+
:param http_headers: Additional headers to set or replace on requests.
|
39
|
+
"""
|
40
|
+
base_url = None
|
41
|
+
url_variables = None
|
42
|
+
if timeout_ms is None:
|
43
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
44
|
+
|
45
|
+
if server_url is not None:
|
46
|
+
base_url = server_url
|
47
|
+
else:
|
48
|
+
base_url = self._get_url(base_url, url_variables)
|
49
|
+
|
50
|
+
request = models.PropertyExtendedSearchRequest(
|
51
|
+
location=location,
|
52
|
+
page=page,
|
53
|
+
status_type=status_type,
|
54
|
+
home_type=home_type,
|
55
|
+
sort=sort,
|
56
|
+
min_price=min_price,
|
57
|
+
max_price=max_price,
|
58
|
+
)
|
59
|
+
|
60
|
+
req = self._build_request(
|
61
|
+
method="GET",
|
62
|
+
path="/propertyExtendedSearch",
|
63
|
+
base_url=base_url,
|
64
|
+
url_variables=url_variables,
|
65
|
+
request=request,
|
66
|
+
request_body_required=False,
|
67
|
+
request_has_path_params=False,
|
68
|
+
request_has_query_params=True,
|
69
|
+
user_agent_header="user-agent",
|
70
|
+
accept_header_value="application/json",
|
71
|
+
http_headers=http_headers,
|
72
|
+
timeout_ms=timeout_ms,
|
73
|
+
)
|
74
|
+
|
75
|
+
if retries == UNSET:
|
76
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
77
|
+
retries = self.sdk_configuration.retry_config
|
78
|
+
|
79
|
+
retry_config = None
|
80
|
+
if isinstance(retries, utils.RetryConfig):
|
81
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
82
|
+
|
83
|
+
http_res = self.do_request(
|
84
|
+
hook_ctx=HookContext(
|
85
|
+
base_url=base_url or "",
|
86
|
+
operation_id="propertyExtendedSearch",
|
87
|
+
oauth2_scopes=[],
|
88
|
+
security_source=None,
|
89
|
+
),
|
90
|
+
request=req,
|
91
|
+
error_status_codes=["400", "4XX", "500", "5XX"],
|
92
|
+
retry_config=retry_config,
|
93
|
+
)
|
94
|
+
|
95
|
+
if utils.match_response(http_res, "200", "application/json"):
|
96
|
+
return utils.unmarshal_json(http_res.text, models.PropertySearchResponse)
|
97
|
+
if utils.match_response(http_res, ["400", "4XX"], "*"):
|
98
|
+
http_res_text = utils.stream_to_text(http_res)
|
99
|
+
raise models.APIError(
|
100
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
101
|
+
)
|
102
|
+
if utils.match_response(http_res, ["500", "5XX"], "*"):
|
103
|
+
http_res_text = utils.stream_to_text(http_res)
|
104
|
+
raise models.APIError(
|
105
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
106
|
+
)
|
107
|
+
|
108
|
+
content_type = http_res.headers.get("Content-Type")
|
109
|
+
http_res_text = utils.stream_to_text(http_res)
|
110
|
+
raise models.APIError(
|
111
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
112
|
+
http_res.status_code,
|
113
|
+
http_res_text,
|
114
|
+
http_res,
|
115
|
+
)
|
116
|
+
|
117
|
+
async def extended_search_async(
|
118
|
+
self,
|
119
|
+
*,
|
120
|
+
location: Optional[str] = None,
|
121
|
+
page: Optional[int] = None,
|
122
|
+
status_type: Optional[models.StatusType] = None,
|
123
|
+
home_type: Optional[models.HomeType] = None,
|
124
|
+
sort: Optional[models.Sort] = None,
|
125
|
+
min_price: Optional[float] = None,
|
126
|
+
max_price: Optional[float] = None,
|
127
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
128
|
+
server_url: Optional[str] = None,
|
129
|
+
timeout_ms: Optional[int] = None,
|
130
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
131
|
+
) -> models.PropertySearchResponse:
|
132
|
+
r"""Search for properties
|
133
|
+
|
134
|
+
:param location: Location details (address, county, neighborhood, or Zip code). Required if polygon or coordinates are empty.
|
135
|
+
:param page: Page number for paginated results. Max value is 20.
|
136
|
+
:param status_type: Property status type.
|
137
|
+
:param home_type: Property type. Comma-separated list.
|
138
|
+
:param sort: Sorting order.
|
139
|
+
:param min_price: Minimum price filter.
|
140
|
+
:param max_price: Maximum price filter.
|
141
|
+
:param retries: Override the default retry configuration for this method
|
142
|
+
:param server_url: Override the default server URL for this method
|
143
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
144
|
+
:param http_headers: Additional headers to set or replace on requests.
|
145
|
+
"""
|
146
|
+
base_url = None
|
147
|
+
url_variables = None
|
148
|
+
if timeout_ms is None:
|
149
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
150
|
+
|
151
|
+
if server_url is not None:
|
152
|
+
base_url = server_url
|
153
|
+
else:
|
154
|
+
base_url = self._get_url(base_url, url_variables)
|
155
|
+
|
156
|
+
request = models.PropertyExtendedSearchRequest(
|
157
|
+
location=location,
|
158
|
+
page=page,
|
159
|
+
status_type=status_type,
|
160
|
+
home_type=home_type,
|
161
|
+
sort=sort,
|
162
|
+
min_price=min_price,
|
163
|
+
max_price=max_price,
|
164
|
+
)
|
165
|
+
|
166
|
+
req = self._build_request_async(
|
167
|
+
method="GET",
|
168
|
+
path="/propertyExtendedSearch",
|
169
|
+
base_url=base_url,
|
170
|
+
url_variables=url_variables,
|
171
|
+
request=request,
|
172
|
+
request_body_required=False,
|
173
|
+
request_has_path_params=False,
|
174
|
+
request_has_query_params=True,
|
175
|
+
user_agent_header="user-agent",
|
176
|
+
accept_header_value="application/json",
|
177
|
+
http_headers=http_headers,
|
178
|
+
timeout_ms=timeout_ms,
|
179
|
+
)
|
180
|
+
|
181
|
+
if retries == UNSET:
|
182
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
183
|
+
retries = self.sdk_configuration.retry_config
|
184
|
+
|
185
|
+
retry_config = None
|
186
|
+
if isinstance(retries, utils.RetryConfig):
|
187
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
188
|
+
|
189
|
+
http_res = await self.do_request_async(
|
190
|
+
hook_ctx=HookContext(
|
191
|
+
base_url=base_url or "",
|
192
|
+
operation_id="propertyExtendedSearch",
|
193
|
+
oauth2_scopes=[],
|
194
|
+
security_source=None,
|
195
|
+
),
|
196
|
+
request=req,
|
197
|
+
error_status_codes=["400", "4XX", "500", "5XX"],
|
198
|
+
retry_config=retry_config,
|
199
|
+
)
|
200
|
+
|
201
|
+
if utils.match_response(http_res, "200", "application/json"):
|
202
|
+
return utils.unmarshal_json(http_res.text, models.PropertySearchResponse)
|
203
|
+
if utils.match_response(http_res, ["400", "4XX"], "*"):
|
204
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
205
|
+
raise models.APIError(
|
206
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
207
|
+
)
|
208
|
+
if utils.match_response(http_res, ["500", "5XX"], "*"):
|
209
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
210
|
+
raise models.APIError(
|
211
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
212
|
+
)
|
213
|
+
|
214
|
+
content_type = http_res.headers.get("Content-Type")
|
215
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
216
|
+
raise models.APIError(
|
217
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
218
|
+
http_res.status_code,
|
219
|
+
http_res_text,
|
220
|
+
http_res,
|
221
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
# Marker file for PEP 561. The package enables type hints.
|
@@ -0,0 +1,114 @@
|
|
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
|
+
from typing import Dict, Optional, cast
|
10
|
+
import weakref
|
11
|
+
from zillow_rapidapi_client import utils
|
12
|
+
from zillow_rapidapi_client._hooks import SDKHooks
|
13
|
+
from zillow_rapidapi_client.properties import Properties
|
14
|
+
from zillow_rapidapi_client.types import OptionalNullable, UNSET
|
15
|
+
|
16
|
+
|
17
|
+
class ZillowRapidapiClient(BaseSDK):
|
18
|
+
r"""Zillow Property Extended Search API: API for searching properties using various filters."""
|
19
|
+
|
20
|
+
properties: Properties
|
21
|
+
|
22
|
+
def __init__(
|
23
|
+
self,
|
24
|
+
server_idx: Optional[int] = None,
|
25
|
+
server_url: Optional[str] = None,
|
26
|
+
url_params: Optional[Dict[str, str]] = None,
|
27
|
+
client: Optional[HttpClient] = None,
|
28
|
+
async_client: Optional[AsyncHttpClient] = None,
|
29
|
+
retry_config: OptionalNullable[RetryConfig] = UNSET,
|
30
|
+
timeout_ms: Optional[int] = None,
|
31
|
+
debug_logger: Optional[Logger] = None,
|
32
|
+
) -> None:
|
33
|
+
r"""Instantiates the SDK configuring it with the provided parameters.
|
34
|
+
|
35
|
+
:param server_idx: The index of the server to use for all methods
|
36
|
+
:param server_url: The server URL to use for all methods
|
37
|
+
:param url_params: Parameters to optionally template the server URL with
|
38
|
+
:param client: The HTTP client to use for all synchronous methods
|
39
|
+
:param async_client: The Async HTTP client to use for all asynchronous methods
|
40
|
+
:param retry_config: The retry configuration to use for all supported methods
|
41
|
+
:param timeout_ms: Optional request timeout applied to each operation in milliseconds
|
42
|
+
"""
|
43
|
+
if client is None:
|
44
|
+
client = httpx.Client()
|
45
|
+
|
46
|
+
assert issubclass(
|
47
|
+
type(client), HttpClient
|
48
|
+
), "The provided client must implement the HttpClient protocol."
|
49
|
+
|
50
|
+
if async_client is None:
|
51
|
+
async_client = httpx.AsyncClient()
|
52
|
+
|
53
|
+
if debug_logger is None:
|
54
|
+
debug_logger = get_default_logger()
|
55
|
+
|
56
|
+
assert issubclass(
|
57
|
+
type(async_client), AsyncHttpClient
|
58
|
+
), "The provided async_client must implement the AsyncHttpClient protocol."
|
59
|
+
|
60
|
+
if server_url is not None:
|
61
|
+
if url_params is not None:
|
62
|
+
server_url = utils.template_url(server_url, url_params)
|
63
|
+
|
64
|
+
BaseSDK.__init__(
|
65
|
+
self,
|
66
|
+
SDKConfiguration(
|
67
|
+
client=client,
|
68
|
+
async_client=async_client,
|
69
|
+
server_url=server_url,
|
70
|
+
server_idx=server_idx,
|
71
|
+
retry_config=retry_config,
|
72
|
+
timeout_ms=timeout_ms,
|
73
|
+
debug_logger=debug_logger,
|
74
|
+
),
|
75
|
+
)
|
76
|
+
|
77
|
+
hooks = SDKHooks()
|
78
|
+
|
79
|
+
current_server_url, *_ = self.sdk_configuration.get_server_details()
|
80
|
+
server_url, self.sdk_configuration.client = hooks.sdk_init(
|
81
|
+
current_server_url, self.sdk_configuration.client
|
82
|
+
)
|
83
|
+
if current_server_url != server_url:
|
84
|
+
self.sdk_configuration.server_url = server_url
|
85
|
+
|
86
|
+
# pylint: disable=protected-access
|
87
|
+
self.sdk_configuration.__dict__["_hooks"] = hooks
|
88
|
+
|
89
|
+
weakref.finalize(
|
90
|
+
self,
|
91
|
+
close_clients,
|
92
|
+
cast(ClientOwner, self.sdk_configuration),
|
93
|
+
self.sdk_configuration.client,
|
94
|
+
self.sdk_configuration.async_client,
|
95
|
+
)
|
96
|
+
|
97
|
+
self._init_sdks()
|
98
|
+
|
99
|
+
def _init_sdks(self):
|
100
|
+
self.properties = Properties(self.sdk_configuration)
|
101
|
+
|
102
|
+
def __enter__(self):
|
103
|
+
return self
|
104
|
+
|
105
|
+
async def __aenter__(self):
|
106
|
+
return self
|
107
|
+
|
108
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
109
|
+
if self.sdk_configuration.client is not None:
|
110
|
+
self.sdk_configuration.client.close()
|
111
|
+
|
112
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
113
|
+
if self.sdk_configuration.async_client is not None:
|
114
|
+
await self.sdk_configuration.async_client.aclose()
|
@@ -0,0 +1,52 @@
|
|
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 pydantic import Field
|
14
|
+
from typing import Dict, Optional, Tuple
|
15
|
+
from zillow_rapidapi_client.types import OptionalNullable, UNSET
|
16
|
+
|
17
|
+
|
18
|
+
SERVERS = [
|
19
|
+
"https://zillow-com1.p.rapidapi.com",
|
20
|
+
# RapidAPI Zillow Proxy
|
21
|
+
]
|
22
|
+
"""Contains the list of servers available to the SDK"""
|
23
|
+
|
24
|
+
|
25
|
+
@dataclass
|
26
|
+
class SDKConfiguration:
|
27
|
+
client: HttpClient
|
28
|
+
async_client: AsyncHttpClient
|
29
|
+
debug_logger: Logger
|
30
|
+
server_url: Optional[str] = ""
|
31
|
+
server_idx: Optional[int] = 0
|
32
|
+
language: str = "python"
|
33
|
+
openapi_doc_version: str = __openapi_doc_version__
|
34
|
+
sdk_version: str = __version__
|
35
|
+
gen_version: str = __gen_version__
|
36
|
+
user_agent: str = __user_agent__
|
37
|
+
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
38
|
+
timeout_ms: Optional[int] = None
|
39
|
+
|
40
|
+
def __post_init__(self):
|
41
|
+
self._hooks = SDKHooks()
|
42
|
+
|
43
|
+
def get_server_details(self) -> Tuple[str, Dict[str, str]]:
|
44
|
+
if self.server_url is not None and self.server_url:
|
45
|
+
return remove_suffix(self.server_url, "/"), {}
|
46
|
+
if self.server_idx is None:
|
47
|
+
self.server_idx = 0
|
48
|
+
|
49
|
+
return SERVERS[self.server_idx], {}
|
50
|
+
|
51
|
+
def get_hooks(self) -> SDKHooks:
|
52
|
+
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, NewType
|
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 = NewType("UnrecognizedInt", int)
|
39
|
+
UnrecognizedStr = NewType("UnrecognizedStr", str)
|
@@ -0,0 +1,99 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from .annotations import get_discriminator
|
4
|
+
from .enums import OpenEnumMeta
|
5
|
+
from .headers import get_headers, get_response_headers
|
6
|
+
from .metadata import (
|
7
|
+
FieldMetadata,
|
8
|
+
find_metadata,
|
9
|
+
FormMetadata,
|
10
|
+
HeaderMetadata,
|
11
|
+
MultipartFormMetadata,
|
12
|
+
PathParamMetadata,
|
13
|
+
QueryParamMetadata,
|
14
|
+
RequestMetadata,
|
15
|
+
SecurityMetadata,
|
16
|
+
)
|
17
|
+
from .queryparams import get_query_params
|
18
|
+
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
19
|
+
from .requestbodies import serialize_request_body, SerializedRequestBody
|
20
|
+
from .security import get_security
|
21
|
+
from .serializers import (
|
22
|
+
get_pydantic_model,
|
23
|
+
marshal_json,
|
24
|
+
unmarshal,
|
25
|
+
unmarshal_json,
|
26
|
+
serialize_decimal,
|
27
|
+
serialize_float,
|
28
|
+
serialize_int,
|
29
|
+
stream_to_text,
|
30
|
+
stream_to_text_async,
|
31
|
+
stream_to_bytes,
|
32
|
+
stream_to_bytes_async,
|
33
|
+
validate_const,
|
34
|
+
validate_decimal,
|
35
|
+
validate_float,
|
36
|
+
validate_int,
|
37
|
+
validate_open_enum,
|
38
|
+
)
|
39
|
+
from .url import generate_url, template_url, remove_suffix
|
40
|
+
from .values import (
|
41
|
+
get_global_from_env,
|
42
|
+
match_content_type,
|
43
|
+
match_status_codes,
|
44
|
+
match_response,
|
45
|
+
cast_partial,
|
46
|
+
)
|
47
|
+
from .logger import Logger, get_body_content, get_default_logger
|
48
|
+
|
49
|
+
__all__ = [
|
50
|
+
"BackoffStrategy",
|
51
|
+
"FieldMetadata",
|
52
|
+
"find_metadata",
|
53
|
+
"FormMetadata",
|
54
|
+
"generate_url",
|
55
|
+
"get_body_content",
|
56
|
+
"get_default_logger",
|
57
|
+
"get_discriminator",
|
58
|
+
"get_global_from_env",
|
59
|
+
"get_headers",
|
60
|
+
"get_pydantic_model",
|
61
|
+
"get_query_params",
|
62
|
+
"get_response_headers",
|
63
|
+
"get_security",
|
64
|
+
"HeaderMetadata",
|
65
|
+
"Logger",
|
66
|
+
"marshal_json",
|
67
|
+
"match_content_type",
|
68
|
+
"match_status_codes",
|
69
|
+
"match_response",
|
70
|
+
"MultipartFormMetadata",
|
71
|
+
"OpenEnumMeta",
|
72
|
+
"PathParamMetadata",
|
73
|
+
"QueryParamMetadata",
|
74
|
+
"remove_suffix",
|
75
|
+
"Retries",
|
76
|
+
"retry",
|
77
|
+
"retry_async",
|
78
|
+
"RetryConfig",
|
79
|
+
"RequestMetadata",
|
80
|
+
"SecurityMetadata",
|
81
|
+
"serialize_decimal",
|
82
|
+
"serialize_float",
|
83
|
+
"serialize_int",
|
84
|
+
"serialize_request_body",
|
85
|
+
"SerializedRequestBody",
|
86
|
+
"stream_to_text",
|
87
|
+
"stream_to_text_async",
|
88
|
+
"stream_to_bytes",
|
89
|
+
"stream_to_bytes_async",
|
90
|
+
"template_url",
|
91
|
+
"unmarshal",
|
92
|
+
"unmarshal_json",
|
93
|
+
"validate_decimal",
|
94
|
+
"validate_const",
|
95
|
+
"validate_float",
|
96
|
+
"validate_int",
|
97
|
+
"validate_open_enum",
|
98
|
+
"cast_partial",
|
99
|
+
]
|
@@ -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,34 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
import enum
|
4
|
+
|
5
|
+
|
6
|
+
class OpenEnumMeta(enum.EnumMeta):
|
7
|
+
def __call__(
|
8
|
+
cls, value, names=None, *, module=None, qualname=None, type=None, start=1
|
9
|
+
):
|
10
|
+
# The `type` kwarg also happens to be a built-in that pylint flags as
|
11
|
+
# redeclared. Safe to ignore this lint rule with this scope.
|
12
|
+
# pylint: disable=redefined-builtin
|
13
|
+
|
14
|
+
if names is not None:
|
15
|
+
return super().__call__(
|
16
|
+
value,
|
17
|
+
names=names,
|
18
|
+
module=module,
|
19
|
+
qualname=qualname,
|
20
|
+
type=type,
|
21
|
+
start=start,
|
22
|
+
)
|
23
|
+
|
24
|
+
try:
|
25
|
+
return super().__call__(
|
26
|
+
value,
|
27
|
+
names=names, # pyright: ignore[reportArgumentType]
|
28
|
+
module=module,
|
29
|
+
qualname=qualname,
|
30
|
+
type=type,
|
31
|
+
start=start,
|
32
|
+
)
|
33
|
+
except ValueError:
|
34
|
+
return value
|