|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import os |
6 | | -from typing import Any, Mapping |
| 6 | +from typing import TYPE_CHECKING, Any, Mapping |
7 | 7 | from typing_extensions import Self, override |
8 | 8 |
|
9 | 9 | import httpx |
|
20 | 20 | not_given, |
21 | 21 | ) |
22 | 22 | from ._utils import is_given, get_async_library |
| 23 | +from ._compat import cached_property |
23 | 24 | from ._version import __version__ |
24 | | -from .resources import brand |
25 | 25 | from ._streaming import Stream as Stream, AsyncStream as AsyncStream |
26 | 26 | from ._exceptions import BrandDevError, APIStatusError |
27 | 27 | from ._base_client import ( |
|
30 | 30 | AsyncAPIClient, |
31 | 31 | ) |
32 | 32 |
|
| 33 | +if TYPE_CHECKING: |
| 34 | + from .resources import brand |
| 35 | + from .resources.brand import BrandResource, AsyncBrandResource |
| 36 | + |
33 | 37 | __all__ = [ |
34 | 38 | "Timeout", |
35 | 39 | "Transport", |
|
43 | 47 |
|
44 | 48 |
|
45 | 49 | class BrandDev(SyncAPIClient): |
46 | | - brand: brand.BrandResource |
47 | | - with_raw_response: BrandDevWithRawResponse |
48 | | - with_streaming_response: BrandDevWithStreamedResponse |
49 | | - |
50 | 50 | # client options |
51 | 51 | api_key: str |
52 | 52 |
|
@@ -101,9 +101,19 @@ def __init__( |
101 | 101 | _strict_response_validation=_strict_response_validation, |
102 | 102 | ) |
103 | 103 |
|
104 | | - self.brand = brand.BrandResource(self) |
105 | | - self.with_raw_response = BrandDevWithRawResponse(self) |
106 | | - self.with_streaming_response = BrandDevWithStreamedResponse(self) |
| 104 | + @cached_property |
| 105 | + def brand(self) -> BrandResource: |
| 106 | + from .resources.brand import BrandResource |
| 107 | + |
| 108 | + return BrandResource(self) |
| 109 | + |
| 110 | + @cached_property |
| 111 | + def with_raw_response(self) -> BrandDevWithRawResponse: |
| 112 | + return BrandDevWithRawResponse(self) |
| 113 | + |
| 114 | + @cached_property |
| 115 | + def with_streaming_response(self) -> BrandDevWithStreamedResponse: |
| 116 | + return BrandDevWithStreamedResponse(self) |
107 | 117 |
|
108 | 118 | @property |
109 | 119 | @override |
@@ -211,10 +221,6 @@ def _make_status_error( |
211 | 221 |
|
212 | 222 |
|
213 | 223 | class AsyncBrandDev(AsyncAPIClient): |
214 | | - brand: brand.AsyncBrandResource |
215 | | - with_raw_response: AsyncBrandDevWithRawResponse |
216 | | - with_streaming_response: AsyncBrandDevWithStreamedResponse |
217 | | - |
218 | 224 | # client options |
219 | 225 | api_key: str |
220 | 226 |
|
@@ -269,9 +275,19 @@ def __init__( |
269 | 275 | _strict_response_validation=_strict_response_validation, |
270 | 276 | ) |
271 | 277 |
|
272 | | - self.brand = brand.AsyncBrandResource(self) |
273 | | - self.with_raw_response = AsyncBrandDevWithRawResponse(self) |
274 | | - self.with_streaming_response = AsyncBrandDevWithStreamedResponse(self) |
| 278 | + @cached_property |
| 279 | + def brand(self) -> AsyncBrandResource: |
| 280 | + from .resources.brand import AsyncBrandResource |
| 281 | + |
| 282 | + return AsyncBrandResource(self) |
| 283 | + |
| 284 | + @cached_property |
| 285 | + def with_raw_response(self) -> AsyncBrandDevWithRawResponse: |
| 286 | + return AsyncBrandDevWithRawResponse(self) |
| 287 | + |
| 288 | + @cached_property |
| 289 | + def with_streaming_response(self) -> AsyncBrandDevWithStreamedResponse: |
| 290 | + return AsyncBrandDevWithStreamedResponse(self) |
275 | 291 |
|
276 | 292 | @property |
277 | 293 | @override |
@@ -379,23 +395,55 @@ def _make_status_error( |
379 | 395 |
|
380 | 396 |
|
381 | 397 | class BrandDevWithRawResponse: |
| 398 | + _client: BrandDev |
| 399 | + |
382 | 400 | def __init__(self, client: BrandDev) -> None: |
383 | | - self.brand = brand.BrandResourceWithRawResponse(client.brand) |
| 401 | + self._client = client |
| 402 | + |
| 403 | + @cached_property |
| 404 | + def brand(self) -> brand.BrandResourceWithRawResponse: |
| 405 | + from .resources.brand import BrandResourceWithRawResponse |
| 406 | + |
| 407 | + return BrandResourceWithRawResponse(self._client.brand) |
384 | 408 |
|
385 | 409 |
|
386 | 410 | class AsyncBrandDevWithRawResponse: |
| 411 | + _client: AsyncBrandDev |
| 412 | + |
387 | 413 | def __init__(self, client: AsyncBrandDev) -> None: |
388 | | - self.brand = brand.AsyncBrandResourceWithRawResponse(client.brand) |
| 414 | + self._client = client |
| 415 | + |
| 416 | + @cached_property |
| 417 | + def brand(self) -> brand.AsyncBrandResourceWithRawResponse: |
| 418 | + from .resources.brand import AsyncBrandResourceWithRawResponse |
| 419 | + |
| 420 | + return AsyncBrandResourceWithRawResponse(self._client.brand) |
389 | 421 |
|
390 | 422 |
|
391 | 423 | class BrandDevWithStreamedResponse: |
| 424 | + _client: BrandDev |
| 425 | + |
392 | 426 | def __init__(self, client: BrandDev) -> None: |
393 | | - self.brand = brand.BrandResourceWithStreamingResponse(client.brand) |
| 427 | + self._client = client |
| 428 | + |
| 429 | + @cached_property |
| 430 | + def brand(self) -> brand.BrandResourceWithStreamingResponse: |
| 431 | + from .resources.brand import BrandResourceWithStreamingResponse |
| 432 | + |
| 433 | + return BrandResourceWithStreamingResponse(self._client.brand) |
394 | 434 |
|
395 | 435 |
|
396 | 436 | class AsyncBrandDevWithStreamedResponse: |
| 437 | + _client: AsyncBrandDev |
| 438 | + |
397 | 439 | def __init__(self, client: AsyncBrandDev) -> None: |
398 | | - self.brand = brand.AsyncBrandResourceWithStreamingResponse(client.brand) |
| 440 | + self._client = client |
| 441 | + |
| 442 | + @cached_property |
| 443 | + def brand(self) -> brand.AsyncBrandResourceWithStreamingResponse: |
| 444 | + from .resources.brand import AsyncBrandResourceWithStreamingResponse |
| 445 | + |
| 446 | + return AsyncBrandResourceWithStreamingResponse(self._client.brand) |
399 | 447 |
|
400 | 448 |
|
401 | 449 | Client = BrandDev |
|
0 commit comments