Skip to content

feat: add Import-PiHoleTeleporter, completing API coverage - #138

Merged
mikemadeja merged 1 commit into
developfrom
feature/teleporter-import
Oct 7, 2026
Merged

mikemadeja merged 1 commit into
developfrom
feature/teleporter-import

Conversation

@mikemadeja

Copy link
Copy Markdown
Owner

Summary

  • Adds Import-PiHoleTeleporter (POST /teleporter) - the last remaining functional gap in the Pi-hole v6 API, aside from two low-value API self-discovery endpoints (GET /endpoints, GET /docs) already agreed to be out of scope
  • Restores a Teleporter archive (as produced by Get-PiHoleTeleporterDownload) with flat switch parameters (-Config, -DhcpLeases, -Group, -Adlist, -AdlistByGroup, -Domainlist, -DomainlistByGroup, -Client, -ClientByGroup) choosing what to restore, instead of mirroring Pi-hole's own nested request shape. Omitting every switch imports everything, matching the API's own default
  • This overwrites the current configuration, so unlike every other function in the module it prompts for confirmation by default (ConfirmImpact = 'High') rather than only when -Confirm is passed explicitly - pass -Confirm:$false to skip the prompt, or -WhatIf for a true dry run (no request is ever sent)

Two things confirmed by hand against a real server that don't match the docs

  • The response's processed-items array is actually returned under files, not processed as the OpenAPI spec documents - the function reads the real field
  • Pi-hole reloads internally right after any import and briefly refuses connections for a few seconds afterward - both the integration tests and the docs example script settle with a short delay to avoid a flaky next call

Test plan

  • Integration tests pass against a live server (5/5): real selective import (restoring the server's own just-exported backup - a no-op, safe to run repeatedly), -WhatIf performs no request, nonexistent file errors, non-ZIP file content errors (real 400 from the API), bad password errors
  • Manually confirmed -WhatIf sends zero requests and a non-interactive call without -Confirm:$false correctly refuses to proceed rather than silently running
  • Manually confirmed generating/restoring does not leave the module or server in a broken state - the transient post-import unavailability clears within a few seconds
  • PSScriptAnalyzer clean
  • Full non-integration unit suite passes (12/12)
  • README.md / docs/EXAMPLES.md regenerated

🤖 Generated with Claude Code

Adds Import-PiHoleTeleporter (POST /teleporter), the last remaining
functional gap in the Pi-hole v6 API. Restores a Teleporter archive
(as produced by Get-PiHoleTeleporterDownload), with flat switch
parameters (-Config, -DhcpLeases, -Group, -Adlist, -AdlistByGroup,
-Domainlist, -DomainlistByGroup, -Client, -ClientByGroup) selecting
which items to restore instead of Pi-hole's own nested request shape.
Omitting every switch imports everything, matching the API's own
default.

This overwrites the current configuration, so unlike every other
function in the module it prompts for confirmation by default
(ConfirmImpact = 'High') rather than only when -Confirm is passed
explicitly - pass -Confirm:$false to skip the prompt, or -WhatIf for
a dry run.

Confirmed two things by hand against a real server that don't match
the OpenAPI spec or weren't otherwise obvious:
- The response's processed-items array is actually returned under
  "files", not "processed" as the spec documents.
- Pi-hole reloads internally right after any import, briefly refusing
  connections - the integration tests and the docs example script
  both settle afterward to avoid a flaky next call.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mikemadeja
mikemadeja merged commit 784de80 into develop Oct 7, 2026
3 checks passed
@mikemadeja mikemadeja mentioned this pull request Oct 7, 2026
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.

1 participant