1010from typing import Any , cast
1111
1212import backoff
13- import humps
1413from aiohttp import (
1514 ClientConnectorError ,
1615 ClientSession ,
1716 ServerDisconnectedError ,
1817)
1918from backoff .types import Details
2019
20+ from pyoverkiz ._case import decamelize
2121from pyoverkiz .action_queue import ActionQueue , ActionQueueSettings
2222from pyoverkiz .auth import AuthStrategy , Credentials , build_auth_strategy
2323from pyoverkiz .const import SUPPORTED_SERVERS
@@ -304,7 +304,7 @@ async def get_setup(self, refresh: bool = False) -> Setup:
304304
305305 response = await self ._get ("setup" )
306306
307- setup = Setup (** humps . decamelize (response ))
307+ setup = Setup (** decamelize (response ))
308308
309309 # Cache response
310310 self .setup = setup
@@ -342,7 +342,7 @@ async def get_devices(self, refresh: bool = False) -> list[Device]:
342342 return self .devices
343343
344344 response = await self ._get ("setup/devices" )
345- devices = [Device (** d ) for d in humps . decamelize (response )]
345+ devices = [Device (** d ) for d in decamelize (response )]
346346
347347 # Cache response
348348 self .devices = devices
@@ -361,7 +361,7 @@ async def get_gateways(self, refresh: bool = False) -> list[Gateway]:
361361 return self .gateways
362362
363363 response = await self ._get ("setup/gateways" )
364- gateways = [Gateway (** g ) for g in humps . decamelize (response )]
364+ gateways = [Gateway (** g ) for g in decamelize (response )]
365365
366366 # Cache response
367367 self .gateways = gateways
@@ -374,7 +374,7 @@ async def get_gateways(self, refresh: bool = False) -> list[Gateway]:
374374 async def get_execution_history (self ) -> list [HistoryExecution ]:
375375 """List execution history."""
376376 response = await self ._get ("history/executions" )
377- return [HistoryExecution (** h ) for h in humps . decamelize (response )]
377+ return [HistoryExecution (** h ) for h in decamelize (response )]
378378
379379 @retry_on_auth_error
380380 async def get_device_definition (self , deviceurl : str ) -> JSON | None :
@@ -391,7 +391,7 @@ async def get_state(self, deviceurl: str) -> list[State]:
391391 response = await self ._get (
392392 f"setup/devices/{ urllib .parse .quote_plus (deviceurl )} /states"
393393 )
394- return [State (** s ) for s in humps . decamelize (response )]
394+ return [State (** s ) for s in decamelize (response )]
395395
396396 @retry_on_auth_error
397397 async def refresh_states (self ) -> None :
@@ -435,7 +435,7 @@ async def fetch_events(self) -> list[Event]:
435435 """
436436 await self ._refresh_token_if_expired ()
437437 response = await self ._post (f"events/{ self .event_listener_id } /fetch" )
438- return [Event (** e ) for e in humps . decamelize (response )]
438+ return [Event (** e ) for e in decamelize (response )]
439439
440440 async def unregister_event_listener (self ) -> None :
441441 """Unregister an event listener.
@@ -450,13 +450,13 @@ async def unregister_event_listener(self) -> None:
450450 async def get_current_execution (self , exec_id : str ) -> Execution :
451451 """Get an action group execution currently running."""
452452 response = await self ._get (f"exec/current/{ exec_id } " )
453- return Execution (** humps . decamelize (response ))
453+ return Execution (** decamelize (response ))
454454
455455 @retry_on_auth_error
456456 async def get_current_executions (self ) -> list [Execution ]:
457457 """Get all action groups executions currently running."""
458458 response = await self ._get ("exec/current" )
459- return [Execution (** e ) for e in humps . decamelize (response )]
459+ return [Execution (** e ) for e in decamelize (response )]
460460
461461 @retry_on_auth_error
462462 async def get_api_version (self ) -> str :
@@ -567,9 +567,7 @@ async def cancel_command(self, exec_id: str) -> None:
567567 async def get_action_groups (self ) -> list [ActionGroup ]:
568568 """List the action groups (scenarios)."""
569569 response = await self ._get ("actionGroups" )
570- return [
571- ActionGroup (** action_group ) for action_group in humps .decamelize (response )
572- ]
570+ return [ActionGroup (** action_group ) for action_group in decamelize (response )]
573571
574572 @retry_on_auth_error
575573 async def get_places (self ) -> Place :
@@ -584,7 +582,7 @@ async def get_places(self) -> Place:
584582 - `sub_places`: List of nested places within this location
585583 """
586584 response = await self ._get ("setup/places" )
587- return Place (** humps . decamelize (response ))
585+ return Place (** decamelize (response ))
588586
589587 @retry_on_auth_error
590588 async def execute_scenario (self , oid : str ) -> str :
@@ -606,7 +604,7 @@ async def get_setup_options(self) -> list[Option]:
606604 Access scope : Full enduser API access (enduser/*).
607605 """
608606 response = await self ._get ("setup/options" )
609- return [Option (** o ) for o in humps . decamelize (response )]
607+ return [Option (** o ) for o in decamelize (response )]
610608
611609 @retry_on_auth_error
612610 async def get_setup_option (self , option : str ) -> Option | None :
@@ -617,7 +615,7 @@ async def get_setup_option(self, option: str) -> Option | None:
617615 response = await self ._get (f"setup/options/{ option } " )
618616
619617 if response :
620- return Option (** humps . decamelize (response ))
618+ return Option (** decamelize (response ))
621619
622620 return None
623621
@@ -635,7 +633,7 @@ async def get_setup_option_parameter(
635633 response = await self ._get (f"setup/options/{ option } /{ parameter } " )
636634
637635 if response :
638- return OptionParameter (** humps . decamelize (response ))
636+ return OptionParameter (** decamelize (response ))
639637
640638 return None
641639
@@ -697,7 +695,7 @@ async def get_reference_ui_profile(self, profile_name: str) -> UIProfileDefiniti
697695 response = await self ._get (
698696 f"reference/ui/profile/{ urllib .parse .quote_plus (profile_name )} "
699697 )
700- return UIProfileDefinition (** humps . decamelize (response ))
698+ return UIProfileDefinition (** decamelize (response ))
701699
702700 @retry_on_auth_error
703701 async def get_reference_ui_profile_names (self ) -> list [str ]:
0 commit comments