forked from alibaba/ROCK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.py
More file actions
66 lines (42 loc) · 1.79 KB
/
Copy pathrequest.py
File metadata and controls
66 lines (42 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from typing import Annotated, Literal
from pydantic import BaseModel, Field
class Command(BaseModel):
session_type: Literal["bash"] = "bash"
command: str | list[str]
class CreateBashSessionRequest(BaseModel):
session_type: Literal["bash"] = "bash"
session: str = "default"
startup_source: list[str] = []
env_enable: bool = False
env: dict[str, str] | None = Field(default=None)
CreateSessionRequest = Annotated[CreateBashSessionRequest, Field(discriminator="session_type")]
"""Union type for all create session requests. Do not use this directly."""
class BashAction(BaseModel):
action_type: Literal["bash"] = "bash"
command: str
session: str = "default"
timeout: float | None = None
check: Literal["silent", "raise", "ignore"] = "raise"
Action = Annotated[BashAction, Field(discriminator="action_type")]
class WriteFileRequest(BaseModel):
content: str
path: str
class CloseBashSessionRequest(BaseModel):
session_type: Literal["bash"] = "bash"
session: str = "default"
CloseSessionRequest = Annotated[CloseBashSessionRequest, Field(discriminator="session_type")]
"""Union type for all close session requests. Do not use this directly."""
class ReadFileRequest(BaseModel):
path: str
"""File path to read from."""
encoding: str | None = None
"""Text encoding to use when reading the file. None uses default encoding.
This corresponds to the `encoding` parameter of `Path.read_text()`."""
errors: str | None = None
"""Error handling strategy when reading the file. None uses default handling.
This corresponds to the `errors` parameter of `Path.read_text()`."""
class UploadRequest(BaseModel):
source_path: str
"""Local file path to upload from."""
target_path: str
"""Remote file path to upload to."""