feat: add Invoke-PiHoleFlushLogs - #109
Merged
Merged
Conversation
Implements POST /action/flush/logs, one of the two remaining "Actions" gaps
from the API coverage audit. Flushes the DNS log file and purges the most
recent 24 hours of query history from both the database and FTL's internal
memory.
The other gap, POST /action/flush/arp, is deprecated by Pi-hole itself in
favor of /action/flush/network ("Deprecated! Use '/action/flush/network'
instead."), which the module already implements via
Invoke-PiHoleFlushNetwork - so it's intentionally not being added as a
separate function.
Also fixed a copy-paste bug found along the way: Invoke-PiHoleFlushNetwork's
.DESCRIPTION described flushing a log file, which is what this new function
actually does, not what flushing the network table does.
Verified against a real Pi-hole v6 server: formatted output, RawOutput, and
bad-password error handling. Added a dedicated integration test file.
README regenerated.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Merges the latest develop (which reorganized tests/ to mirror PiHoleShell/Public/<Category>/) into this branch, then moves this PR's own new test file - added before that reorg landed - into tests/Actions/ to match, fixing its $PSScriptRoot-relative IntegrationConfig.local.ps1 lookup accordingly. Verified against the real Pi-hole server post-move. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
POST /action/flush/logs, one of the two remaining "Actions" gaps from the API coverage audit. Flushes the DNS log file and purges the most recent 24 hours of query history from both the database and FTL's internal memory.The other gap,
POST /action/flush/arp, is deprecated by Pi-hole itself in favor of/action/flush/network(per the live API spec: "Deprecated! Use '/action/flush/network' instead."), which the module already implements viaInvoke-PiHoleFlushNetwork- so it's intentionally not being added as a separate function. That leaves "Actions" fully covered.Also fixed a copy-paste bug found along the way:
Invoke-PiHoleFlushNetwork's.DESCRIPTIONdescribed flushing a log file, which is what this new function actually does, not what flushing the network table does.Test plan
Invoke-ScriptAnalyzer -Path .\PiHoleShell -Recurse- clean-RawOutput, and bad-password error handlingREADME.md🤖 Generated with Claude Code