-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_client.py
More file actions
27 lines (21 loc) · 943 Bytes
/
_client.py
File metadata and controls
27 lines (21 loc) · 943 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
27
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
from fishjam.version import get_version
class Client:
def __init__(self, fishjam_id: str, management_token: str):
self._fishjam_url = get_fishjam_url(fishjam_id)
self.client = AuthenticatedClient(
self._fishjam_url,
token=management_token,
headers={"x-fishjam-api-client": f"python-server/{get_version()}"},
)
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