Skip to content

Add get_transfer() and cancel_transfer() for file transfer monitoring#160

Merged
agners merged 1 commit into
home-assistant-libs:mainfrom
heikkih:feat/transfer-endpoint
May 7, 2026
Merged

Add get_transfer() and cancel_transfer() for file transfer monitoring#160
agners merged 1 commit into
home-assistant-libs:mainfrom
heikkih:feat/transfer-endpoint

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented Apr 27, 2026

Summary

Adds two methods wrapping the /api/v1/transfer endpoint:

  • get_transfer() -> Transfer | None — returns the active transfer, or None on 204 (no transfer in progress)
  • cancel_transfer(transfer_id: int) -> None — stops an active transfer via DELETE /api/v1/transfer/{id}

The Transfer TypedDict covers all fields from the OpenAPI spec. All fields are optional (total=False) since availability varies by transfer state and direction. The id field is not in the spec schema but is included as it is needed to call cancel_transfer().

Test plan

  • test_get_transfer — verifies fields from a 200 response
  • test_get_transfer_none — verifies None is returned on 204
  • test_cancel_transfer — verifies correct URL is called

🤖 Generated with Claude Code

@heikkih heikkih force-pushed the feat/transfer-endpoint branch from f96f89f to ab295ba Compare April 28, 2026 11:47
Comment thread pyprusalink/types.py
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented May 6, 2026

Pushed c37af23total=False removed, NotRequired applied per the OpenAPI spec's required list:

Required: type, display_name, path, progress, transferred, time_transferring, to_print
NotRequired: id (printer-returned but not in spec), url (only for FROM_WEB), size, time_remaining

@heikkih heikkih force-pushed the feat/transfer-endpoint branch from c37af23 to 4af5699 Compare May 6, 2026 17:38
Copy link
Copy Markdown
Contributor

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs rebasing/merge now.

Comment thread pyprusalink/types.py Outdated
Comment thread tests/test_prusalink.py Outdated
Exposes GET /api/v1/transfer as get_transfer() -> Transfer | None,
returning None on 204 (no active transfer). Also exposes
DELETE /api/v1/transfer/{id} as cancel_transfer(transfer_id).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@heikkih heikkih force-pushed the feat/transfer-endpoint branch from 4af5699 to 7c42fb0 Compare May 7, 2026 10:30
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented May 7, 2026

Pushed 7c42fb0:

Copy link
Copy Markdown
Contributor

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@agners agners merged commit 32650af into home-assistant-libs:main May 7, 2026
2 checks passed
@heikkih heikkih deleted the feat/transfer-endpoint branch May 13, 2026 10:48
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.

2 participants