|
7 | 7 | import sys |
8 | 8 | import termios |
9 | 9 | import tty |
10 | | -from typing import Any, Callable, Optional |
| 10 | +from typing import Any |
11 | 11 |
|
12 | 12 | from ..communicator.data_channel import SessionDataChannel |
13 | 13 | from ..communicator.utils import create_websocket_config |
14 | 14 | from ..constants import CLIENT_VERSION |
15 | | -from ..file_transfer.client import FileTransferClient |
16 | | -from ..file_transfer.types import ( |
17 | | - ChecksumType, |
18 | | - FileTransferOptions, |
19 | | -) |
20 | 15 | from ..session.plugins import StandardStreamPlugin |
21 | 16 | from ..session.session_handler import SessionHandler |
22 | 17 | from ..session.types import ClientConfig, SessionConfig, SessionType |
@@ -479,132 +474,3 @@ async def _stop_resize_heartbeat(self) -> None: |
479 | 474 | except asyncio.CancelledError: |
480 | 475 | pass |
481 | 476 | self._resize_task = None |
482 | | - |
483 | | - async def upload_file( |
484 | | - self, |
485 | | - local_path: str, |
486 | | - remote_path: str, |
487 | | - target: str, |
488 | | - progress_callback: Optional[Callable[[int, int], None]] = None, |
489 | | - verify_checksum: bool = True, |
490 | | - chunk_size: int = 65536, |
491 | | - # AWS parameters |
492 | | - profile: Optional[str] = None, |
493 | | - region: Optional[str] = None, |
494 | | - endpoint_url: Optional[str] = None, |
495 | | - ) -> bool: |
496 | | - """Upload a file to remote host via AWS SSM. |
497 | | -
|
498 | | - Args: |
499 | | - local_path: Path to local file |
500 | | - remote_path: Destination path on remote host |
501 | | - target: EC2 instance or managed instance ID |
502 | | - progress_callback: Optional callback for progress updates |
503 | | - verify_checksum: Whether to verify file integrity |
504 | | - chunk_size: Transfer chunk size in bytes |
505 | | - profile: AWS profile name |
506 | | - region: AWS region |
507 | | - endpoint_url: Custom AWS endpoint URL |
508 | | -
|
509 | | - Returns: |
510 | | - True if transfer successful, False otherwise |
511 | | - """ |
512 | | - options = FileTransferOptions( |
513 | | - chunk_size=chunk_size, |
514 | | - verify_checksum=verify_checksum, |
515 | | - progress_callback=progress_callback, |
516 | | - ) |
517 | | - |
518 | | - client = FileTransferClient() |
519 | | - return await client.upload_file( |
520 | | - local_path=local_path, |
521 | | - remote_path=remote_path, |
522 | | - target=target, |
523 | | - options=options, |
524 | | - profile=profile, |
525 | | - region=region, |
526 | | - endpoint_url=endpoint_url, |
527 | | - ) |
528 | | - |
529 | | - async def download_file( |
530 | | - self, |
531 | | - remote_path: str, |
532 | | - local_path: str, |
533 | | - target: str, |
534 | | - progress_callback: Optional[Callable[[int, int], None]] = None, |
535 | | - verify_checksum: bool = True, |
536 | | - chunk_size: int = 65536, |
537 | | - # AWS parameters |
538 | | - profile: Optional[str] = None, |
539 | | - region: Optional[str] = None, |
540 | | - endpoint_url: Optional[str] = None, |
541 | | - ) -> bool: |
542 | | - """Download a file from remote host via AWS SSM. |
543 | | -
|
544 | | - Args: |
545 | | - remote_path: Path to remote file |
546 | | - local_path: Local destination path |
547 | | - target: EC2 instance or managed instance ID |
548 | | - progress_callback: Optional callback for progress updates |
549 | | - verify_checksum: Whether to verify file integrity |
550 | | - chunk_size: Transfer chunk size in bytes |
551 | | - profile: AWS profile name |
552 | | - region: AWS region |
553 | | - endpoint_url: Custom AWS endpoint URL |
554 | | -
|
555 | | - Returns: |
556 | | - True if transfer successful, False otherwise |
557 | | - """ |
558 | | - options = FileTransferOptions( |
559 | | - chunk_size=chunk_size, |
560 | | - verify_checksum=verify_checksum, |
561 | | - progress_callback=progress_callback, |
562 | | - ) |
563 | | - |
564 | | - client = FileTransferClient() |
565 | | - return await client.download_file( |
566 | | - remote_path=remote_path, |
567 | | - local_path=local_path, |
568 | | - target=target, |
569 | | - options=options, |
570 | | - profile=profile, |
571 | | - region=region, |
572 | | - endpoint_url=endpoint_url, |
573 | | - ) |
574 | | - |
575 | | - async def verify_remote_file( |
576 | | - self, |
577 | | - remote_path: str, |
578 | | - target: str, |
579 | | - checksum_type: str = "md5", |
580 | | - # AWS parameters |
581 | | - profile: Optional[str] = None, |
582 | | - region: Optional[str] = None, |
583 | | - endpoint_url: Optional[str] = None, |
584 | | - ) -> Optional[str]: |
585 | | - """Get checksum of remote file. |
586 | | -
|
587 | | - Args: |
588 | | - remote_path: Path to remote file |
589 | | - target: EC2 instance or managed instance ID |
590 | | - checksum_type: Checksum algorithm (md5 or sha256) |
591 | | - profile: AWS profile name |
592 | | - region: AWS region |
593 | | - endpoint_url: Custom AWS endpoint URL |
594 | | -
|
595 | | - Returns: |
596 | | - Checksum string if successful, None otherwise |
597 | | - """ |
598 | | - checksum_enum = ( |
599 | | - ChecksumType.MD5 if checksum_type.lower() == "md5" else ChecksumType.SHA256 |
600 | | - ) |
601 | | - |
602 | | - client = FileTransferClient() |
603 | | - return await client.verify_remote_file( |
604 | | - remote_path=remote_path, |
605 | | - target=target, |
606 | | - checksum_type=checksum_enum, |
607 | | - profile=profile, |
608 | | - region=region, |
609 | | - endpoint_url=endpoint_url, |
610 | | - ) |
0 commit comments