From 23259e97bf481079d384ba179865f487bb688cea Mon Sep 17 00:00:00 2001 From: Adrian Czerwiec Date: Wed, 26 Mar 2025 14:50:11 +0100 Subject: [PATCH 1/2] add room type query param --- examples/room_manager/room_service.py | 17 ++++++++++++++--- examples/room_manager/routes.py | 17 +++++++++++++++-- fishjam/room/__init__.py | 8 ++++++-- protos | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/examples/room_manager/room_service.py b/examples/room_manager/room_service.py index 03d9d1f..17d43ec 100644 --- a/examples/room_manager/room_service.py +++ b/examples/room_manager/room_service.py @@ -6,6 +6,7 @@ import betterproto from fishjam import FishjamClient, PeerOptions, Room, RoomOptions +from fishjam._openapi_client.models import RoomConfigRoomType from fishjam.events import ServerMessagePeerCrashed as PeerCrashed from fishjam.events import ServerMessagePeerDeleted as PeerDeleted from fishjam.events import ServerMessageRoomCrashed as RoomCrashed @@ -38,8 +39,15 @@ def __init__(self, args: Namespace, logger: Logger): self.logger = logger self.config = args - def get_peer_access(self, room_name: str, username: str) -> PeerAccess: - room = self.__find_or_create_room(room_name) + def get_peer_access( + self, + room_name: str, + username: str, + room_type: RoomConfigRoomType | None, + ) -> PeerAccess: + room = self.__find_or_create_room( + room_name, room_type or RoomConfigRoomType.FULL_FEATURE + ) peer_access = self.peer_name_to_access.get(username) peer_in_room = self.__is_in_room(room, peer_access) @@ -63,7 +71,9 @@ def handle_notification(self, notification: betterproto.Message): case _: pass - def __find_or_create_room(self, room_name: str) -> Room: + def __find_or_create_room( + self, room_name: str, room_type: RoomConfigRoomType + ) -> Room: if room_name in self.room_name_to_room_id: self.logger.info("Room %s, already exists in the Fishjam", room_name) @@ -74,6 +84,7 @@ def __find_or_create_room(self, room_name: str) -> Room: max_peers=self.config.max_peers, webhook_url=self.config.webhook_url, peerless_purge_timeout=self.config.peerless_purge_timeout, + room_type=room_type.value, ) new_room = self.fishjam_client.create_room(options=options) diff --git a/examples/room_manager/routes.py b/examples/room_manager/routes.py index 46cd9c9..2d608a4 100644 --- a/examples/room_manager/routes.py +++ b/examples/room_manager/routes.py @@ -3,6 +3,7 @@ from flask import Flask, abort, jsonify, request from fishjam import receive_binary +from fishjam.room import RoomConfigRoomType from .room_service import RoomService @@ -15,7 +16,13 @@ def health_check(): @app.get("/api/rooms//users/") def get_room_params(room_name, peer_name): - access_data = room_service.get_peer_access(room_name, peer_name) + raw_room_type = request.args.get("roomType") + try: + room_type = RoomConfigRoomType(raw_room_type) if raw_room_type else None + except ValueError: + return abort(400) + + access_data = room_service.get_peer_access(room_name, peer_name, room_type) response = asdict(access_data) response["peerToken"] = response.pop("peer_token") @@ -25,12 +32,18 @@ def get_room_params(room_name, peer_name): @app.get("/api/rooms") def get_room_query(): room_name = request.args.get("roomName") + raw_room_type = request.args.get("roomType") peer_name = request.args.get("peerName") if not room_name or not peer_name: return abort(400) - access_data = room_service.get_peer_access(room_name, peer_name) + try: + room_type = RoomConfigRoomType(raw_room_type) if raw_room_type else None + except ValueError: + return abort(400) + + access_data = room_service.get_peer_access(room_name, peer_name, room_type) response = asdict(access_data) response["peerToken"] = response.pop("peer_token") diff --git a/fishjam/room/__init__.py b/fishjam/room/__init__.py index a4ee1bc..c9b4fe5 100644 --- a/fishjam/room/__init__.py +++ b/fishjam/room/__init__.py @@ -1,3 +1,7 @@ -from fishjam._openapi_client.models import RoomConfig, RoomConfigVideoCodec +from fishjam._openapi_client.models import ( + RoomConfig, + RoomConfigRoomType, + RoomConfigVideoCodec, +) -__all__ = ["RoomConfig", "RoomConfigVideoCodec"] +__all__ = ["RoomConfig", "RoomConfigVideoCodec", "RoomConfigRoomType"] diff --git a/protos b/protos index f8b5c34..2de4c0f 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit f8b5c34643e2f649746ae111defecee923cfaf96 +Subproject commit 2de4c0f072525463663f81fdde3419966fdabfff From 19472e43ec46763013120a614bcce0b37254af80 Mon Sep 17 00:00:00 2001 From: Adrian Czerwiec Date: Wed, 26 Mar 2025 15:53:43 +0100 Subject: [PATCH 2/2] add cors, slightly refactor, test and update client --- examples/room_manager/main.py | 2 + examples/room_manager/room_service.py | 9 +- .../_openapi_client/api/default/__init__.py | 0 .../_openapi_client/api/default/drain_node.py | 127 ++++++++++++++ .../api/default/shutdown_status.py | 129 ++++++++++++++ .../_openapi_client/api/health/__init__.py | 0 .../_openapi_client/api/health/healthcheck.py | 129 ++++++++++++++ fishjam/_openapi_client/api/user/__init__.py | 0 .../_openapi_client/api/user/delete_user.py | 157 ++++++++++++++++++ .../_openapi_client/api/user/get_all_users.py | 133 +++++++++++++++ fishjam/_openapi_client/models/__init__.py | 6 +- .../models/component_options_file.py | 2 +- .../models/component_properties_file.py | 2 +- fishjam/_openapi_client/models/user.py | 67 ++++++++ .../models/user_listing_response.py | 75 +++++++++ 15 files changed, 830 insertions(+), 8 deletions(-) create mode 100644 fishjam/_openapi_client/api/default/__init__.py create mode 100644 fishjam/_openapi_client/api/default/drain_node.py create mode 100644 fishjam/_openapi_client/api/default/shutdown_status.py create mode 100644 fishjam/_openapi_client/api/health/__init__.py create mode 100644 fishjam/_openapi_client/api/health/healthcheck.py create mode 100644 fishjam/_openapi_client/api/user/__init__.py create mode 100644 fishjam/_openapi_client/api/user/delete_user.py create mode 100644 fishjam/_openapi_client/api/user/get_all_users.py create mode 100644 fishjam/_openapi_client/models/user.py create mode 100644 fishjam/_openapi_client/models/user_listing_response.py diff --git a/examples/room_manager/main.py b/examples/room_manager/main.py index 0c89c0a..4801feb 100755 --- a/examples/room_manager/main.py +++ b/examples/room_manager/main.py @@ -1,12 +1,14 @@ import logging from flask import Flask +from flask_cors import CORS from .arguments import parse_arguments from .room_service import RoomService from .routes import setup_routes app = Flask(__name__) +CORS(app) app.logger.setLevel(logging.INFO) diff --git a/examples/room_manager/room_service.py b/examples/room_manager/room_service.py index 17d43ec..a400c86 100644 --- a/examples/room_manager/room_service.py +++ b/examples/room_manager/room_service.py @@ -45,9 +45,7 @@ def get_peer_access( username: str, room_type: RoomConfigRoomType | None, ) -> PeerAccess: - room = self.__find_or_create_room( - room_name, room_type or RoomConfigRoomType.FULL_FEATURE - ) + room = self.__find_or_create_room(room_name, room_type) peer_access = self.peer_name_to_access.get(username) peer_in_room = self.__is_in_room(room, peer_access) @@ -72,7 +70,7 @@ def handle_notification(self, notification: betterproto.Message): pass def __find_or_create_room( - self, room_name: str, room_type: RoomConfigRoomType + self, room_name: str, room_type: RoomConfigRoomType | None ) -> Room: if room_name in self.room_name_to_room_id: self.logger.info("Room %s, already exists in the Fishjam", room_name) @@ -84,8 +82,9 @@ def __find_or_create_room( max_peers=self.config.max_peers, webhook_url=self.config.webhook_url, peerless_purge_timeout=self.config.peerless_purge_timeout, - room_type=room_type.value, + room_type=room_type.value if room_type else "full_feature", ) + new_room = self.fishjam_client.create_room(options=options) self.room_name_to_room_id[room_name] = new_room.id diff --git a/fishjam/_openapi_client/api/default/__init__.py b/fishjam/_openapi_client/api/default/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fishjam/_openapi_client/api/default/drain_node.py b/fishjam/_openapi_client/api/default/drain_node.py new file mode 100644 index 0000000..5b58a33 --- /dev/null +++ b/fishjam/_openapi_client/api/default/drain_node.py @@ -0,0 +1,127 @@ +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": "/admin/shutdown/drain", + } + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, Error]]: + if response.status_code == HTTPStatus.OK: + response_200 = cast(Any, None) + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = Error.from_dict(response.json()) + + return response_401 + 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: AuthenticatedClient, +) -> Response[Union[Any, Error]]: + """Marks node as draining, making it the last in the load balancing order. + + 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: AuthenticatedClient, +) -> Optional[Union[Any, Error]]: + """Marks node as draining, making it the last in the load balancing order. + + 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: AuthenticatedClient, +) -> Response[Union[Any, Error]]: + """Marks node as draining, making it the last in the load balancing order. + + 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: AuthenticatedClient, +) -> Optional[Union[Any, Error]]: + """Marks node as draining, making it the last in the load balancing order. + + 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 diff --git a/fishjam/_openapi_client/api/default/shutdown_status.py b/fishjam/_openapi_client/api/default/shutdown_status.py new file mode 100644 index 0000000..b68e607 --- /dev/null +++ b/fishjam/_openapi_client/api/default/shutdown_status.py @@ -0,0 +1,129 @@ +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.shutdown_status_response import ShutdownStatusResponse +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + return { + "method": "get", + "url": "/admin/shutdown/status", + } + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Error, ShutdownStatusResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = ShutdownStatusResponse.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = Error.from_dict(response.json()) + + return response_401 + 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, ShutdownStatusResponse]]: + 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, +) -> Response[Union[Error, ShutdownStatusResponse]]: + """Returns status information for the shutdown process of Fishjam. + + 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, ShutdownStatusResponse]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, ShutdownStatusResponse]]: + """Returns status information for the shutdown process of Fishjam. + + 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, ShutdownStatusResponse] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, +) -> Response[Union[Error, ShutdownStatusResponse]]: + """Returns status information for the shutdown process of Fishjam. + + 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, ShutdownStatusResponse]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, ShutdownStatusResponse]]: + """Returns status information for the shutdown process of Fishjam. + + 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, ShutdownStatusResponse] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fishjam/_openapi_client/api/health/__init__.py b/fishjam/_openapi_client/api/health/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fishjam/_openapi_client/api/health/healthcheck.py b/fishjam/_openapi_client/api/health/healthcheck.py new file mode 100644 index 0000000..7d0a9ba --- /dev/null +++ b/fishjam/_openapi_client/api/health/healthcheck.py @@ -0,0 +1,129 @@ +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.healthcheck_response import HealthcheckResponse +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + return { + "method": "get", + "url": "/admin/health", + } + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Error, HealthcheckResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = HealthcheckResponse.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = Error.from_dict(response.json()) + + return response_401 + 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, HealthcheckResponse]]: + 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, +) -> Response[Union[Error, HealthcheckResponse]]: + """Describes the health of Fishjam + + 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, HealthcheckResponse]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, HealthcheckResponse]]: + """Describes the health of Fishjam + + 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, HealthcheckResponse] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, +) -> Response[Union[Error, HealthcheckResponse]]: + """Describes the health of Fishjam + + 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, HealthcheckResponse]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, HealthcheckResponse]]: + """Describes the health of Fishjam + + 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, HealthcheckResponse] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fishjam/_openapi_client/api/user/__init__.py b/fishjam/_openapi_client/api/user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fishjam/_openapi_client/api/user/delete_user.py b/fishjam/_openapi_client/api/user/delete_user.py new file mode 100644 index 0000000..09836cd --- /dev/null +++ b/fishjam/_openapi_client/api/user/delete_user.py @@ -0,0 +1,157 @@ +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( + id: str, +) -> Dict[str, Any]: + return { + "method": "delete", + "url": "/admin/user/{id}".format( + id=id, + ), + } + + +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.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[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( + id: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, Error]]: + """Removes user with provided user id + + Args: + 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[Any, Error]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, Error]]: + """Removes user with provided user id + + Args: + 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[Any, Error] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient, +) -> Response[Union[Any, Error]]: + """Removes user with provided user id + + Args: + 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[Any, Error]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: AuthenticatedClient, +) -> Optional[Union[Any, Error]]: + """Removes user with provided user id + + Args: + 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[Any, Error] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/fishjam/_openapi_client/api/user/get_all_users.py b/fishjam/_openapi_client/api/user/get_all_users.py new file mode 100644 index 0000000..3dbc290 --- /dev/null +++ b/fishjam/_openapi_client/api/user/get_all_users.py @@ -0,0 +1,133 @@ +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.user_listing_response import UserListingResponse +from ...types import Response + + +def _get_kwargs() -> Dict[str, Any]: + return { + "method": "get", + "url": "/admin/user", + } + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Error, UserListingResponse]]: + if response.status_code == HTTPStatus.OK: + response_200 = UserListingResponse.from_dict(response.json()) + + return response_200 + if response.status_code == HTTPStatus.UNAUTHORIZED: + response_401 = Error.from_dict(response.json()) + + return response_401 + 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, UserListingResponse]]: + 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, +) -> Response[Union[Error, UserListingResponse]]: + """Show information about all users + + 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, UserListingResponse]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, UserListingResponse]]: + """Show information about all users + + 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, UserListingResponse] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, +) -> Response[Union[Error, UserListingResponse]]: + """Show information about all users + + 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, UserListingResponse]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, +) -> Optional[Union[Error, UserListingResponse]]: + """Show information about all users + + 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, UserListingResponse] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/fishjam/_openapi_client/models/__init__.py b/fishjam/_openapi_client/models/__init__.py index c5c2d92..6a64a58 100644 --- a/fishjam/_openapi_client/models/__init__.py +++ b/fishjam/_openapi_client/models/__init__.py @@ -1,4 +1,4 @@ -"""Contains all the data models used in inputs/outputs""" +""" Contains all the data models used in inputs/outputs """ from .add_component_json_body import AddComponentJsonBody from .add_peer_json_body import AddPeerJsonBody @@ -66,6 +66,8 @@ from .subscription_config import SubscriptionConfig from .track import Track from .track_type import TrackType +from .user import User +from .user_listing_response import UserListingResponse __all__ = ( "AddComponentJsonBody", @@ -126,4 +128,6 @@ "SubscriptionConfig", "Track", "TrackType", + "User", + "UserListingResponse", ) diff --git a/fishjam/_openapi_client/models/component_options_file.py b/fishjam/_openapi_client/models/component_options_file.py index e2945fc..f843c8e 100644 --- a/fishjam/_openapi_client/models/component_options_file.py +++ b/fishjam/_openapi_client/models/component_options_file.py @@ -13,7 +13,7 @@ class ComponentOptionsFile: """Options specific to the File component""" file_path: str - """Path to track file. Must be either OPUS encapsulated in Ogg or raw h264""" + """Path to track file. Must be either opus encapsulated in Ogg or raw h264""" framerate: Union[Unset, None, int] = UNSET """Framerate of video in a file. It is only valid for video track""" additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) diff --git a/fishjam/_openapi_client/models/component_properties_file.py b/fishjam/_openapi_client/models/component_properties_file.py index e5824dc..b357604 100644 --- a/fishjam/_openapi_client/models/component_properties_file.py +++ b/fishjam/_openapi_client/models/component_properties_file.py @@ -11,7 +11,7 @@ class ComponentPropertiesFile: """Properties specific to the File component""" file_path: str - """Relative path to track file. Must be either OPUS encapsulated in Ogg or raw h264""" + """Relative path to track file. Must be either opus encapsulated in Ogg or raw h264""" framerate: Optional[int] """Framerate of video in a file. It is only valid for video track""" additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) diff --git a/fishjam/_openapi_client/models/user.py b/fishjam/_openapi_client/models/user.py new file mode 100644 index 0000000..1725167 --- /dev/null +++ b/fishjam/_openapi_client/models/user.py @@ -0,0 +1,67 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="User") + + +@_attrs_define +class User: + """Description of the user state""" + + token: str + """User token, has to be in UUID format""" + user_id: str + """User ID""" + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + """@private""" + + def to_dict(self) -> Dict[str, Any]: + """@private""" + token = self.token + user_id = self.user_id + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "token": token, + "user_id": user_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + """@private""" + d = src_dict.copy() + token = d.pop("token") + + user_id = d.pop("user_id") + + user = cls( + token=token, + user_id=user_id, + ) + + user.additional_properties = d + return user + + @property + def additional_keys(self) -> List[str]: + """@private""" + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/fishjam/_openapi_client/models/user_listing_response.py b/fishjam/_openapi_client/models/user_listing_response.py new file mode 100644 index 0000000..1d1ee77 --- /dev/null +++ b/fishjam/_openapi_client/models/user_listing_response.py @@ -0,0 +1,75 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.user import User + + +T = TypeVar("T", bound="UserListingResponse") + + +@_attrs_define +class UserListingResponse: + """Response containing list of all users""" + + data: List["User"] + """None""" + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + """@private""" + + def to_dict(self) -> Dict[str, Any]: + """@private""" + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + + data.append(data_item) + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + """@private""" + from ..models.user import User + + d = src_dict.copy() + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = User.from_dict(data_item_data) + + data.append(data_item) + + user_listing_response = cls( + data=data, + ) + + user_listing_response.additional_properties = d + return user_listing_response + + @property + def additional_keys(self) -> List[str]: + """@private""" + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties