From 3160e116733f03a5dd2d5e3f9c9ffd4c810e902a Mon Sep 17 00:00:00 2001 From: mj23000 Date: Fri, 22 Nov 2024 18:37:56 +0100 Subject: [PATCH] Fix callback setters not supporting awaitable callbacks --- docs/mozart-api.yaml | 2 +- python_client/PKG-INFO | 2 +- python_client/mozart_api/__init__.py | 2 +- python_client/mozart_api/api_client.py | 2 +- python_client/mozart_api/configuration.py | 2 +- python_client/mozart_api/mozart_client.py | 142 +++++++++++++++------- python_client/pyproject.toml | 2 +- 7 files changed, 107 insertions(+), 47 deletions(-) diff --git a/docs/mozart-api.yaml b/docs/mozart-api.yaml index e6ecc3e..c579e0f 100644 --- a/docs/mozart-api.yaml +++ b/docs/mozart-api.yaml @@ -5520,7 +5520,7 @@ info: - [Beosound Level](https://www.bang-olufsen.com/en/dk/speakers/beosound-level)\n\ - [Beosound Theatre](https://www.bang-olufsen.com/en/dk/soundbars/beosound-theatre)\n\ \n\nThis API documentation has been generated for version 4.1.1.116 of the\ - \ Mozart platform and API generation version 4.1.1.116.2.\n\n## Python API\n\ + \ Mozart platform and API generation version 4.1.1.116.3.\n\n## Python API\n\ \nThe Python package has been generated using the [OpenAPI Generator](https:/openapi-generator.tech/)\ \ version 7.10.0. On top of the generated API, a helper file, mozart_client.py,\ \ has been made that makes the API more pythonic. We recommend using this.\n\ diff --git a/python_client/PKG-INFO b/python_client/PKG-INFO index c9da7e7..2404b95 100644 --- a/python_client/PKG-INFO +++ b/python_client/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: mozart_api -Version: 4.1.1.116.2 +Version: 4.1.1.116.3 Summary: Mozart platform API Home-page: https://pypi.org/project/mozart-api/ License: MIT diff --git a/python_client/mozart_api/__init__.py b/python_client/mozart_api/__init__.py index e6118c7..db2905f 100644 --- a/python_client/mozart_api/__init__.py +++ b/python_client/mozart_api/__init__.py @@ -14,7 +14,7 @@ Do not edit the class manually. """ # noqa: E501 -__version__ = "4.1.1.116.2" +__version__ = "4.1.1.116.3" # import manually created api client from mozart_api.mozart_client import ( diff --git a/python_client/mozart_api/api_client.py b/python_client/mozart_api/api_client.py index 1a29d44..3a9e8a8 100644 --- a/python_client/mozart_api/api_client.py +++ b/python_client/mozart_api/api_client.py @@ -87,7 +87,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/4.1.1.116.2/python" + self.user_agent = "OpenAPI-Generator/4.1.1.116.3/python" self.client_side_validation = configuration.client_side_validation async def __aenter__(self): diff --git a/python_client/mozart_api/configuration.py b/python_client/mozart_api/configuration.py index f9db52f..f31f5e0 100644 --- a/python_client/mozart_api/configuration.py +++ b/python_client/mozart_api/configuration.py @@ -380,7 +380,7 @@ def to_debug_report(self): "OS: {env}\n" "Python Version: {pyversion}\n" "Version of the API: 0.2.0\n" - "SDK Package Version: 4.1.1.116.2".format( + "SDK Package Version: 4.1.1.116.3".format( env=sys.platform, pyversion=sys.version ) ) diff --git a/python_client/mozart_api/mozart_client.py b/python_client/mozart_api/mozart_client.py index bc0f3bb..4e7184b 100644 --- a/python_client/mozart_api/mozart_client.py +++ b/python_client/mozart_api/mozart_client.py @@ -6,7 +6,7 @@ import logging import re from collections import defaultdict -from collections.abc import Callable +from collections.abc import Awaitable, Callable from contextlib import AbstractAsyncContextManager from dataclasses import dataclass from datetime import time @@ -261,11 +261,11 @@ def __init__(self, host: str, ssl_context: SSLContext | None = None) -> None: self._on_connection_lost: Callable | None = None self._on_connection: Callable | None = None - self._on_all_notifications: Callable[[WebSocketEventType, str], None] | None = ( - None - ) + self._on_all_notifications: ( + Callable[[WebSocketEventType, str], Awaitable[None] | None] | None + ) = None self._on_all_notifications_raw: ( - Callable[[BaseWebSocketResponse], None] | None + Callable[[BaseWebSocketResponse], Awaitable[None] | None] | None ) = None self._notification_callbacks: dict[str, Callable | None] = defaultdict() @@ -550,14 +550,18 @@ def get_on_connection(self, on_connection: Callable) -> None: def get_all_notifications( self, - on_all_notifications: Callable[[WebSocketEventType, str], None], + on_all_notifications: Callable[ + [WebSocketEventType, str], Awaitable[None] | None + ], ) -> None: """Set callback for all notifications.""" self._on_all_notifications = on_all_notifications def get_all_notifications_raw( self, - on_all_notifications_raw: Callable[[BaseWebSocketResponse], None], + on_all_notifications_raw: Callable[ + [BaseWebSocketResponse], Awaitable[None] | None + ], ) -> None: """Set callback for all notifications as dict.""" self._on_all_notifications_raw = on_all_notifications_raw @@ -565,7 +569,10 @@ def get_all_notifications_raw( # Generated section start def get_active_hdmi_input_signal_notifications( - self, on_active_hdmi_input_signal_notification: Callable[[HdmiInput], None] + self, + on_active_hdmi_input_signal_notification: Callable[ + [HdmiInput], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventActiveHdmiInputSignal notifications.""" self._notification_callbacks["WebSocketEventActiveHdmiInputSignal"] = ( @@ -574,7 +581,9 @@ def get_active_hdmi_input_signal_notifications( def get_active_listening_mode_notifications( self, - on_active_listening_mode_notification: Callable[[ListeningModeProps], None], + on_active_listening_mode_notification: Callable[ + [ListeningModeProps], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventActiveListeningMode notifications.""" self._notification_callbacks["WebSocketEventActiveListeningMode"] = ( @@ -583,7 +592,9 @@ def get_active_listening_mode_notifications( def get_active_speaker_group_notifications( self, - on_active_speaker_group_notification: Callable[[SpeakerGroupOverview], None], + on_active_speaker_group_notification: Callable[ + [SpeakerGroupOverview], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventActiveSpeakerGroup notifications.""" self._notification_callbacks["WebSocketEventActiveSpeakerGroup"] = ( @@ -591,7 +602,10 @@ def get_active_speaker_group_notifications( ) def get_alarm_timer_notifications( - self, on_alarm_timer_notification: Callable[[AlarmTimerEventData], None] + self, + on_alarm_timer_notification: Callable[ + [AlarmTimerEventData], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventAlarmTimer notifications.""" self._notification_callbacks["WebSocketEventAlarmTimer"] = ( @@ -599,7 +613,10 @@ def get_alarm_timer_notifications( ) def get_alarm_triggered_notifications( - self, on_alarm_triggered_notification: Callable[[AlarmTriggeredInfo], None] + self, + on_alarm_triggered_notification: Callable[ + [AlarmTriggeredInfo], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventAlarmTriggered notifications.""" self._notification_callbacks["WebSocketEventAlarmTriggered"] = ( @@ -607,13 +624,16 @@ def get_alarm_triggered_notifications( ) def get_battery_notifications( - self, on_battery_notification: Callable[[BatteryState], None] + self, on_battery_notification: Callable[[BatteryState], Awaitable[None] | None] ) -> None: """Set callback for WebSocketEventBattery notifications.""" self._notification_callbacks["WebSocketEventBattery"] = on_battery_notification def get_beo_remote_button_notifications( - self, on_beo_remote_button_notification: Callable[[BeoRemoteButton], None] + self, + on_beo_remote_button_notification: Callable[ + [BeoRemoteButton], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventBeoRemoteButton notifications.""" self._notification_callbacks["WebSocketEventBeoRemoteButton"] = ( @@ -623,7 +643,7 @@ def get_beo_remote_button_notifications( def get_beolink_experiences_result_notifications( self, on_beolink_experiences_result_notification: Callable[ - [BeolinkExperiencesResult], None + [BeolinkExperiencesResult], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventBeolinkExperiencesResult notifications.""" @@ -632,7 +652,10 @@ def get_beolink_experiences_result_notifications( ) def get_beolink_join_result_notifications( - self, on_beolink_join_result_notification: Callable[[BeolinkJoinResult], None] + self, + on_beolink_join_result_notification: Callable[ + [BeolinkJoinResult], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventBeolinkJoinResult notifications.""" self._notification_callbacks["WebSocketEventBeolinkJoinResult"] = ( @@ -640,13 +663,16 @@ def get_beolink_join_result_notifications( ) def get_button_notifications( - self, on_button_notification: Callable[[ButtonEvent], None] + self, on_button_notification: Callable[[ButtonEvent], Awaitable[None] | None] ) -> None: """Set callback for WebSocketEventButton notifications.""" self._notification_callbacks["WebSocketEventButton"] = on_button_notification def get_curtains_notifications( - self, on_curtains_notification: Callable[[ProductCurtainStatus], None] + self, + on_curtains_notification: Callable[ + [ProductCurtainStatus], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventCurtains notifications.""" self._notification_callbacks["WebSocketEventCurtains"] = ( @@ -655,7 +681,9 @@ def get_curtains_notifications( def get_hdmi_video_format_signal_notifications( self, - on_hdmi_video_format_signal_notification: Callable[[HdmiVideoFormat], None], + on_hdmi_video_format_signal_notification: Callable[ + [HdmiVideoFormat], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventHdmiVideoFormatSignal notifications.""" self._notification_callbacks["WebSocketEventHdmiVideoFormatSignal"] = ( @@ -663,7 +691,10 @@ def get_hdmi_video_format_signal_notifications( ) def get_notification_notifications( - self, on_notification_notification: Callable[[WebsocketNotificationTag], None] + self, + on_notification_notification: Callable[ + [WebsocketNotificationTag], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventNotification notifications.""" self._notification_callbacks["WebSocketEventNotification"] = ( @@ -671,7 +702,10 @@ def get_notification_notifications( ) def get_playback_error_notifications( - self, on_playback_error_notification: Callable[[PlaybackError], None] + self, + on_playback_error_notification: Callable[ + [PlaybackError], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventPlaybackError notifications.""" self._notification_callbacks["WebSocketEventPlaybackError"] = ( @@ -680,7 +714,9 @@ def get_playback_error_notifications( def get_playback_metadata_notifications( self, - on_playback_metadata_notification: Callable[[PlaybackContentMetadata], None], + on_playback_metadata_notification: Callable[ + [PlaybackContentMetadata], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventPlaybackMetadata notifications.""" self._notification_callbacks["WebSocketEventPlaybackMetadata"] = ( @@ -688,7 +724,10 @@ def get_playback_metadata_notifications( ) def get_playback_progress_notifications( - self, on_playback_progress_notification: Callable[[PlaybackProgress], None] + self, + on_playback_progress_notification: Callable[ + [PlaybackProgress], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventPlaybackProgress notifications.""" self._notification_callbacks["WebSocketEventPlaybackProgress"] = ( @@ -696,7 +735,8 @@ def get_playback_progress_notifications( ) def get_playback_source_notifications( - self, on_playback_source_notification: Callable[[Source], None] + self, + on_playback_source_notification: Callable[[Source], Awaitable[None] | None], ) -> None: """Set callback for WebSocketEventPlaybackSource notifications.""" self._notification_callbacks["WebSocketEventPlaybackSource"] = ( @@ -704,7 +744,10 @@ def get_playback_source_notifications( ) def get_playback_state_notifications( - self, on_playback_state_notification: Callable[[RenderingState], None] + self, + on_playback_state_notification: Callable[ + [RenderingState], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventPlaybackState notifications.""" self._notification_callbacks["WebSocketEventPlaybackState"] = ( @@ -712,7 +755,8 @@ def get_playback_state_notifications( ) def get_power_state_notifications( - self, on_power_state_notification: Callable[[PowerStateEnum], None] + self, + on_power_state_notification: Callable[[PowerStateEnum], Awaitable[None] | None], ) -> None: """Set callback for WebSocketEventPowerState notifications.""" self._notification_callbacks["WebSocketEventPowerState"] = ( @@ -722,7 +766,7 @@ def get_power_state_notifications( def get_powerlink_connection_state_notifications( self, on_powerlink_connection_state_notification: Callable[ - [PowerlinkConnectionStateEnum], None + [PowerlinkConnectionStateEnum], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventPowerlinkConnectionState notifications.""" @@ -733,7 +777,7 @@ def get_powerlink_connection_state_notifications( def get_puc_install_remote_id_status_notifications( self, on_puc_install_remote_id_status_notification: Callable[ - [InstallRecordIdState], None + [InstallRecordIdState], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventPucInstallRemoteIdStatus notifications.""" @@ -742,7 +786,7 @@ def get_puc_install_remote_id_status_notifications( ) def get_role_notifications( - self, on_role_notification: Callable[[SpeakerRoleEnum], None] + self, on_role_notification: Callable[[SpeakerRoleEnum], Awaitable[None] | None] ) -> None: """Set callback for WebSocketEventRole notifications.""" self._notification_callbacks["WebSocketEventRole"] = on_role_notification @@ -750,7 +794,7 @@ def get_role_notifications( def get_room_compensation_current_measurement_event_notifications( self, on_room_compensation_current_measurement_event_notification: Callable[ - [RoomCompensationCurrentMeasurement], None + [RoomCompensationCurrentMeasurement], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventRoomCompensationCurrentMeasurementEvent notifications.""" @@ -761,7 +805,7 @@ def get_room_compensation_current_measurement_event_notifications( def get_room_compensation_state_notifications( self, on_room_compensation_state_notification: Callable[ - [RoomCompensationStateValue], None + [RoomCompensationStateValue], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventRoomCompensationState notifications.""" @@ -771,7 +815,9 @@ def get_room_compensation_state_notifications( def get_software_update_state_notifications( self, - on_software_update_state_notification: Callable[[SoftwareUpdateState], None], + on_software_update_state_notification: Callable[ + [SoftwareUpdateState], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventSoftwareUpdateState notifications.""" self._notification_callbacks["WebSocketEventSoftwareUpdateState"] = ( @@ -779,7 +825,10 @@ def get_software_update_state_notifications( ) def get_sound_settings_notifications( - self, on_sound_settings_notification: Callable[[SoundSettings], None] + self, + on_sound_settings_notification: Callable[ + [SoundSettings], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventSoundSettings notifications.""" self._notification_callbacks["WebSocketEventSoundSettings"] = ( @@ -787,7 +836,7 @@ def get_sound_settings_notifications( ) def get_source_change_notifications( - self, on_source_change_notification: Callable[[Source], None] + self, on_source_change_notification: Callable[[Source], Awaitable[None] | None] ) -> None: """Set callback for WebSocketEventSourceChange notifications.""" self._notification_callbacks["WebSocketEventSourceChange"] = ( @@ -795,7 +844,8 @@ def get_source_change_notifications( ) def get_speaker_group_changed_notifications( - self, on_speaker_group_changed_notification: Callable[[str], None] + self, + on_speaker_group_changed_notification: Callable[[str], Awaitable[None] | None], ) -> None: """Set callback for WebSocketEventSpeakerGroupChanged notifications.""" self._notification_callbacks["WebSocketEventSpeakerGroupChanged"] = ( @@ -805,7 +855,7 @@ def get_speaker_group_changed_notifications( def get_speaker_link_status_changed_notifications( self, on_speaker_link_status_changed_notification: Callable[ - [SpeakerLinkStatus], None + [SpeakerLinkStatus], Awaitable[None] | None ], ) -> None: """Set callback for WebSocketEventSpeakerLinkStatusChanged notifications.""" @@ -814,7 +864,10 @@ def get_speaker_link_status_changed_notifications( ) def get_stand_connected_notifications( - self, on_stand_connected_notification: Callable[[StandConnected], None] + self, + on_stand_connected_notification: Callable[ + [StandConnected], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventStandConnected notifications.""" self._notification_callbacks["WebSocketEventStandConnected"] = ( @@ -822,7 +875,10 @@ def get_stand_connected_notifications( ) def get_stand_position_notifications( - self, on_stand_position_notification: Callable[[StandPosition], None] + self, + on_stand_position_notification: Callable[ + [StandPosition], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventStandPosition notifications.""" self._notification_callbacks["WebSocketEventStandPosition"] = ( @@ -830,19 +886,23 @@ def get_stand_position_notifications( ) def get_tv_info_notifications( - self, on_tv_info_notification: Callable[[TvInfoEventData], None] + self, + on_tv_info_notification: Callable[[TvInfoEventData], Awaitable[None] | None], ) -> None: """Set callback for WebSocketEventTvInfo notifications.""" self._notification_callbacks["WebSocketEventTvInfo"] = on_tv_info_notification def get_volume_notifications( - self, on_volume_notification: Callable[[VolumeState], None] + self, on_volume_notification: Callable[[VolumeState], Awaitable[None] | None] ) -> None: """Set callback for WebSocketEventVolume notifications.""" self._notification_callbacks["WebSocketEventVolume"] = on_volume_notification def get_wisa_out_state_notifications( - self, on_wisa_out_state_notification: Callable[[WisaOutState], None] + self, + on_wisa_out_state_notification: Callable[ + [WisaOutState], Awaitable[None] | None + ], ) -> None: """Set callback for WebSocketEventWisaOutState notifications.""" self._notification_callbacks["WebSocketEventWisaOutState"] = ( diff --git a/python_client/pyproject.toml b/python_client/pyproject.toml index dcee2eb..9e7ff74 100644 --- a/python_client/pyproject.toml +++ b/python_client/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mozart_api" -version = "4.1.1.116.2" +version = "4.1.1.116.3" description = "Mozart platform API" authors = [ "BangOlufsen ",