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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ Documentation is generated via openapi-python-client.

To update documentation you need to:

- in `poetry_scripts.py` change branch from which openapi.yaml should be downloaded
- run `poetry run update-client`
- Go to https://github.com/fishjam-cloud/fishjam/blob/main/openapi.yaml and open the raw file.
- Copy the URL.
- Run `poetry run update_client <copied-url>`

## License

Expand Down
131 changes: 131 additions & 0 deletions fishjam/_openapi_client/api/default/notification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union, cast

import httpx

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


def _get_kwargs() -> Dict[str, Any]:
return {
"method": "post",
"url": "/notifications",
}


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Error]]:
if response.status_code == HTTPStatus.NO_CONTENT:
response_204 = cast(Any, None)
return response_204
if response.status_code == HTTPStatus.UNAUTHORIZED:
response_401 = Error.from_dict(response.json())

return response_401
if response.status_code == HTTPStatus.NOT_FOUND:
response_404 = Error.from_dict(response.json())

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


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[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(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Any, Error]]:
"""Handle notification from broadcaster

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[Union[Any, Error]]
"""

kwargs = _get_kwargs()

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

return _build_response(client=client, response=response)


def sync(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Any, Error]]:
"""Handle notification from broadcaster

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:
Union[Any, Error]
"""

return sync_detailed(
client=client,
).parsed


async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Any, Error]]:
"""Handle notification from broadcaster

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[Union[Any, Error]]
"""

kwargs = _get_kwargs()

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

return _build_response(client=client, response=response)


async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Any, Error]]:
"""Handle notification from broadcaster

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:
Union[Any, Error]
"""

return (
await asyncio_detailed(
client=client,
)
).parsed
Empty file.
167 changes: 167 additions & 0 deletions fishjam/_openapi_client/api/streamer/generate_streamer_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union

import httpx

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


def _get_kwargs(
room_id: str,
) -> Dict[str, Any]:
return {
"method": "post",
"url": "/room/{room_id}/streamer".format(
room_id=room_id,
),
}


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, StreamerToken]]:
if response.status_code == HTTPStatus.CREATED:
response_201 = StreamerToken.from_dict(response.json())

return response_201
if response.status_code == HTTPStatus.BAD_REQUEST:
response_400 = Error.from_dict(response.json())

return response_400
if response.status_code == HTTPStatus.UNAUTHORIZED:
response_401 = Error.from_dict(response.json())

return response_401
if response.status_code == HTTPStatus.NOT_FOUND:
response_404 = Error.from_dict(response.json())

return response_404
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
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: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Error, StreamerToken]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, StreamerToken]]:
"""Generate a token that can be used by a streamer to start streaming

Args:
room_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[Union[Error, StreamerToken]]
"""

kwargs = _get_kwargs(
room_id=room_id,
)

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

return _build_response(client=client, response=response)


def sync(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, StreamerToken]]:
"""Generate a token that can be used by a streamer to start streaming

Args:
room_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:
Union[Error, StreamerToken]
"""

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


async def asyncio_detailed(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, StreamerToken]]:
"""Generate a token that can be used by a streamer to start streaming

Args:
room_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[Union[Error, StreamerToken]]
"""

kwargs = _get_kwargs(
room_id=room_id,
)

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

return _build_response(client=client, response=response)


async def asyncio(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, StreamerToken]]:
"""Generate a token that can be used by a streamer to start streaming

Args:
room_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:
Union[Error, StreamerToken]
"""

return (
await asyncio_detailed(
room_id=room_id,
client=client,
)
).parsed
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def sync_detailed(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, ViewerToken]]:
"""Generate single livestream access token
"""Generates token that a viewer can use to watch a livestream

Args:
room_id (str):
Expand Down Expand Up @@ -95,7 +95,7 @@ def sync(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, ViewerToken]]:
"""Generate single livestream access token
"""Generates token that a viewer can use to watch a livestream

Args:
room_id (str):
Expand All @@ -119,7 +119,7 @@ async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, ViewerToken]]:
"""Generate single livestream access token
"""Generates token that a viewer can use to watch a livestream

Args:
room_id (str):
Expand All @@ -146,7 +146,7 @@ async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, ViewerToken]]:
"""Generate single livestream access token
"""Generates token that a viewer can use to watch a livestream

Args:
room_id (str):
Expand Down
2 changes: 2 additions & 0 deletions fishjam/_openapi_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
from .shutdown_status import ShutdownStatus
from .shutdown_status_response import ShutdownStatusResponse
from .sip_credentials import SIPCredentials
from .streamer_token import StreamerToken
from .subscription_config import SubscriptionConfig
from .track import Track
from .track_type import TrackType
Expand Down Expand Up @@ -126,6 +127,7 @@
"ShutdownStatus",
"ShutdownStatusResponse",
"SIPCredentials",
"StreamerToken",
"SubscriptionConfig",
"Track",
"TrackType",
Expand Down
Loading