Skip to content

Read and replace a network as raw JSON - #24

Merged
ChrisonSimtian merged 4 commits into
mainfrom
feat/network-raw-json
Oct 23, 2026
Merged

ChrisonSimtian merged 4 commits into
mainfrom
feat/network-raw-json

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Lets a caller change one network setting without dropping the rest: UnifiNetwork models about 12 of a live network's 63 fields, so a typed update would reset the others.

What changed

  • ListNetworksRawAsync, GetNetworkRawAsync (exactly one row or throw), ReplaceNetworkRawAsync (body sent verbatim), all over JsonObject
  • NetworkDhcpDns.Read / With: With changes only dhcpd_dns_enabled and dhcpd_dns_1..4 and never mutates its input
  • No UpdateNetworkAsync(UnifiNetwork), on purpose
  • Internal handler seam on UnifiLegacySession so tests can assert the bytes sent; public API unchanged

Verification

dotnet test: 59 passed, 0 failed, 10 skipped (the existing live-test gate). Not run against a live controller; a read-only live test is included.

Closes #23
Spec: Chrison-Homelab/Homelab#736 (the Consumer DHCP DNS spec)

UnifiNetwork models about 12 of a live network's ~63 fields and
rest/networkconf/{id} is a full replacement, so a typed update would reset
the rest. Add ListNetworksRawAsync, GetNetworkRawAsync (exactly one row or
throw) and ReplaceNetworkRawAsync (body sent verbatim) over JsonObject, and
NetworkDhcpDns to read or change only dhcpd_dns_enabled and dhcpd_dns_1..4.
There is deliberately no UpdateNetworkAsync(UnifiNetwork).

UnifiLegacySession gains an internal handler seam so unit tests can assert
the bytes on the wire.
@ChrisonSimtian ChrisonSimtian added the enhancement New feature or request label Oct 23, 2026
Creates a scratch network, writes DHCP DNS through NetworkDhcpDns.With, asserts only the DNS keys moved, restores the saved object and asserts every key matches its JSON text, and checks no other network changed. Skips without UNIFI_LEGACY_BASE_URL + UNIFI_USERNAME + UNIFI_PASSWORD and refuses any host but localhost / 127.0.0.1 / ::1.
@ChrisonSimtian
ChrisonSimtian merged commit 01eebb4 into main Oct 23, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feat/network-raw-json branch October 23, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read and replace a network as raw JSON, so a caller can change one setting without dropping the rest

1 participant