| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import time |
| 4 |
|
| 5 |
import anyio |
| 6 |
|
| 7 |
from ._base_client import SyncAPIClient, AsyncAPIClient |
| 8 |
|
| 9 |
|
| 10 |
class SyncAPIResource: |
| 11 |
_client: SyncAPIClient |
| 12 |
|
| 13 |
def __init__(self, client: SyncAPIClient) -> None: |
| 14 |
self._client = client |
| 15 |
self._get = client.get |
| 16 |
self._post = client.post |
| 17 |
self._patch = client.patch |
| 18 |
self._put = client.put |
| 19 |
self._delete = client.delete |
| 20 |
self._get_api_list = client.get_api_list |
| 21 |
|
| 22 |
def _sleep(self, seconds: float) -> None: |
| 23 |
time.sleep(seconds) |
| 24 |
|
| 25 |
|
| 26 |
class AsyncAPIResource: |
| 27 |
_client: AsyncAPIClient |
| 28 |
|
| 29 |
def __init__(self, client: AsyncAPIClient) -> None: |
| 30 |
self._client = client |
| 31 |
self._get = client.get |
| 32 |
self._post = client.post |
| 33 |
self._patch = client.patch |
| 34 |
self._put = client.put |
| 35 |
self._delete = client.delete |
| 36 |
self._get_api_list = client.get_api_list |
| 37 |
|
| 38 |
async def _sleep(self, seconds: float) -> None: |
| 39 |
await anyio.sleep(seconds) |