pixel-client 1.1.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.
- pixel_client/__init__.py +68 -0
- pixel_client/_base.py +2540 -0
- pixel_client/_sync.py +1494 -0
- pixel_client/auth.py +65 -0
- pixel_client/exceptions.py +54 -0
- pixel_client/models.py +423 -0
- pixel_client/py.typed +0 -0
- pixel_client/settings.py +38 -0
- pixel_client/types.py +16 -0
- pixel_client/utils.py +91 -0
- pixel_client-1.1.0.dist-info/METADATA +267 -0
- pixel_client-1.1.0.dist-info/RECORD +14 -0
- pixel_client-1.1.0.dist-info/WHEEL +4 -0
- pixel_client-1.1.0.dist-info/licenses/LICENSE.txt +201 -0
pixel_client/__init__.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from importlib.metadata import version
|
|
2
|
+
from typing import overload, Literal, Unpack
|
|
3
|
+
from functools import lru_cache
|
|
4
|
+
from ._base import PixelClientAsync, PixelClientKwargs
|
|
5
|
+
from ._sync import PixelClient
|
|
6
|
+
from .settings import PixelApiSettings
|
|
7
|
+
|
|
8
|
+
from .models import * # noqa: F403
|
|
9
|
+
|
|
10
|
+
__version__ = version("pixel_client")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@overload
|
|
14
|
+
def get_client(
|
|
15
|
+
async_: Literal[False] = ...,
|
|
16
|
+
settings: PixelApiSettings | None = None,
|
|
17
|
+
**kwargs: Unpack[PixelClientKwargs],
|
|
18
|
+
) -> PixelClient: ...
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@overload
|
|
22
|
+
def get_client(
|
|
23
|
+
async_: Literal[True] = ...,
|
|
24
|
+
settings: PixelApiSettings | None = None,
|
|
25
|
+
**kwargs: Unpack[PixelClientKwargs],
|
|
26
|
+
) -> PixelClientAsync: ...
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_client(
|
|
30
|
+
async_: bool = False,
|
|
31
|
+
settings: PixelApiSettings | None = None,
|
|
32
|
+
**kwargs: Unpack[PixelClientKwargs],
|
|
33
|
+
) -> PixelClientAsync | PixelClient:
|
|
34
|
+
"""
|
|
35
|
+
Get the pixel client.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
async_ (bool): Whether to return an asynchronous client.
|
|
39
|
+
settings (PixelApiSettings | None): Settings for the Pixel API client. If None, defaults are used.
|
|
40
|
+
**kwargs: Additional keyword arguments to pass to the client constructor.
|
|
41
|
+
Returns:
|
|
42
|
+
PixelClientAsync | PixelClient: An instance of the Pixel API client, either synchronous or asynchronous.
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
```python
|
|
46
|
+
from pixel_client import get_client, PixelApiSettings
|
|
47
|
+
# Settings from environment variables
|
|
48
|
+
async_client = get_client(async_=True)
|
|
49
|
+
# Settings from a .env file, see https://docs.pydantic.dev/latest/concepts/pydantic_settings/#dotenv-env-support
|
|
50
|
+
settings = PixelApiSettings(_env_file="path/to/.env")
|
|
51
|
+
# async_ defaults to False, so this will return a synchronous client
|
|
52
|
+
sync_client = get_client(settings=settings)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note:
|
|
56
|
+
The client is cached and will be reused on subsequent calls, unless the settings change.
|
|
57
|
+
"""
|
|
58
|
+
return _cached_get_client(async_, settings or PixelApiSettings(), **kwargs) # type: ignore
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@lru_cache
|
|
62
|
+
def _cached_get_client(
|
|
63
|
+
async_: bool, settings: PixelApiSettings, **kwargs: Unpack[PixelClientKwargs]
|
|
64
|
+
) -> PixelClientAsync | PixelClient:
|
|
65
|
+
async_client = PixelClientAsync.from_settings(settings, **kwargs)
|
|
66
|
+
if async_:
|
|
67
|
+
return async_client
|
|
68
|
+
return PixelClient(async_client)
|