Skip to content

Refactor unifi_client.py to use Abstract Base Classes#70

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/rewrite-unifi-client-api
Draft

Refactor unifi_client.py to use Abstract Base Classes#70
Copilot wants to merge 3 commits into
mainfrom
copilot/rewrite-unifi-client-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 20, 2025

Restructures unifi_client.py from standalone functions to an ABC-based architecture for better extensibility and type safety.

Changes

  • UniFiClientBase abstract class: Defines interface with abstract methods get_infos() and scrape()
  • UniFiClient concrete implementation: Encapsulates controller configuration and implements data retrieval logic
  • Backward compatibility: Original get_infos() and scrape() functions preserved as wrappers

Usage

# New API - explicit configuration passing
from unifi_respondd.unifi_client import UniFiClient
from unifi_respondd import config

cfg = config.Config.from_dict(config.load_config())
client = UniFiClient(cfg)
aps = client.get_infos()

# Legacy API - still works unchanged
from unifi_respondd import unifi_client
aps = unifi_client.get_infos()

Enables subclassing for testing, mocking, or alternative controller implementations while maintaining existing integration points.

Original prompt

This section details on the original issue you should resolve

<issue_title>Rewrite unifi_client.py to inherit ABCs new API</issue_title>
<issue_description>This ticket to track the work of re-writing unifi_respondd/unifi_client.py to inherit the new ABC API. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 20, 2025 11:33
Co-authored-by: GoliathLabs <8057646+GoliathLabs@users.noreply.github.com>
Co-authored-by: GoliathLabs <8057646+GoliathLabs@users.noreply.github.com>
Copilot AI changed the title [WIP] Rewrite unifi_client.py to inherit ABC's new API Refactor unifi_client.py to use Abstract Base Classes Dec 20, 2025
Copilot AI requested a review from GoliathLabs December 20, 2025 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite unifi_client.py to inherit ABCs new API

2 participants