From 23ea4adfb145a99bc751e1543835cbd7ee5320cb Mon Sep 17 00:00:00 2001 From: Jakub Novak Date: Mon, 14 Oct 2024 19:51:05 -0700 Subject: [PATCH] Rename rpc methods for watcher --- Makefile | 2 +- .../src/envd/filesystem/filesystem_connect.ts | 41 ++- .../src/envd/filesystem/filesystem_pb.ts | 282 ++++++++++++++++-- .../e2b/api/client/api/default/get_health.py | 8 +- .../sandboxes/delete_sandboxes_sandbox_id.py | 8 +- .../post_sandboxes_sandbox_id_refreshes.py | 12 +- .../post_sandboxes_sandbox_id_timeout.py | 12 +- .../templates/delete_templates_template_id.py | 8 +- ...t_templates_template_id_builds_build_id.py | 8 +- packages/python-sdk/e2b/api/client/client.py | 36 ++- .../e2b/api/client/models/__init__.py | 4 +- .../e2b/envd/filesystem/filesystem_connect.py | 76 ++--- .../e2b/envd/filesystem/filesystem_pb2.py | 47 +-- .../e2b/envd/filesystem/filesystem_pb2.pyi | 16 +- .../e2b/envd/process/process_pb2.py | 11 +- .../sandbox_async/filesystem/filesystem.py | 9 +- packages/python-sdk/e2b/sandbox_async/main.py | 12 +- .../e2b/sandbox_async/process/process.py | 6 +- .../e2b/sandbox_sync/filesystem/filesystem.py | 4 +- .../sandbox_sync/filesystem/watch_handle.py | 11 +- spec/envd/filesystem/filesystem.proto | 20 +- 21 files changed, 481 insertions(+), 152 deletions(-) diff --git a/Makefile b/Makefile index cb7ed6ce8..a0744e9dc 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ generate: generate-js generate-python generate-js: cd packages/js-sdk && pnpm generate cd packages/js-sdk && pnpm generate-envd-api - buf generate --template spec/envd/buf-js.gen.yaml + cd spec/envd && buf generate --template buf-js.gen.yaml generate-python: cd packages/python-sdk && make generate-api diff --git a/packages/js-sdk/src/envd/filesystem/filesystem_connect.ts b/packages/js-sdk/src/envd/filesystem/filesystem_connect.ts index baf7605e8..0bf7b717b 100644 --- a/packages/js-sdk/src/envd/filesystem/filesystem_connect.ts +++ b/packages/js-sdk/src/envd/filesystem/filesystem_connect.ts @@ -3,7 +3,7 @@ /* eslint-disable */ // @ts-nocheck -import { ListDirRequest, ListDirResponse, MakeDirRequest, MakeDirResponse, MoveRequest, MoveResponse, RemoveRequest, RemoveResponse, StatRequest, StatResponse, WatchDirRequest, WatchDirResponse } from "./filesystem_pb.js"; +import { CreateWatcherRequest, CreateWatcherResponse, GetWatcherEventsRequest, GetWatcherEventsResponse, ListDirRequest, ListDirResponse, MakeDirRequest, MakeDirResponse, MoveRequest, MoveResponse, RemoveRequest, RemoveResponse, RemoveWatcherRequest, RemoveWatcherResponse, StatRequest, StatResponse, WatchDirRequest, WatchDirResponse } from "./filesystem_pb.js"; import { MethodKind } from "@bufbuild/protobuf"; /** @@ -48,6 +48,15 @@ export const Filesystem = { O: ListDirResponse, kind: MethodKind.Unary, }, + /** + * @generated from rpc filesystem.Filesystem.Remove + */ + remove: { + name: "Remove", + I: RemoveRequest, + O: RemoveResponse, + kind: MethodKind.Unary, + }, /** * @generated from rpc filesystem.Filesystem.WatchDir */ @@ -58,12 +67,32 @@ export const Filesystem = { kind: MethodKind.ServerStreaming, }, /** - * @generated from rpc filesystem.Filesystem.Remove + * Non-streaming versions of WatchDir + * + * @generated from rpc filesystem.Filesystem.CreateWatcher */ - remove: { - name: "Remove", - I: RemoveRequest, - O: RemoveResponse, + createWatcher: { + name: "CreateWatcher", + I: CreateWatcherRequest, + O: CreateWatcherResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc filesystem.Filesystem.GetWatcherEvents + */ + getWatcherEvents: { + name: "GetWatcherEvents", + I: GetWatcherEventsRequest, + O: GetWatcherEventsResponse, + kind: MethodKind.Unary, + }, + /** + * @generated from rpc filesystem.Filesystem.RemoveWatcher + */ + removeWatcher: { + name: "RemoveWatcher", + I: RemoveWatcherRequest, + O: RemoveWatcherResponse, kind: MethodKind.Unary, }, } diff --git a/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts b/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts index 34057463b..b250cba13 100644 --- a/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts +++ b/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts @@ -532,6 +532,49 @@ export class WatchDirRequest extends Message { } } +/** + * @generated from message filesystem.FilesystemEvent + */ +export class FilesystemEvent extends Message { + /** + * @generated from field: string name = 1; + */ + name = ""; + + /** + * @generated from field: filesystem.EventType type = 2; + */ + type = EventType.UNSPECIFIED; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.FilesystemEvent"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "type", kind: "enum", T: proto3.getEnumType(EventType) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): FilesystemEvent { + return new FilesystemEvent().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): FilesystemEvent { + return new FilesystemEvent().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): FilesystemEvent { + return new FilesystemEvent().fromJsonString(jsonString, options); + } + + static equals(a: FilesystemEvent | PlainMessage | undefined, b: FilesystemEvent | PlainMessage | undefined): boolean { + return proto3.util.equals(FilesystemEvent, a, b); + } +} + /** * @generated from message filesystem.WatchDirResponse */ @@ -547,9 +590,9 @@ export class WatchDirResponse extends Message { case: "start"; } | { /** - * @generated from field: filesystem.WatchDirResponse.FilesystemEvent filesystem = 2; + * @generated from field: filesystem.FilesystemEvent filesystem = 2; */ - value: WatchDirResponse_FilesystemEvent; + value: FilesystemEvent; case: "filesystem"; } | { /** @@ -568,7 +611,7 @@ export class WatchDirResponse extends Message { static readonly typeName = "filesystem.WatchDirResponse"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ { no: 1, name: "start", kind: "message", T: WatchDirResponse_StartEvent, oneof: "event" }, - { no: 2, name: "filesystem", kind: "message", T: WatchDirResponse_FilesystemEvent, oneof: "event" }, + { no: 2, name: "filesystem", kind: "message", T: FilesystemEvent, oneof: "event" }, { no: 3, name: "keepalive", kind: "message", T: WatchDirResponse_KeepAlive, oneof: "event" }, ]); @@ -621,76 +664,249 @@ export class WatchDirResponse_StartEvent extends Message { + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.WatchDirResponse.KeepAlive"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WatchDirResponse_KeepAlive { + return new WatchDirResponse_KeepAlive().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WatchDirResponse_KeepAlive { + return new WatchDirResponse_KeepAlive().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WatchDirResponse_KeepAlive { + return new WatchDirResponse_KeepAlive().fromJsonString(jsonString, options); + } + + static equals(a: WatchDirResponse_KeepAlive | PlainMessage | undefined, b: WatchDirResponse_KeepAlive | PlainMessage | undefined): boolean { + return proto3.util.equals(WatchDirResponse_KeepAlive, a, b); + } +} + +/** + * @generated from message filesystem.CreateWatcherRequest */ -export class WatchDirResponse_FilesystemEvent extends Message { +export class CreateWatcherRequest extends Message { /** - * @generated from field: string name = 1; + * @generated from field: string path = 1; */ - name = ""; + path = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.CreateWatcherRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "path", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CreateWatcherRequest { + return new CreateWatcherRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CreateWatcherRequest { + return new CreateWatcherRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CreateWatcherRequest { + return new CreateWatcherRequest().fromJsonString(jsonString, options); + } + + static equals(a: CreateWatcherRequest | PlainMessage | undefined, b: CreateWatcherRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(CreateWatcherRequest, a, b); + } +} +/** + * @generated from message filesystem.CreateWatcherResponse + */ +export class CreateWatcherResponse extends Message { /** - * @generated from field: filesystem.EventType type = 2; + * @generated from field: string watcher_id = 1; */ - type = EventType.UNSPECIFIED; + watcherId = ""; - constructor(data?: PartialMessage) { + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); } static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "filesystem.WatchDirResponse.FilesystemEvent"; + static readonly typeName = "filesystem.CreateWatcherResponse"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "type", kind: "enum", T: proto3.getEnumType(EventType) }, + { no: 1, name: "watcher_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ]); - static fromBinary(bytes: Uint8Array, options?: Partial): WatchDirResponse_FilesystemEvent { - return new WatchDirResponse_FilesystemEvent().fromBinary(bytes, options); + static fromBinary(bytes: Uint8Array, options?: Partial): CreateWatcherResponse { + return new CreateWatcherResponse().fromBinary(bytes, options); } - static fromJson(jsonValue: JsonValue, options?: Partial): WatchDirResponse_FilesystemEvent { - return new WatchDirResponse_FilesystemEvent().fromJson(jsonValue, options); + static fromJson(jsonValue: JsonValue, options?: Partial): CreateWatcherResponse { + return new CreateWatcherResponse().fromJson(jsonValue, options); } - static fromJsonString(jsonString: string, options?: Partial): WatchDirResponse_FilesystemEvent { - return new WatchDirResponse_FilesystemEvent().fromJsonString(jsonString, options); + static fromJsonString(jsonString: string, options?: Partial): CreateWatcherResponse { + return new CreateWatcherResponse().fromJsonString(jsonString, options); } - static equals(a: WatchDirResponse_FilesystemEvent | PlainMessage | undefined, b: WatchDirResponse_FilesystemEvent | PlainMessage | undefined): boolean { - return proto3.util.equals(WatchDirResponse_FilesystemEvent, a, b); + static equals(a: CreateWatcherResponse | PlainMessage | undefined, b: CreateWatcherResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(CreateWatcherResponse, a, b); } } /** - * @generated from message filesystem.WatchDirResponse.KeepAlive + * @generated from message filesystem.GetWatcherEventsRequest */ -export class WatchDirResponse_KeepAlive extends Message { - constructor(data?: PartialMessage) { +export class GetWatcherEventsRequest extends Message { + /** + * @generated from field: string watcher_id = 1; + */ + watcherId = ""; + + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); } static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "filesystem.WatchDirResponse.KeepAlive"; + static readonly typeName = "filesystem.GetWatcherEventsRequest"; static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "watcher_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ]); - static fromBinary(bytes: Uint8Array, options?: Partial): WatchDirResponse_KeepAlive { - return new WatchDirResponse_KeepAlive().fromBinary(bytes, options); + static fromBinary(bytes: Uint8Array, options?: Partial): GetWatcherEventsRequest { + return new GetWatcherEventsRequest().fromBinary(bytes, options); } - static fromJson(jsonValue: JsonValue, options?: Partial): WatchDirResponse_KeepAlive { - return new WatchDirResponse_KeepAlive().fromJson(jsonValue, options); + static fromJson(jsonValue: JsonValue, options?: Partial): GetWatcherEventsRequest { + return new GetWatcherEventsRequest().fromJson(jsonValue, options); } - static fromJsonString(jsonString: string, options?: Partial): WatchDirResponse_KeepAlive { - return new WatchDirResponse_KeepAlive().fromJsonString(jsonString, options); + static fromJsonString(jsonString: string, options?: Partial): GetWatcherEventsRequest { + return new GetWatcherEventsRequest().fromJsonString(jsonString, options); } - static equals(a: WatchDirResponse_KeepAlive | PlainMessage | undefined, b: WatchDirResponse_KeepAlive | PlainMessage | undefined): boolean { - return proto3.util.equals(WatchDirResponse_KeepAlive, a, b); + static equals(a: GetWatcherEventsRequest | PlainMessage | undefined, b: GetWatcherEventsRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetWatcherEventsRequest, a, b); + } +} + +/** + * @generated from message filesystem.GetWatcherEventsResponse + */ +export class GetWatcherEventsResponse extends Message { + /** + * @generated from field: repeated filesystem.FilesystemEvent events = 1; + */ + events: FilesystemEvent[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.GetWatcherEventsResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "events", kind: "message", T: FilesystemEvent, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetWatcherEventsResponse { + return new GetWatcherEventsResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetWatcherEventsResponse { + return new GetWatcherEventsResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetWatcherEventsResponse { + return new GetWatcherEventsResponse().fromJsonString(jsonString, options); + } + + static equals(a: GetWatcherEventsResponse | PlainMessage | undefined, b: GetWatcherEventsResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(GetWatcherEventsResponse, a, b); + } +} + +/** + * @generated from message filesystem.RemoveWatcherRequest + */ +export class RemoveWatcherRequest extends Message { + /** + * @generated from field: string watcher_id = 1; + */ + watcherId = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.RemoveWatcherRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "watcher_id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RemoveWatcherRequest { + return new RemoveWatcherRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RemoveWatcherRequest { + return new RemoveWatcherRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RemoveWatcherRequest { + return new RemoveWatcherRequest().fromJsonString(jsonString, options); + } + + static equals(a: RemoveWatcherRequest | PlainMessage | undefined, b: RemoveWatcherRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(RemoveWatcherRequest, a, b); + } +} + +/** + * @generated from message filesystem.RemoveWatcherResponse + */ +export class RemoveWatcherResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "filesystem.RemoveWatcherResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RemoveWatcherResponse { + return new RemoveWatcherResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RemoveWatcherResponse { + return new RemoveWatcherResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RemoveWatcherResponse { + return new RemoveWatcherResponse().fromJsonString(jsonString, options); + } + + static equals(a: RemoveWatcherResponse | PlainMessage | undefined, b: RemoveWatcherResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(RemoveWatcherResponse, a, b); } } diff --git a/packages/python-sdk/e2b/api/client/api/default/get_health.py b/packages/python-sdk/e2b/api/client/api/default/get_health.py index 339a6905f..c295ec3c2 100644 --- a/packages/python-sdk/e2b/api/client/api/default/get_health.py +++ b/packages/python-sdk/e2b/api/client/api/default/get_health.py @@ -17,7 +17,9 @@ def _get_kwargs() -> Dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.OK: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -28,7 +30,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py b/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py index fa9f37750..974f2d687 100644 --- a/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +++ b/packages/python-sdk/e2b/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py @@ -19,7 +19,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.NO_CONTENT: return None if response.status_code == HTTPStatus.NOT_FOUND: @@ -34,7 +36,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py index 163bcf177..39dfc678a 100644 --- a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +++ b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py @@ -5,7 +5,9 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.post_sandboxes_sandbox_id_refreshes_body import PostSandboxesSandboxIDRefreshesBody +from ...models.post_sandboxes_sandbox_id_refreshes_body import ( + PostSandboxesSandboxIDRefreshesBody, +) from ...types import Response @@ -30,7 +32,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.NO_CONTENT: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -43,7 +47,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py index 148d97c87..615963abf 100644 --- a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +++ b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py @@ -5,7 +5,9 @@ from ... import errors from ...client import AuthenticatedClient, Client -from ...models.post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBody +from ...models.post_sandboxes_sandbox_id_timeout_body import ( + PostSandboxesSandboxIDTimeoutBody, +) from ...types import Response @@ -30,7 +32,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.NO_CONTENT: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -45,7 +49,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py b/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py index d493420f3..b7c162b27 100644 --- a/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py +++ b/packages/python-sdk/e2b/api/client/api/templates/delete_templates_template_id.py @@ -19,7 +19,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.NO_CONTENT: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -32,7 +34,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py index 67e21c739..754229875 100644 --- a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py +++ b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id_builds_build_id.py @@ -20,7 +20,9 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]: +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Any]: if response.status_code == HTTPStatus.ACCEPTED: return None if response.status_code == HTTPStatus.UNAUTHORIZED: @@ -33,7 +35,9 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]: +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Any]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, diff --git a/packages/python-sdk/e2b/api/client/client.py b/packages/python-sdk/e2b/api/client/client.py index 63a2493b9..38b07d057 100644 --- a/packages/python-sdk/e2b/api/client/client.py +++ b/packages/python-sdk/e2b/api/client/client.py @@ -38,9 +38,15 @@ class Client: _base_url: str = field(alias="base_url") _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -168,9 +174,15 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") - _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _timeout: Optional[httpx.Timeout] = field( + default=None, kw_only=True, alias="timeout" + ) + _verify_ssl: Union[str, bool, ssl.SSLContext] = field( + default=True, kw_only=True, alias="verify_ssl" + ) + _follow_redirects: bool = field( + default=False, kw_only=True, alias="follow_redirects" + ) _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -214,7 +226,9 @@ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": def get_httpx_client(self) -> httpx.Client: """Get the underlying httpx.Client, constructing a new one if not previously set""" if self._client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._client = httpx.Client( base_url=self._base_url, cookies=self._cookies, @@ -235,7 +249,9 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client( + self, async_client: httpx.AsyncClient + ) -> "AuthenticatedClient": """Manually the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -246,7 +262,9 @@ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Authentica def get_async_httpx_client(self) -> httpx.AsyncClient: """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" if self._async_client is None: - self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) self._async_client = httpx.AsyncClient( base_url=self._base_url, cookies=self._cookies, diff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.py index d55b958c2..85275a6de 100644 --- a/packages/python-sdk/e2b/api/client/models/__init__.py +++ b/packages/python-sdk/e2b/api/client/models/__init__.py @@ -2,7 +2,9 @@ from .error import Error from .new_sandbox import NewSandbox -from .post_sandboxes_sandbox_id_refreshes_body import PostSandboxesSandboxIDRefreshesBody +from .post_sandboxes_sandbox_id_refreshes_body import ( + PostSandboxesSandboxIDRefreshesBody, +) from .post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBody from .running_sandbox import RunningSandbox from .sandbox import Sandbox diff --git a/packages/python-sdk/e2b/envd/filesystem/filesystem_connect.py b/packages/python-sdk/e2b/envd/filesystem/filesystem_connect.py index bda1cc7fe..e995585e8 100644 --- a/packages/python-sdk/e2b/envd/filesystem/filesystem_connect.py +++ b/packages/python-sdk/e2b/envd/filesystem/filesystem_connect.py @@ -74,29 +74,29 @@ def __init__( json=json, **opts, ) - self._watch_dir_start = connect.Client( + self._create_watcher = connect.Client( pool=pool, async_pool=async_pool, - url=f"{base_url}/{FilesystemName}/WatchDirStart", - response_type=filesystem_dot_filesystem__pb2.WatchDirStartResponse, + url=f"{base_url}/{FilesystemName}/CreateWatcher", + response_type=filesystem_dot_filesystem__pb2.CreateWatcherResponse, compressor=compressor, json=json, **opts, ) - self._watch_dir_get = connect.Client( + self._get_watcher_events = connect.Client( pool=pool, async_pool=async_pool, - url=f"{base_url}/{FilesystemName}/WatchDirGet", - response_type=filesystem_dot_filesystem__pb2.WatchDirGetResponse, + url=f"{base_url}/{FilesystemName}/GetWatcherEvents", + response_type=filesystem_dot_filesystem__pb2.GetWatcherEventsResponse, compressor=compressor, json=json, **opts, ) - self._watch_dir_stop = connect.Client( + self._remove_watcher = connect.Client( pool=pool, async_pool=async_pool, - url=f"{base_url}/{FilesystemName}/WatchDirStop", - response_type=filesystem_dot_filesystem__pb2.WatchDirStopResponse, + url=f"{base_url}/{FilesystemName}/RemoveWatcher", + response_type=filesystem_dot_filesystem__pb2.RemoveWatcherResponse, compressor=compressor, json=json, **opts, @@ -162,32 +162,32 @@ def awatch_dir( ) -> AsyncGenerator[filesystem_dot_filesystem__pb2.WatchDirResponse, Any]: return self._watch_dir.acall_server_stream(req, **opts) - def watch_dir_start( - self, req: filesystem_dot_filesystem__pb2.WatchDirRequest, **opts - ) -> filesystem_dot_filesystem__pb2.WatchDirStartResponse: - return self._watch_dir_start.call_unary(req, **opts) - - def awatch_dir_start( - self, req: filesystem_dot_filesystem__pb2.WatchDirRequest, **opts - ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.WatchDirStartResponse]: - return self._watch_dir_start.acall_unary(req, **opts) - - def watch_dir_get( - self, req: filesystem_dot_filesystem__pb2.WatchDirGetRequest, **opts - ) -> filesystem_dot_filesystem__pb2.WatchDirGetResponse: - return self._watch_dir_get.call_unary(req, **opts) - - def awatch_dir_get( - self, req: filesystem_dot_filesystem__pb2.WatchDirGetRequest, **opts - ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.WatchDirGetResponse]: - return self._watch_dir_get.acall_unary(req, **opts) - - def watch_dir_stop( - self, req: filesystem_dot_filesystem__pb2.WatchDirStopRequest, **opts - ) -> filesystem_dot_filesystem__pb2.WatchDirStopResponse: - return self._watch_dir_stop.call_unary(req, **opts) - - def awatch_dir_stop( - self, req: filesystem_dot_filesystem__pb2.WatchDirStopRequest, **opts - ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.WatchDirStopResponse]: - return self._watch_dir_stop.acall_unary(req, **opts) + def create_watcher( + self, req: filesystem_dot_filesystem__pb2.CreateWatcherRequest, **opts + ) -> filesystem_dot_filesystem__pb2.CreateWatcherResponse: + return self._create_watcher.call_unary(req, **opts) + + def acreate_watcher( + self, req: filesystem_dot_filesystem__pb2.CreateWatcherRequest, **opts + ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.CreateWatcherResponse]: + return self._create_watcher.acall_unary(req, **opts) + + def get_watcher_events( + self, req: filesystem_dot_filesystem__pb2.GetWatcherEventsRequest, **opts + ) -> filesystem_dot_filesystem__pb2.GetWatcherEventsResponse: + return self._get_watcher_events.call_unary(req, **opts) + + def aget_watcher_events( + self, req: filesystem_dot_filesystem__pb2.GetWatcherEventsRequest, **opts + ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.GetWatcherEventsResponse]: + return self._get_watcher_events.acall_unary(req, **opts) + + def remove_watcher( + self, req: filesystem_dot_filesystem__pb2.RemoveWatcherRequest, **opts + ) -> filesystem_dot_filesystem__pb2.RemoveWatcherResponse: + return self._remove_watcher.call_unary(req, **opts) + + def aremove_watcher( + self, req: filesystem_dot_filesystem__pb2.RemoveWatcherRequest, **opts + ) -> Coroutine[Any, Any, filesystem_dot_filesystem__pb2.RemoveWatcherResponse]: + return self._remove_watcher.acall_unary(req, **opts) diff --git a/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.py b/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.py index a8fad31d5..7bceafff4 100644 --- a/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.py +++ b/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.py @@ -1,20 +1,25 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE # source: filesystem/filesystem.proto # Protobuf Python Version: 5.27.3 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, 5, 27, 3, "", "filesystem/filesystem.proto" +) # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n\x1b\x66ilesystem/filesystem.proto\x12\nfilesystem"G\n\x0bMoveRequest\x12\x16\n\x06source\x18\x01 \x01(\tR\x06source\x12 \n\x0b\x64\x65stination\x18\x02 \x01(\tR\x0b\x64\x65stination";\n\x0cMoveResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"$\n\x0eMakeDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path">\n\x0fMakeDirResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"#\n\rRemoveRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"\x10\n\x0eRemoveResponse"!\n\x0bStatRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path";\n\x0cStatResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"]\n\tEntryInfo\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12(\n\x04type\x18\x02 \x01(\x0e\x32\x14.filesystem.FileTypeR\x04type\x12\x12\n\x04path\x18\x03 \x01(\tR\x04path"$\n\x0eListDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"B\n\x0fListDirResponse\x12/\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x15.filesystem.EntryInfoR\x07\x65ntries"%\n\x0fWatchDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"P\n\x0f\x46ilesystemEvent\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12)\n\x04type\x18\x02 \x01(\x0e\x32\x15.filesystem.EventTypeR\x04type"\xfe\x01\n\x10WatchDirResponse\x12?\n\x05start\x18\x01 \x01(\x0b\x32\'.filesystem.WatchDirResponse.StartEventH\x00R\x05start\x12=\n\nfilesystem\x18\x02 \x01(\x0b\x32\x1b.filesystem.FilesystemEventH\x00R\nfilesystem\x12\x46\n\tkeepalive\x18\x03 \x01(\x0b\x32&.filesystem.WatchDirResponse.KeepAliveH\x00R\tkeepalive\x1a\x0c\n\nStartEvent\x1a\x0b\n\tKeepAliveB\x07\n\x05\x65vent"6\n\x15WatchDirStartResponse\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"3\n\x12WatchDirGetRequest\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"J\n\x13WatchDirGetResponse\x12\x33\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1b.filesystem.FilesystemEventR\x06\x65vents"4\n\x13WatchDirStopRequest\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"\x16\n\x14WatchDirStopResponse*R\n\x08\x46ileType\x12\x19\n\x15\x46ILE_TYPE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x46ILE_TYPE_FILE\x10\x01\x12\x17\n\x13\x46ILE_TYPE_DIRECTORY\x10\x02*\x98\x01\n\tEventType\x12\x1a\n\x16\x45VENT_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x45VENT_TYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENT_TYPE_WRITE\x10\x02\x12\x15\n\x11\x45VENT_TYPE_REMOVE\x10\x03\x12\x15\n\x11\x45VENT_TYPE_RENAME\x10\x04\x12\x14\n\x10\x45VENT_TYPE_CHMOD\x10\x05\x32\x88\x05\n\nFilesystem\x12\x39\n\x04Stat\x12\x17.filesystem.StatRequest\x1a\x18.filesystem.StatResponse\x12\x42\n\x07MakeDir\x12\x1a.filesystem.MakeDirRequest\x1a\x1b.filesystem.MakeDirResponse\x12\x39\n\x04Move\x12\x17.filesystem.MoveRequest\x1a\x18.filesystem.MoveResponse\x12\x42\n\x07ListDir\x12\x1a.filesystem.ListDirRequest\x1a\x1b.filesystem.ListDirResponse\x12?\n\x06Remove\x12\x19.filesystem.RemoveRequest\x1a\x1a.filesystem.RemoveResponse\x12G\n\x08WatchDir\x12\x1b.filesystem.WatchDirRequest\x1a\x1c.filesystem.WatchDirResponse0\x01\x12O\n\rWatchDirStart\x12\x1b.filesystem.WatchDirRequest\x1a!.filesystem.WatchDirStartResponse\x12N\n\x0bWatchDirGet\x12\x1e.filesystem.WatchDirGetRequest\x1a\x1f.filesystem.WatchDirGetResponse\x12Q\n\x0cWatchDirStop\x12\x1f.filesystem.WatchDirStopRequest\x1a .filesystem.WatchDirStopResponseBi\n\x0e\x63om.filesystemB\x0f\x46ilesystemProtoP\x01\xa2\x02\x03\x46XX\xaa\x02\nFilesystem\xca\x02\nFilesystem\xe2\x02\x16\x46ilesystem\\GPBMetadata\xea\x02\nFilesystemb\x06proto3' + b'\n\x1b\x66ilesystem/filesystem.proto\x12\nfilesystem"G\n\x0bMoveRequest\x12\x16\n\x06source\x18\x01 \x01(\tR\x06source\x12 \n\x0b\x64\x65stination\x18\x02 \x01(\tR\x0b\x64\x65stination";\n\x0cMoveResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"$\n\x0eMakeDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path">\n\x0fMakeDirResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"#\n\rRemoveRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"\x10\n\x0eRemoveResponse"!\n\x0bStatRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path";\n\x0cStatResponse\x12+\n\x05\x65ntry\x18\x01 \x01(\x0b\x32\x15.filesystem.EntryInfoR\x05\x65ntry"]\n\tEntryInfo\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12(\n\x04type\x18\x02 \x01(\x0e\x32\x14.filesystem.FileTypeR\x04type\x12\x12\n\x04path\x18\x03 \x01(\tR\x04path"$\n\x0eListDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"B\n\x0fListDirResponse\x12/\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x15.filesystem.EntryInfoR\x07\x65ntries"%\n\x0fWatchDirRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"P\n\x0f\x46ilesystemEvent\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12)\n\x04type\x18\x02 \x01(\x0e\x32\x15.filesystem.EventTypeR\x04type"\xfe\x01\n\x10WatchDirResponse\x12?\n\x05start\x18\x01 \x01(\x0b\x32\'.filesystem.WatchDirResponse.StartEventH\x00R\x05start\x12=\n\nfilesystem\x18\x02 \x01(\x0b\x32\x1b.filesystem.FilesystemEventH\x00R\nfilesystem\x12\x46\n\tkeepalive\x18\x03 \x01(\x0b\x32&.filesystem.WatchDirResponse.KeepAliveH\x00R\tkeepalive\x1a\x0c\n\nStartEvent\x1a\x0b\n\tKeepAliveB\x07\n\x05\x65vent"*\n\x14\x43reateWatcherRequest\x12\x12\n\x04path\x18\x01 \x01(\tR\x04path"6\n\x15\x43reateWatcherResponse\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"8\n\x17GetWatcherEventsRequest\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"O\n\x18GetWatcherEventsResponse\x12\x33\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x1b.filesystem.FilesystemEventR\x06\x65vents"5\n\x14RemoveWatcherRequest\x12\x1d\n\nwatcher_id\x18\x01 \x01(\tR\twatcherId"\x17\n\x15RemoveWatcherResponse*R\n\x08\x46ileType\x12\x19\n\x15\x46ILE_TYPE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x46ILE_TYPE_FILE\x10\x01\x12\x17\n\x13\x46ILE_TYPE_DIRECTORY\x10\x02*\x98\x01\n\tEventType\x12\x1a\n\x16\x45VENT_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11\x45VENT_TYPE_CREATE\x10\x01\x12\x14\n\x10\x45VENT_TYPE_WRITE\x10\x02\x12\x15\n\x11\x45VENT_TYPE_REMOVE\x10\x03\x12\x15\n\x11\x45VENT_TYPE_RENAME\x10\x04\x12\x14\n\x10\x45VENT_TYPE_CHMOD\x10\x05\x32\x9f\x05\n\nFilesystem\x12\x39\n\x04Stat\x12\x17.filesystem.StatRequest\x1a\x18.filesystem.StatResponse\x12\x42\n\x07MakeDir\x12\x1a.filesystem.MakeDirRequest\x1a\x1b.filesystem.MakeDirResponse\x12\x39\n\x04Move\x12\x17.filesystem.MoveRequest\x1a\x18.filesystem.MoveResponse\x12\x42\n\x07ListDir\x12\x1a.filesystem.ListDirRequest\x1a\x1b.filesystem.ListDirResponse\x12?\n\x06Remove\x12\x19.filesystem.RemoveRequest\x1a\x1a.filesystem.RemoveResponse\x12G\n\x08WatchDir\x12\x1b.filesystem.WatchDirRequest\x1a\x1c.filesystem.WatchDirResponse0\x01\x12T\n\rCreateWatcher\x12 .filesystem.CreateWatcherRequest\x1a!.filesystem.CreateWatcherResponse\x12]\n\x10GetWatcherEvents\x12#.filesystem.GetWatcherEventsRequest\x1a$.filesystem.GetWatcherEventsResponse\x12T\n\rRemoveWatcher\x12 .filesystem.RemoveWatcherRequest\x1a!.filesystem.RemoveWatcherResponseBi\n\x0e\x63om.filesystemB\x0f\x46ilesystemProtoP\x01\xa2\x02\x03\x46XX\xaa\x02\nFilesystem\xca\x02\nFilesystem\xe2\x02\x16\x46ilesystem\\GPBMetadata\xea\x02\nFilesystemb\x06proto3' ) _globals = globals() @@ -24,13 +29,13 @@ ) if not _descriptor._USE_C_DESCRIPTORS: _globals["DESCRIPTOR"]._loaded_options = None - _globals["DESCRIPTOR"]._serialized_options = ( - b"\n\016com.filesystemB\017FilesystemProtoP\001\242\002\003FXX\252\002\nFilesystem\312\002\nFilesystem\342\002\026Filesystem\\GPBMetadata\352\002\nFilesystem" - ) - _globals["_FILETYPE"]._serialized_start = 1272 - _globals["_FILETYPE"]._serialized_end = 1354 - _globals["_EVENTTYPE"]._serialized_start = 1357 - _globals["_EVENTTYPE"]._serialized_end = 1509 + _globals[ + "DESCRIPTOR" + ]._serialized_options = b"\n\016com.filesystemB\017FilesystemProtoP\001\242\002\003FXX\252\002\nFilesystem\312\002\nFilesystem\342\002\026Filesystem\\GPBMetadata\352\002\nFilesystem" + _globals["_FILETYPE"]._serialized_start = 1328 + _globals["_FILETYPE"]._serialized_end = 1410 + _globals["_EVENTTYPE"]._serialized_start = 1413 + _globals["_EVENTTYPE"]._serialized_end = 1565 _globals["_MOVEREQUEST"]._serialized_start = 43 _globals["_MOVEREQUEST"]._serialized_end = 114 _globals["_MOVERESPONSE"]._serialized_start = 116 @@ -63,16 +68,18 @@ _globals["_WATCHDIRRESPONSE_STARTEVENT"]._serialized_end = 985 _globals["_WATCHDIRRESPONSE_KEEPALIVE"]._serialized_start = 987 _globals["_WATCHDIRRESPONSE_KEEPALIVE"]._serialized_end = 998 - _globals["_WATCHDIRSTARTRESPONSE"]._serialized_start = 1009 - _globals["_WATCHDIRSTARTRESPONSE"]._serialized_end = 1063 - _globals["_WATCHDIRGETREQUEST"]._serialized_start = 1065 - _globals["_WATCHDIRGETREQUEST"]._serialized_end = 1116 - _globals["_WATCHDIRGETRESPONSE"]._serialized_start = 1118 - _globals["_WATCHDIRGETRESPONSE"]._serialized_end = 1192 - _globals["_WATCHDIRSTOPREQUEST"]._serialized_start = 1194 - _globals["_WATCHDIRSTOPREQUEST"]._serialized_end = 1246 - _globals["_WATCHDIRSTOPRESPONSE"]._serialized_start = 1248 - _globals["_WATCHDIRSTOPRESPONSE"]._serialized_end = 1270 - _globals["_FILESYSTEM"]._serialized_start = 1512 - _globals["_FILESYSTEM"]._serialized_end = 2160 + _globals["_CREATEWATCHERREQUEST"]._serialized_start = 1009 + _globals["_CREATEWATCHERREQUEST"]._serialized_end = 1051 + _globals["_CREATEWATCHERRESPONSE"]._serialized_start = 1053 + _globals["_CREATEWATCHERRESPONSE"]._serialized_end = 1107 + _globals["_GETWATCHEREVENTSREQUEST"]._serialized_start = 1109 + _globals["_GETWATCHEREVENTSREQUEST"]._serialized_end = 1165 + _globals["_GETWATCHEREVENTSRESPONSE"]._serialized_start = 1167 + _globals["_GETWATCHEREVENTSRESPONSE"]._serialized_end = 1246 + _globals["_REMOVEWATCHERREQUEST"]._serialized_start = 1248 + _globals["_REMOVEWATCHERREQUEST"]._serialized_end = 1301 + _globals["_REMOVEWATCHERRESPONSE"]._serialized_start = 1303 + _globals["_REMOVEWATCHERRESPONSE"]._serialized_end = 1326 + _globals["_FILESYSTEM"]._serialized_start = 1568 + _globals["_FILESYSTEM"]._serialized_end = 2239 # @@protoc_insertion_point(module_scope) diff --git a/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.pyi b/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.pyi index d90860292..a2208c060 100644 --- a/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.pyi +++ b/packages/python-sdk/e2b/envd/filesystem/filesystem_pb2.pyi @@ -155,19 +155,25 @@ class WatchDirResponse(_message.Message): keepalive: _Optional[_Union[WatchDirResponse.KeepAlive, _Mapping]] = ..., ) -> None: ... -class WatchDirStartResponse(_message.Message): +class CreateWatcherRequest(_message.Message): + __slots__ = ("path",) + PATH_FIELD_NUMBER: _ClassVar[int] + path: str + def __init__(self, path: _Optional[str] = ...) -> None: ... + +class CreateWatcherResponse(_message.Message): __slots__ = ("watcher_id",) WATCHER_ID_FIELD_NUMBER: _ClassVar[int] watcher_id: str def __init__(self, watcher_id: _Optional[str] = ...) -> None: ... -class WatchDirGetRequest(_message.Message): +class GetWatcherEventsRequest(_message.Message): __slots__ = ("watcher_id",) WATCHER_ID_FIELD_NUMBER: _ClassVar[int] watcher_id: str def __init__(self, watcher_id: _Optional[str] = ...) -> None: ... -class WatchDirGetResponse(_message.Message): +class GetWatcherEventsResponse(_message.Message): __slots__ = ("events",) EVENTS_FIELD_NUMBER: _ClassVar[int] events: _containers.RepeatedCompositeFieldContainer[FilesystemEvent] @@ -175,12 +181,12 @@ class WatchDirGetResponse(_message.Message): self, events: _Optional[_Iterable[_Union[FilesystemEvent, _Mapping]]] = ... ) -> None: ... -class WatchDirStopRequest(_message.Message): +class RemoveWatcherRequest(_message.Message): __slots__ = ("watcher_id",) WATCHER_ID_FIELD_NUMBER: _ClassVar[int] watcher_id: str def __init__(self, watcher_id: _Optional[str] = ...) -> None: ... -class WatchDirStopResponse(_message.Message): +class RemoveWatcherResponse(_message.Message): __slots__ = () def __init__(self) -> None: ... diff --git a/packages/python-sdk/e2b/envd/process/process_pb2.py b/packages/python-sdk/e2b/envd/process/process_pb2.py index 1674f451a..23c3081c7 100644 --- a/packages/python-sdk/e2b/envd/process/process_pb2.py +++ b/packages/python-sdk/e2b/envd/process/process_pb2.py @@ -1,13 +1,18 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE # source: process/process.proto # Protobuf Python Version: 5.27.3 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, 5, 27, 3, "", "process/process.proto" +) # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -22,9 +27,9 @@ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "process.process_pb2", _globals) if not _descriptor._USE_C_DESCRIPTORS: _globals["DESCRIPTOR"]._loaded_options = None - _globals["DESCRIPTOR"]._serialized_options = ( - b"\n\013com.processB\014ProcessProtoP\001\242\002\003PXX\252\002\007Process\312\002\007Process\342\002\023Process\\GPBMetadata\352\002\007Process" - ) + _globals[ + "DESCRIPTOR" + ]._serialized_options = b"\n\013com.processB\014ProcessProtoP\001\242\002\003PXX\252\002\007Process\312\002\007Process\342\002\023Process\\GPBMetadata\352\002\007Process" _globals["_PROCESSCONFIG_ENVSENTRY"]._loaded_options = None _globals["_PROCESSCONFIG_ENVSENTRY"]._serialized_options = b"8\001" _globals["_SIGNAL"]._serialized_start = 2316 diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py index f726b9e12..949e282fb 100644 --- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py +++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py @@ -52,7 +52,8 @@ async def read( format: Literal["text"] = "text", user: Username = "user", request_timeout: Optional[float] = None, - ) -> str: ... + ) -> str: + ... @overload async def read( @@ -61,7 +62,8 @@ async def read( format: Literal["bytes"], user: Username = "user", request_timeout: Optional[float] = None, - ) -> bytearray: ... + ) -> bytearray: + ... @overload async def read( @@ -70,7 +72,8 @@ async def read( format: Literal["stream"], user: Username = "user", request_timeout: Optional[float] = None, - ) -> AsyncIterator[bytes]: ... + ) -> AsyncIterator[bytes]: + ... async def read( self, diff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.py index 5a588ac8a..74627e297 100644 --- a/packages/python-sdk/e2b/sandbox_async/main.py +++ b/packages/python-sdk/e2b/sandbox_async/main.py @@ -253,7 +253,8 @@ async def __aexit__(self, exc_type, exc_value, traceback): await self.kill() @overload - async def kill(self, request_timeout: Optional[float] = None) -> bool: ... + async def kill(self, request_timeout: Optional[float] = None) -> bool: + ... @overload @staticmethod @@ -263,7 +264,8 @@ async def kill( domain: Optional[str] = None, debug: Optional[bool] = None, request_timeout: Optional[float] = None, - ) -> bool: ... + ) -> bool: + ... @class_method_variant("_cls_kill") async def kill(self, request_timeout: Optional[float] = None) -> bool: # type: ignore @@ -290,7 +292,8 @@ async def set_timeout( self, timeout: int, request_timeout: Optional[float] = None, - ) -> None: ... + ) -> None: + ... @overload @staticmethod @@ -301,7 +304,8 @@ async def set_timeout( domain: Optional[str] = None, debug: Optional[bool] = None, request_timeout: Optional[float] = None, - ) -> None: ... + ) -> None: + ... @class_method_variant("_cls_set_timeout") async def set_timeout( # type: ignore diff --git a/packages/python-sdk/e2b/sandbox_async/process/process.py b/packages/python-sdk/e2b/sandbox_async/process/process.py index b7c3fa741..4111fd4ef 100644 --- a/packages/python-sdk/e2b/sandbox_async/process/process.py +++ b/packages/python-sdk/e2b/sandbox_async/process/process.py @@ -137,7 +137,8 @@ async def run( on_stderr: Optional[OutputHandler[Stderr]] = None, timeout: Optional[float] = 60, request_timeout: Optional[float] = None, - ) -> ProcessResult: ... + ) -> ProcessResult: + ... @overload async def run( @@ -151,7 +152,8 @@ async def run( on_stderr: Optional[OutputHandler[Stderr]] = None, timeout: Optional[float] = 60, request_timeout: Optional[float] = None, - ) -> AsyncProcessHandle: ... + ) -> AsyncProcessHandle: + ... async def run( self, diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py index 13540112c..1aa176c30 100644 --- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py +++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py @@ -314,8 +314,8 @@ def watch_dir( :return: Watcher handle """ try: - r = self._rpc.watch_dir_start( - filesystem_pb2.WatchDirRequest(path=path), + r = self._rpc.create_watcher( + filesystem_pb2.CreateWatcherRequest(path=path), request_timeout=self._connection_config.get_request_timeout( request_timeout ), diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/watch_handle.py index bd3a0b3be..8f4fae891 100644 --- a/packages/python-sdk/e2b/sandbox_sync/filesystem/watch_handle.py +++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/watch_handle.py @@ -2,7 +2,10 @@ from e2b import SandboxException from e2b.envd.filesystem import filesystem_connect -from e2b.envd.filesystem.filesystem_pb2 import WatchDirStopRequest, WatchDirGetRequest +from e2b.envd.filesystem.filesystem_pb2 import ( + GetWatcherEventsRequest, + RemoveWatcherRequest, +) from e2b.envd.rpc import handle_rpc_exception from e2b.sandbox.filesystem.watch_handle import FilesystemEvent, map_event_type @@ -26,7 +29,7 @@ def stop(self): Stop watching the directory. After you stop the watcher you won't be able to get the events anymore. """ try: - self._rpc.watch_dir_stop(WatchDirStopRequest(watcher_id=self._watcher_id)) + self._rpc.remove_watcher(RemoveWatcherRequest(watcher_id=self._watcher_id)) except Exception as e: raise handle_rpc_exception(e) @@ -40,7 +43,9 @@ def get_new_events(self) -> List[FilesystemEvent]: raise SandboxException("The watcher is already stopped") try: - r = self._rpc.watch_dir_get(WatchDirGetRequest(watcher_id=self._watcher_id)) + r = self._rpc.get_watcher_events( + GetWatcherEventsRequest(watcher_id=self._watcher_id) + ) except Exception as e: raise handle_rpc_exception(e) diff --git a/spec/envd/filesystem/filesystem.proto b/spec/envd/filesystem/filesystem.proto index 873f77b4c..05694cb20 100644 --- a/spec/envd/filesystem/filesystem.proto +++ b/spec/envd/filesystem/filesystem.proto @@ -12,9 +12,9 @@ service Filesystem { rpc WatchDir(WatchDirRequest) returns (stream WatchDirResponse); // Non-streaming versions of WatchDir - rpc WatchDirStart(WatchDirRequest) returns (WatchDirStartResponse); - rpc WatchDirGet(WatchDirGetRequest) returns (WatchDirGetResponse); - rpc WatchDirStop(WatchDirStopRequest) returns (WatchDirStopResponse); + rpc CreateWatcher(CreateWatcherRequest) returns (CreateWatcherResponse); + rpc GetWatcherEvents(GetWatcherEventsRequest) returns (GetWatcherEventsResponse); + rpc RemoveWatcher(RemoveWatcherRequest) returns (RemoveWatcherResponse); } message MoveRequest { @@ -89,23 +89,27 @@ message WatchDirResponse { message KeepAlive {} } -message WatchDirStartResponse { +message CreateWatcherRequest { + string path = 1; +} + +message CreateWatcherResponse { string watcher_id = 1; } -message WatchDirGetRequest { +message GetWatcherEventsRequest { string watcher_id = 1; } -message WatchDirGetResponse { +message GetWatcherEventsResponse { repeated FilesystemEvent events = 1; } -message WatchDirStopRequest { +message RemoveWatcherRequest { string watcher_id = 1; } -message WatchDirStopResponse {} +message RemoveWatcherResponse {} enum EventType { EVENT_TYPE_UNSPECIFIED = 0;