Fix channel nomenclature
This commit is contained in:
@@ -35,7 +35,7 @@ class RadioAPIClient:
|
||||
|
||||
Args:
|
||||
method (str): The HTTP method (e.g., 'GET', 'POST').
|
||||
endpoint (str): The API endpoint path (e.g., '/channels').
|
||||
endpoint (str): The API endpoint path (e.g., '/systems').
|
||||
**kwargs: Additional arguments for httpx.AsyncClient.request.
|
||||
|
||||
Returns:
|
||||
@@ -58,31 +58,31 @@ class RadioAPIClient:
|
||||
print(f"An error occurred while requesting {e.request.url!r}: {e}")
|
||||
raise
|
||||
|
||||
async def get_channels(self):
|
||||
async def get_systems(self):
|
||||
"""
|
||||
Retrieves a summary list of all available radio channels.
|
||||
Retrieves a summary list of all available radio systems.
|
||||
|
||||
Returns:
|
||||
list: A list of channel summaries (e.g., [{"id": "channel_1", "name": "..."}]).
|
||||
list: A list of system summaries (e.g., [{"id": "system_1", "name": "..."}]).
|
||||
"""
|
||||
print(f"Fetching channels from {self.base_url}/channels")
|
||||
return await self._request("GET", "/channels")
|
||||
print(f"Fetching systems from {self.base_url}/systems")
|
||||
return await self._request("GET", "/systems")
|
||||
|
||||
async def get_channel_details(self, channel_id: str):
|
||||
async def get_system_details(self, system_id: str):
|
||||
"""
|
||||
Retrieves detailed information for a specific channel.
|
||||
Retrieves detailed information for a specific system.
|
||||
|
||||
Args:
|
||||
channel_id (str): The unique ID of the channel.
|
||||
system_id (str): The unique ID of the system.
|
||||
|
||||
Returns:
|
||||
dict: The channel details.
|
||||
dict: The system details.
|
||||
|
||||
Raises:
|
||||
httpx.HTTPStatusError: If the channel is not found (404).
|
||||
httpx.HTTPStatusError: If the system is not found (404).
|
||||
"""
|
||||
print(f"Fetching details for channel: {channel_id} from {self.base_url}/channels/{channel_id}")
|
||||
return await self._request("GET", f"/channels/{channel_id}")
|
||||
print(f"Fetching details for system: {system_id} from {self.base_url}/systems/{system_id}")
|
||||
return await self._request("GET", f"/systems/{system_id}")
|
||||
|
||||
async def list_clients(self):
|
||||
"""
|
||||
@@ -132,26 +132,26 @@ async def example_api_usage():
|
||||
async with RadioAPIClient("http://localhost:5000") as api_client:
|
||||
print("\n--- Getting Channels ---")
|
||||
try:
|
||||
channels_summary = await api_client.get_channels()
|
||||
print("Channels Summary:", channels_summary)
|
||||
systems_summary = await api_client.get_systems()
|
||||
print("Channels Summary:", systems_summary)
|
||||
except Exception as e:
|
||||
print(f"Error getting channels: {e}")
|
||||
print(f"Error getting systems: {e}")
|
||||
|
||||
print("\n--- Getting Channel Details (channel_1) ---")
|
||||
print("\n--- Getting Channel Details (system_1) ---")
|
||||
try:
|
||||
channel_details = await api_client.get_channel_details("channel_1")
|
||||
print("Channel 1 Details:", channel_details)
|
||||
system_details = await api_client.get_system_details("system_1")
|
||||
print("Channel 1 Details:", system_details)
|
||||
except Exception as e:
|
||||
print(f"Error getting channel details: {e}")
|
||||
print(f"Error getting system details: {e}")
|
||||
|
||||
print("\n--- Getting Channel Details (non-existent) ---")
|
||||
try:
|
||||
non_existent_channel = await api_client.get_channel_details("non_existent_channel")
|
||||
print("Non-existent Channel Details:", non_existent_channel) # This should not print
|
||||
non_existent_system = await api_client.get_system_details("non_existent_system")
|
||||
print("Non-existent Channel Details:", non_existent_system) # This should not print
|
||||
except httpx.HTTPStatusError as e:
|
||||
print(f"Caught expected error for non-existent channel: {e.response.status_code} - {e.response.json()}")
|
||||
print(f"Caught expected error for non-existent system: {e.response.status_code} - {e.response.json()}")
|
||||
except Exception as e:
|
||||
print(f"Error getting non-existent channel details: {e}")
|
||||
print(f"Error getting non-existent system details: {e}")
|
||||
|
||||
|
||||
print("\n--- Listing Connected Clients ---")
|
||||
|
||||
Reference in New Issue
Block a user