-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_client.py
More file actions
26 lines (20 loc) · 839 Bytes
/
_client.py
File metadata and controls
26 lines (20 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import cast
from fishjam._openapi_client.client import AuthenticatedClient
from fishjam._openapi_client.models import Error
from fishjam._openapi_client.types import Response
from fishjam.errors import HTTPError
from fishjam.utils import get_fishjam_url
class Client:
def __init__(
self, fishjam_id: str, management_token: str, *, fishjam_url: str | None = None
):
self.client = AuthenticatedClient(
get_fishjam_url(fishjam_id, fishjam_url),
token=management_token,
)
def _request(self, method, **kwargs):
response = method.sync_detailed(client=self.client, **kwargs)
if isinstance(response.parsed, Error):
response = cast(Response[Error], response)
raise HTTPError.from_response(response)
return response.parsed