Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fishjam/_openapi_client/api/recordings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
189 changes: 189 additions & 0 deletions fishjam/_openapi_client/api/recordings/create_recording.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
from http import HTTPStatus
from typing import Any

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.recording_config import RecordingConfig
from ...models.recording_details_response import RecordingDetailsResponse
from ...types import Response


def _get_kwargs(
*,
body: RecordingConfig,
) -> dict[str, Any]:
headers: dict[str, Any] = {}

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/recordings",
}

_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Error | RecordingDetailsResponse | None:
if response.status_code == 201:
response_201 = RecordingDetailsResponse.from_dict(response.json())

return response_201

if response.status_code == 400:
response_400 = Error.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = Error.from_dict(response.json())

return response_401

if response.status_code == 402:
response_402 = Error.from_dict(response.json())

return response_402

if response.status_code == 503:
response_503 = Error.from_dict(response.json())

return response_503

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[Error | RecordingDetailsResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: AuthenticatedClient,
body: RecordingConfig,
) -> Response[Error | RecordingDetailsResponse]:
"""Create a recording

Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.

Args:
body (RecordingConfig): Recording configuration

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Error | RecordingDetailsResponse]
"""

kwargs = _get_kwargs(
body=body,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
*,
client: AuthenticatedClient,
body: RecordingConfig,
) -> Error | RecordingDetailsResponse | None:
"""Create a recording

Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.

Args:
body (RecordingConfig): Recording configuration

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Error | RecordingDetailsResponse
"""

return sync_detailed(
client=client,
body=body,
).parsed


async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: RecordingConfig,
) -> Response[Error | RecordingDetailsResponse]:
"""Create a recording

Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.

Args:
body (RecordingConfig): Recording configuration

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Error | RecordingDetailsResponse]
"""

kwargs = _get_kwargs(
body=body,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
*,
client: AuthenticatedClient,
body: RecordingConfig,
) -> Error | RecordingDetailsResponse | None:
"""Create a recording

Create a recording resource. Capturing starts synchronously, so it is returned with status `active`.

Args:
body (RecordingConfig): Recording configuration

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Error | RecordingDetailsResponse
"""

return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
171 changes: 171 additions & 0 deletions fishjam/_openapi_client/api/recordings/delete_recording.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
from http import HTTPStatus
from typing import Any, cast
from urllib.parse import quote

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response


def _get_kwargs(
recording_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/recordings/{recording_id}".format(
recording_id=quote(str(recording_id), safe=""),
),
}

return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Any | Error | None:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204

if response.status_code == 401:
response_401 = Error.from_dict(response.json())

return response_401

if response.status_code == 503:
response_503 = Error.from_dict(response.json())

return response_503

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[Any | Error]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
recording_id: str,
*,
client: AuthenticatedClient,
) -> Response[Any | Error]:
"""Delete a recording

Delete a recording by id.

Args:
recording_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any | Error]
"""

kwargs = _get_kwargs(
recording_id=recording_id,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
recording_id: str,
*,
client: AuthenticatedClient,
) -> Any | Error | None:
"""Delete a recording

Delete a recording by id.

Args:
recording_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Any | Error
"""

return sync_detailed(
recording_id=recording_id,
client=client,
).parsed


async def asyncio_detailed(
recording_id: str,
*,
client: AuthenticatedClient,
) -> Response[Any | Error]:
"""Delete a recording

Delete a recording by id.

Args:
recording_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Any | Error]
"""

kwargs = _get_kwargs(
recording_id=recording_id,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
recording_id: str,
*,
client: AuthenticatedClient,
) -> Any | Error | None:
"""Delete a recording

Delete a recording by id.

Args:
recording_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Any | Error
"""

return (
await asyncio_detailed(
recording_id=recording_id,
client=client,
)
).parsed
Loading
Loading