e2b 2.60.0__tar.gz → 2.62.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {e2b-2.60.0 → e2b-2.62.0}/PKG-INFO +1 -1
- {e2b-2.60.0 → e2b-2.62.0}/e2b/__init__.py +9 -1
- {e2b-2.60.0 → e2b-2.62.0}/e2b/retry.py +19 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/command_handle.py +25 -5
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/filesystem/filesystem.py +228 -23
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command.py +170 -5
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command_handle.py +34 -17
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/filesystem/filesystem.py +33 -14
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/main.py +8 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/sandbox_api.py +4 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/command.py +150 -3
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/command_handle.py +25 -14
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/filesystem/filesystem.py +33 -14
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/main.py +8 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/sandbox_api.py +4 -0
- {e2b-2.60.0 → e2b-2.62.0}/pyproject.toml +2 -2
- {e2b-2.60.0 → e2b-2.62.0}/pyproject.toml.orig +2 -2
- {e2b-2.60.0 → e2b-2.62.0}/README.md +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_logs.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_v2_sandboxes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/get_v_2_sandboxes_sandbox_id_logs.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_fork.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_pause.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_resume.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_snapshots.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_v2_sandboxes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/post_v_2_sandboxes_sandbox_id_connect.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/sandboxes/put_sandboxes_sandbox_id_network.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/delete_secrets_secret_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/get_secrets.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/get_secrets_secret_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/post_secrets.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/secrets/post_secrets_secret_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/snapshots/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/snapshots/get_snapshots.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/delete_templates_tags.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_count.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_exists.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_groups.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/get_templates_template_id_tags_tag_assignments.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/tags/post_templates_tags.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/delete_templates_template_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_default_templates.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_aliases_alias.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_logs.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_templates_template_id_files_hash.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/get_v2_templates.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/patch_templates_template_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/patch_v_2_templates_template_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/post_v3_templates.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/templates/post_v_2_templates_template_id_builds_build_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/delete_volumes_volume_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/get_volumes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/get_volumes_volume_id.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/api/volumes/post_volumes.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/client.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/errors.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/assign_template_tags_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/assigned_template_tags.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/aws_registry.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/aws_registry_type.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/build_log_entry.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/build_status_reason.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/connect_sandbox.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/connect_sandbox_v2.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/delete_template_tags_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/error.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/gcp_registry.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/gcp_registry_type.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/general_registry.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/general_registry_type.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/get_templates_template_id_tags_groups_sort.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/listed_sandbox.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/log_level.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/logs_direction.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/logs_source.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/mcp_type_0.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_sandbox.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_sandbox_v2.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_secret.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/new_volume.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/order_direction.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/resumed_sandbox.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_auto_resume_config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_detail.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_egress_proxy_config_type_0.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_egress_proxy_tls_config_type_0.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_fork_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_fork_result.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam_token.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_iam_tokens.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_lifecycle.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log_entry.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_log_entry_fields.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_logs.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_logs_v2_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_metric.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_config_rules.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_rule.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_transform.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_transform_headers.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_update_config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_network_update_config_rules.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_on_timeout.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_pause_mode.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_pause_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_refresh_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_snapshot_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_state.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_timeout_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandbox_volume_mount.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/sandboxes_with_metrics.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret_metadata.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/secret_update.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/snapshot_info.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/team_user.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_alias_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_file_upload.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_file_upload_headers.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_info.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_logs_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_request_v3.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_start_v2.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_build_status.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_request_response_v3.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_step.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_assignment.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_assignments_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_exists_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_group.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tag_groups_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_tags_count_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_update_request.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_update_response.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/template_with_builds.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/volume.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/models/volume_and_token.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/py.typed +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client_async/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/client_sync/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/api/metadata.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/client.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/connection_config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/api.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_async/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_shared.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/client_sync/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/filesystem_connect.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/filesystem/filesystem_pb.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/interceptors.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/process_connect.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/process/process_pb.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/rpc.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/envd/versions.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/exceptions.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/io_utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/paginator.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/py.typed +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/args.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/auth.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/parse.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/_git/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/main.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/commands/stream_input.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/filesystem/watch_handle.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/iam.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/main.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/mcp.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/network.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/sandbox_api.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/signature.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox/utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/command_input_handle.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/commands/pty.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/filesystem/watch_handle.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/git.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/paginator.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_async/utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_domains.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/commands/pty.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/filesystem/watch_handle.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/git.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/sandbox_sync/paginator.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/base.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/secret_async.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/secret_sync.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/secret/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/consts.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/dockerfile_parser.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/logger.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/main.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/readycmd.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template/utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template_async/build_api.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template_async/main.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template_sync/build_api.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/template_sync/main.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/delete_volumecontent_volume_id_path.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_dir.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_file.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/get_volumecontent_volume_id_path.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/patch_volumecontent_volume_id_path.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/post_volumecontent_volume_id_dir.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/api/volumes/put_volumecontent_volume_id_file.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/client.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/errors.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/error.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/patch_volumecontent_volume_id_path_body.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/volume_entry_stat.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/models/volume_entry_stat_type.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/py.typed +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client_async/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/client_sync/__init__.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/connection_config.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/types.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/utils.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/volume_async.py +0 -0
- {e2b-2.60.0 → e2b-2.62.0}/e2b/volume/volume_sync.py +0 -0
|
@@ -70,7 +70,13 @@ from .sandbox.commands.command_handle import (
|
|
|
70
70
|
Stdout,
|
|
71
71
|
)
|
|
72
72
|
from .sandbox.commands.main import ProcessInfo
|
|
73
|
-
from .sandbox.filesystem.filesystem import
|
|
73
|
+
from .sandbox.filesystem.filesystem import (
|
|
74
|
+
AsyncWriteData,
|
|
75
|
+
EntryInfo,
|
|
76
|
+
FileType,
|
|
77
|
+
WriteData,
|
|
78
|
+
WriteInfo,
|
|
79
|
+
)
|
|
74
80
|
from .sandbox.filesystem.watch_handle import (
|
|
75
81
|
FilesystemEvent,
|
|
76
82
|
FilesystemEventType,
|
|
@@ -231,6 +237,8 @@ __all__ = [
|
|
|
231
237
|
"FilesystemEventType",
|
|
232
238
|
"EntryInfo",
|
|
233
239
|
"WriteInfo",
|
|
240
|
+
"WriteData",
|
|
241
|
+
"AsyncWriteData",
|
|
234
242
|
"FileType",
|
|
235
243
|
# Network
|
|
236
244
|
"SandboxEgressProxyOpts",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import random
|
|
5
|
+
import re
|
|
5
6
|
import time
|
|
6
7
|
from typing import Awaitable, Callable, Optional
|
|
7
8
|
|
|
@@ -25,6 +26,24 @@ def resolve_max_retries(retries: int) -> int:
|
|
|
25
26
|
return retries
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
def resolve_idempotency_key(key: Optional[str]) -> Optional[str]:
|
|
30
|
+
if key is None:
|
|
31
|
+
return None
|
|
32
|
+
if not isinstance(key, str):
|
|
33
|
+
raise InvalidArgumentException(
|
|
34
|
+
f"Invalid idempotency_key: expected a string, got {type(key).__name__}."
|
|
35
|
+
)
|
|
36
|
+
if len(key) < 1 or len(key) > 255:
|
|
37
|
+
raise InvalidArgumentException(
|
|
38
|
+
f"Invalid idempotency_key: expected 1-255 characters, got {len(key)}."
|
|
39
|
+
)
|
|
40
|
+
if re.fullmatch(r"[a-z0-9-]+", key) is None:
|
|
41
|
+
raise InvalidArgumentException(
|
|
42
|
+
"Invalid idempotency_key: only lowercase letters, digits and hyphens are allowed."
|
|
43
|
+
)
|
|
44
|
+
return key
|
|
45
|
+
|
|
46
|
+
|
|
28
47
|
def parse_retry_after(value: Optional[str]) -> Optional[int]:
|
|
29
48
|
if not value:
|
|
30
49
|
return None
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Generic, List, Optional
|
|
3
|
+
|
|
4
|
+
from typing_extensions import TypeVar
|
|
3
5
|
|
|
4
6
|
from e2b.exceptions import SandboxException
|
|
5
7
|
|
|
@@ -16,6 +18,18 @@ PtyOutput = bytes
|
|
|
16
18
|
Pty output.
|
|
17
19
|
"""
|
|
18
20
|
|
|
21
|
+
OutputT = TypeVar("OutputT", bound=Optional[str], default=str)
|
|
22
|
+
"""
|
|
23
|
+
Type of the accumulated command output: `None` when the command was started with `retain_output=False`, `str` otherwise.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def join_output(chunks: Optional[List[str]]) -> Optional[str]:
|
|
28
|
+
"""
|
|
29
|
+
Join accumulated output chunks, or return `None` when output is not retained.
|
|
30
|
+
"""
|
|
31
|
+
return None if chunks is None else "".join(chunks)
|
|
32
|
+
|
|
19
33
|
|
|
20
34
|
@dataclass
|
|
21
35
|
class PtySize:
|
|
@@ -34,18 +48,22 @@ class PtySize:
|
|
|
34
48
|
|
|
35
49
|
|
|
36
50
|
@dataclass
|
|
37
|
-
class CommandResult:
|
|
51
|
+
class CommandResult(Generic[OutputT]):
|
|
38
52
|
"""
|
|
39
53
|
Command execution result.
|
|
40
54
|
"""
|
|
41
55
|
|
|
42
|
-
stderr:
|
|
56
|
+
stderr: OutputT
|
|
43
57
|
"""
|
|
44
58
|
Command stderr output.
|
|
59
|
+
|
|
60
|
+
`None` if the command was started with `retain_output=False`.
|
|
45
61
|
"""
|
|
46
|
-
stdout:
|
|
62
|
+
stdout: OutputT
|
|
47
63
|
"""
|
|
48
64
|
Command stdout output.
|
|
65
|
+
|
|
66
|
+
`None` if the command was started with `retain_output=False`.
|
|
49
67
|
"""
|
|
50
68
|
exit_code: int
|
|
51
69
|
"""
|
|
@@ -60,10 +78,12 @@ class CommandResult:
|
|
|
60
78
|
|
|
61
79
|
|
|
62
80
|
@dataclass
|
|
63
|
-
class CommandExitException(SandboxException, CommandResult):
|
|
81
|
+
class CommandExitException(SandboxException, CommandResult[OutputT]):
|
|
64
82
|
"""
|
|
65
83
|
Exception raised when a command exits with a non-zero exit code.
|
|
66
84
|
"""
|
|
67
85
|
|
|
68
86
|
def __str__(self):
|
|
87
|
+
if self.stderr is None:
|
|
88
|
+
return f"Command exited with code {self.exit_code}"
|
|
69
89
|
return f"Command exited with code {self.exit_code} and error:\n{self.stderr}"
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import gzip
|
|
3
|
+
import inspect
|
|
3
4
|
import re
|
|
4
5
|
from dataclasses import dataclass, field
|
|
5
6
|
from datetime import datetime
|
|
6
7
|
from enum import Enum
|
|
7
8
|
from io import IOBase, TextIOBase
|
|
8
|
-
from typing import
|
|
9
|
+
from typing import (
|
|
10
|
+
IO,
|
|
11
|
+
AsyncIterable,
|
|
12
|
+
AsyncIterator,
|
|
13
|
+
Dict,
|
|
14
|
+
Iterable,
|
|
15
|
+
Iterator,
|
|
16
|
+
Optional,
|
|
17
|
+
Sequence,
|
|
18
|
+
TypedDict,
|
|
19
|
+
TypeGuard,
|
|
20
|
+
Union,
|
|
21
|
+
cast,
|
|
22
|
+
)
|
|
9
23
|
|
|
10
24
|
import httpx
|
|
11
25
|
|
|
12
26
|
from protobuf.wkt import Timestamp
|
|
13
27
|
|
|
14
28
|
from e2b.envd.filesystem import filesystem_pb
|
|
15
|
-
from e2b.exceptions import InvalidArgumentException
|
|
29
|
+
from e2b.exceptions import InvalidArgumentException, TemplateException
|
|
16
30
|
from e2b.io_utils import agzip_iter, aiter_io_chunks, gzip_iter, iter_io_chunks
|
|
17
31
|
|
|
18
32
|
|
|
@@ -148,15 +162,53 @@ def map_entry_info(entry: filesystem_pb.EntryInfo) -> EntryInfo:
|
|
|
148
162
|
)
|
|
149
163
|
|
|
150
164
|
|
|
165
|
+
WriteData = Union[str, bytes, IO, Iterable[bytes]]
|
|
166
|
+
"""Data accepted by ``Sandbox.files.write``."""
|
|
167
|
+
|
|
168
|
+
AsyncWriteData = Union[str, bytes, IO, AsyncIterable[bytes]]
|
|
169
|
+
"""Data accepted by ``AsyncSandbox.files.write``."""
|
|
170
|
+
|
|
171
|
+
|
|
151
172
|
class WriteEntry(TypedDict):
|
|
152
173
|
"""
|
|
153
174
|
Contains path and data of the file to be written to the filesystem.
|
|
175
|
+
|
|
176
|
+
``data`` can be a ``str``, ``bytes`` or a file-like object; such an entry is
|
|
177
|
+
accepted by both ``Sandbox`` and ``AsyncSandbox``. Use :class:`SyncWriteEntry`
|
|
178
|
+
or :class:`AsyncWriteEntry` to stream an iterable of ``bytes`` chunks.
|
|
154
179
|
"""
|
|
155
180
|
|
|
156
181
|
path: str
|
|
157
182
|
data: Union[str, bytes, IO]
|
|
158
183
|
|
|
159
184
|
|
|
185
|
+
class SyncWriteEntry(TypedDict):
|
|
186
|
+
"""
|
|
187
|
+
Contains path and data of the file to be written to the filesystem by ``Sandbox``.
|
|
188
|
+
|
|
189
|
+
``data`` can be anything :class:`WriteEntry` accepts, or an iterable of
|
|
190
|
+
``bytes`` chunks.
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
path: str
|
|
194
|
+
data: WriteData
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class AsyncWriteEntry(TypedDict):
|
|
198
|
+
"""
|
|
199
|
+
Contains path and data of the file to be written to the filesystem by ``AsyncSandbox``.
|
|
200
|
+
|
|
201
|
+
``data`` can be anything :class:`WriteEntry` accepts, or an async iterable
|
|
202
|
+
of ``bytes`` chunks.
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
path: str
|
|
206
|
+
data: AsyncWriteData
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
AnyWriteEntry = Union[WriteEntry, SyncWriteEntry, AsyncWriteEntry]
|
|
210
|
+
|
|
211
|
+
|
|
160
212
|
class FileStreamReader(Iterator[bytes]):
|
|
161
213
|
"""Iterator over a streamed file download.
|
|
162
214
|
|
|
@@ -264,7 +316,143 @@ class AsyncFileStreamReader(AsyncIterator[bytes]):
|
|
|
264
316
|
await self.aclose()
|
|
265
317
|
|
|
266
318
|
|
|
267
|
-
def
|
|
319
|
+
def _is_file_like(data) -> TypeGuard[IO]:
|
|
320
|
+
"""Whether ``data`` is read as a file: an ``IOBase``, or any object with a
|
|
321
|
+
sync ``read`` method (``tempfile`` wrappers, werkzeug ``FileStorage``, Django
|
|
322
|
+
``File``), which would otherwise be iterated line by line.
|
|
323
|
+
|
|
324
|
+
An async ``read`` (aiofiles files, aiohttp ``response.content``) doesn't
|
|
325
|
+
count: those are consumed as async iterables."""
|
|
326
|
+
if isinstance(data, IOBase):
|
|
327
|
+
return True
|
|
328
|
+
if isinstance(data, (str, bytes)):
|
|
329
|
+
return False
|
|
330
|
+
read = getattr(data, "read", None)
|
|
331
|
+
return callable(read) and not inspect.iscoroutinefunction(read)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def _is_chunk_iterable(data) -> TypeGuard[Iterable[bytes]]:
|
|
335
|
+
"""Whether ``data`` is an iterable of ``bytes`` chunks (not a buffer or file)."""
|
|
336
|
+
return (
|
|
337
|
+
isinstance(data, Iterable)
|
|
338
|
+
and not isinstance(data, (str, bytes, bytearray, memoryview))
|
|
339
|
+
and not _is_file_like(data)
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def _is_async_chunk_iterable(data) -> TypeGuard[AsyncIterable[bytes]]:
|
|
344
|
+
return isinstance(data, AsyncIterable) and not _is_file_like(data)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
class ChunkCheck:
|
|
348
|
+
"""Records a chunk validation error raised while the transport pulls the
|
|
349
|
+
upload body: the transport reports it as its own ``httpx.WriteError``, so
|
|
350
|
+
the write re-raises the recorded error instead."""
|
|
351
|
+
|
|
352
|
+
def __init__(self) -> None:
|
|
353
|
+
self.error: Optional[InvalidArgumentException] = None
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _check_chunk(chunk, check: Optional[ChunkCheck] = None) -> bytes:
|
|
357
|
+
if isinstance(chunk, bytes):
|
|
358
|
+
return chunk
|
|
359
|
+
if isinstance(chunk, (bytearray, memoryview)):
|
|
360
|
+
return bytes(chunk)
|
|
361
|
+
err = InvalidArgumentException(
|
|
362
|
+
f"Iterable upload data must yield bytes chunks, got {type(chunk).__name__}"
|
|
363
|
+
)
|
|
364
|
+
if check is not None:
|
|
365
|
+
check.error = err
|
|
366
|
+
raise err
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
def iter_chunks(
|
|
370
|
+
data: Iterable[bytes], check: Optional[ChunkCheck] = None
|
|
371
|
+
) -> Iterator[bytes]:
|
|
372
|
+
"""Iterate user-supplied upload chunks, rejecting anything but bytes."""
|
|
373
|
+
for chunk in data:
|
|
374
|
+
yield _check_chunk(chunk, check)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
async def aiter_chunks(
|
|
378
|
+
data: AsyncIterable[bytes], check: Optional[ChunkCheck] = None
|
|
379
|
+
) -> AsyncIterator[bytes]:
|
|
380
|
+
"""Iterate user-supplied async upload chunks, rejecting anything but bytes."""
|
|
381
|
+
async for chunk in data:
|
|
382
|
+
yield _check_chunk(chunk, check)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def _is_wrong_iterable(data, is_async: bool) -> bool:
|
|
386
|
+
"""Whether ``data`` is an iterable of the kind the other SDK takes: async
|
|
387
|
+
iterables only go to ``AsyncSandbox``, sync ones only to ``Sandbox``."""
|
|
388
|
+
if is_async:
|
|
389
|
+
return _is_chunk_iterable(data) and not _is_async_chunk_iterable(data)
|
|
390
|
+
return _is_async_chunk_iterable(data) and not _is_chunk_iterable(data)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def _unsupported_data(
|
|
394
|
+
data, is_async: bool, file_path: Optional[str] = None
|
|
395
|
+
) -> InvalidArgumentException:
|
|
396
|
+
target = f" for file {file_path}" if file_path else ""
|
|
397
|
+
if _is_wrong_iterable(data, is_async):
|
|
398
|
+
if is_async:
|
|
399
|
+
return InvalidArgumentException(
|
|
400
|
+
f"Sync iterable data{target} is only supported by `Sandbox`; "
|
|
401
|
+
"pass an async iterable of bytes, a file-like object or bytes to `AsyncSandbox.files.write`."
|
|
402
|
+
)
|
|
403
|
+
return InvalidArgumentException(
|
|
404
|
+
f"Async iterable data{target} is only supported by `AsyncSandbox`; "
|
|
405
|
+
"pass a sync iterable of bytes, a file-like object or bytes to `Sandbox.files.write`."
|
|
406
|
+
)
|
|
407
|
+
return InvalidArgumentException(f"Unsupported data type{target}: {type(data)}")
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def check_stream_upload(
|
|
411
|
+
files: Sequence[AnyWriteEntry],
|
|
412
|
+
use_octet_stream: bool,
|
|
413
|
+
supports_octet_stream: bool,
|
|
414
|
+
is_async: bool,
|
|
415
|
+
) -> None:
|
|
416
|
+
"""Reject iterable data on the multipart upload, which would buffer it.
|
|
417
|
+
|
|
418
|
+
Iterables of the other SDK's kind are rejected outright: sync ones in
|
|
419
|
+
``AsyncSandbox`` (``is_async``), async ones in ``Sandbox``.
|
|
420
|
+
"""
|
|
421
|
+
for file in files:
|
|
422
|
+
if _is_wrong_iterable(file["data"], is_async):
|
|
423
|
+
raise _unsupported_data(file["data"], is_async, file["path"])
|
|
424
|
+
if not any(
|
|
425
|
+
_is_chunk_iterable(file["data"]) or _is_async_chunk_iterable(file["data"])
|
|
426
|
+
for file in files
|
|
427
|
+
):
|
|
428
|
+
return
|
|
429
|
+
if not supports_octet_stream:
|
|
430
|
+
raise TemplateException("Uploading iterable data requires envd 0.5.7 or later.")
|
|
431
|
+
if not use_octet_stream:
|
|
432
|
+
raise InvalidArgumentException(
|
|
433
|
+
"Iterable data is only uploaded with octet-stream; "
|
|
434
|
+
"`use_octet_stream=False` is not supported for it."
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
class _BinaryReader:
|
|
439
|
+
"""Reads a non-``IOBase`` file-like of either mode as UTF-8 bytes.
|
|
440
|
+
|
|
441
|
+
httpx sizes a multipart file by its descriptor, which miscounts text that
|
|
442
|
+
re-encodes to a different length, so this hides the descriptor and httpx
|
|
443
|
+
streams the field without a precomputed length."""
|
|
444
|
+
|
|
445
|
+
def __init__(self, data: IO) -> None:
|
|
446
|
+
self._data = data
|
|
447
|
+
|
|
448
|
+
def read(self, size: int = -1) -> bytes:
|
|
449
|
+
chunk = self._data.read(size)
|
|
450
|
+
return chunk if isinstance(chunk, bytes) else chunk.encode("utf-8")
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def _to_httpx_file(
|
|
454
|
+
file_path: str, file_data: Union[WriteData, AsyncWriteData], is_async: bool
|
|
455
|
+
):
|
|
268
456
|
"""Build an httpx multipart `("file", (name, data))` tuple for the upload."""
|
|
269
457
|
if isinstance(file_data, (str, bytes)):
|
|
270
458
|
return ("file", (file_path, file_data))
|
|
@@ -276,11 +464,15 @@ def _to_httpx_file(file_path: str, file_data: Union[str, bytes, IO]):
|
|
|
276
464
|
return ("file", (file_path, file_data.read()))
|
|
277
465
|
elif isinstance(file_data, IOBase):
|
|
278
466
|
return ("file", (file_path, file_data))
|
|
467
|
+
elif _is_file_like(file_data):
|
|
468
|
+
return ("file", (file_path, cast(IO[bytes], _BinaryReader(file_data))))
|
|
279
469
|
else:
|
|
280
|
-
raise
|
|
470
|
+
raise _unsupported_data(file_data, is_async, file_path)
|
|
281
471
|
|
|
282
472
|
|
|
283
|
-
def multipart_body_is_streamed(
|
|
473
|
+
def multipart_body_is_streamed(
|
|
474
|
+
files: Sequence[AnyWriteEntry],
|
|
475
|
+
) -> bool:
|
|
284
476
|
"""Whether the multipart body built from ``files`` streams any entry.
|
|
285
477
|
|
|
286
478
|
Only binary file-like data is handed to httpx as a stream:
|
|
@@ -291,52 +483,65 @@ def multipart_body_is_streamed(files: List[WriteEntry]) -> bool:
|
|
|
291
483
|
``to_upload_body``, which streams text and binary alike on the
|
|
292
484
|
octet-stream path (``iter_io_chunks`` encodes the chunks)."""
|
|
293
485
|
return any(
|
|
294
|
-
|
|
486
|
+
_is_file_like(file["data"]) and not isinstance(file["data"], TextIOBase)
|
|
295
487
|
for file in files
|
|
296
488
|
)
|
|
297
489
|
|
|
298
490
|
|
|
299
491
|
def to_upload_body(
|
|
300
|
-
data:
|
|
492
|
+
data: WriteData,
|
|
301
493
|
use_gzip: bool = False,
|
|
494
|
+
check: Optional[ChunkCheck] = None,
|
|
302
495
|
) -> Union[bytes, IO, Iterator[bytes]]:
|
|
303
496
|
"""Prepare file data for upload, optionally gzip-compressed.
|
|
304
497
|
|
|
305
|
-
File-like objects are streamed in chunks instead of
|
|
306
|
-
memory.
|
|
498
|
+
File-like objects and iterables of bytes are streamed in chunks instead of
|
|
499
|
+
being buffered in memory.
|
|
307
500
|
"""
|
|
308
501
|
if isinstance(data, (str, bytes)):
|
|
309
502
|
raw = data.encode("utf-8") if isinstance(data, str) else data
|
|
310
503
|
return gzip.compress(raw) if use_gzip else raw
|
|
311
|
-
elif
|
|
312
|
-
if
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
504
|
+
elif _is_file_like(data):
|
|
505
|
+
if (
|
|
506
|
+
isinstance(data, IOBase)
|
|
507
|
+
and not isinstance(data, TextIOBase)
|
|
508
|
+
and not use_gzip
|
|
509
|
+
):
|
|
510
|
+
# httpx streams binary file-like objects in chunks without buffering.
|
|
511
|
+
return cast(IO, data)
|
|
512
|
+
# Text-mode IO yields str chunks—encode them while streaming. Other
|
|
513
|
+
# file-likes may be either mode, and httpx would iterate them by line.
|
|
514
|
+
chunks = iter_io_chunks(data)
|
|
515
|
+
return gzip_iter(chunks) if use_gzip else chunks
|
|
516
|
+
elif _is_chunk_iterable(data):
|
|
517
|
+
chunks = iter_chunks(data, check)
|
|
518
|
+
return gzip_iter(chunks) if use_gzip else chunks
|
|
319
519
|
else:
|
|
320
|
-
raise
|
|
520
|
+
raise _unsupported_data(data, is_async=False)
|
|
321
521
|
|
|
322
522
|
|
|
323
523
|
def to_upload_body_async(
|
|
324
|
-
data:
|
|
524
|
+
data: AsyncWriteData,
|
|
325
525
|
use_gzip: bool = False,
|
|
526
|
+
check: Optional[ChunkCheck] = None,
|
|
326
527
|
) -> Union[bytes, AsyncIterator[bytes]]:
|
|
327
528
|
"""Prepare file data for upload with async httpx, optionally gzip-compressed.
|
|
328
529
|
|
|
329
|
-
File-like objects
|
|
330
|
-
memory. Async httpx requires an async iterable
|
|
530
|
+
File-like objects and async iterables of bytes are streamed in chunks
|
|
531
|
+
instead of being buffered in memory. Async httpx requires an async iterable
|
|
532
|
+
for streamed request bodies.
|
|
331
533
|
"""
|
|
332
534
|
if isinstance(data, (str, bytes)):
|
|
333
535
|
raw = data.encode("utf-8") if isinstance(data, str) else data
|
|
334
536
|
return gzip.compress(raw) if use_gzip else raw
|
|
335
|
-
elif
|
|
537
|
+
elif _is_file_like(data):
|
|
336
538
|
chunks = aiter_io_chunks(data)
|
|
337
539
|
return agzip_iter(chunks) if use_gzip else chunks
|
|
540
|
+
elif _is_async_chunk_iterable(data):
|
|
541
|
+
chunks = aiter_chunks(data, check)
|
|
542
|
+
return agzip_iter(chunks) if use_gzip else chunks
|
|
338
543
|
else:
|
|
339
|
-
raise
|
|
544
|
+
raise _unsupported_data(data, is_async=True)
|
|
340
545
|
|
|
341
546
|
|
|
342
547
|
METADATA_HEADER_PREFIX = "X-Metadata-"
|