gbox_sdk.wrapper.box package¶
Subpackages¶
- gbox_sdk.wrapper.box.android package
- Submodules
- gbox_sdk.wrapper.box.android.android module
- gbox_sdk.wrapper.box.android.app_manager module
- gbox_sdk.wrapper.box.android.app_operator module
- gbox_sdk.wrapper.box.android.pkg_manager module
- gbox_sdk.wrapper.box.android.pkg_operator module
- gbox_sdk.wrapper.box.android.types module
- Module contents
Submodules¶
gbox_sdk.wrapper.box.action module¶
- class gbox_sdk.wrapper.box.action.ActionAI¶
Bases:
ActionAIParams
Extends ActionAIParams for AI-based actions.
-
background:
str
¶
-
include_screenshot:
Annotated
[bool
]¶
-
instruction:
Required
[str
]¶
-
output_format:
Annotated
[Literal
['base64'
,'storageKey'
]]¶
-
screenshot_delay:
Annotated
[str
]¶
-
settings:
Settings
¶
-
background:
gbox_sdk.wrapper.box.base module¶
gbox_sdk.wrapper.box.browser module¶
gbox_sdk.wrapper.box.file_system module¶
gbox_sdk.wrapper.box.linux module¶
Module contents¶
- class gbox_sdk.wrapper.box.ActionOperator(client, box_id)¶
Bases:
object
Provides high-level action operations for a specific box using the GboxClient.
Methods correspond to various box actions such as click, drag, swipe, type, screenshot, etc.
- ai(body)¶
Perform an AI-powered action on the box.
- Return type:
Union
[AIActionScreenshotResult
,AIActionResult
]
- Args:
body: Either a string instruction or ActionAI parameters.
- Returns:
ActionAIResponse: The response from the AI action.
- click(body)¶
Perform a click action on the box.
- Return type:
- Args:
body (ActionClickParams): Parameters for the click action.
- Returns:
ActionClickResponse: The response from the click action.
- drag(body)¶
Perform a drag action on the box.
- Return type:
- Args:
body (ActionDragParams): Parameters for the drag action.
- Returns:
ActionDragResponse: The response from the drag action.
- move(body)¶
Move an element or pointer on the box.
- Return type:
- Args:
body (ActionMoveParams): Parameters for the move action.
- Returns:
ActionMoveResponse: The response from the move action.
- press_button(body)¶
Simulate a button press on the box.
- Return type:
- Args:
body (ActionPressButtonParams): Parameters for the button press action.
- Returns:
ActionPressButtonResponse: The response from the button press action.
- press_key(body)¶
Simulate a key press on the box.
- Return type:
- Args:
body (ActionPressKeyParams): Parameters for the key press action.
- Returns:
ActionPressKeyResponse: The response from the key press action.
- screen_rotation(body)¶
Rotate the screen of the box.
- Return type:
- Args:
body (ActionScreenRotationParams): Parameters for the screen rotation action.
- Returns:
ActionScreenRotationResponse: The response from the screen rotation action.
- screenshot(body=None)¶
Take a screenshot of the box.
- Return type:
- Args:
- body (Optional[ActionScreenshot]): Parameters for the screenshot action.
If not provided, defaults to base64 output format.
- Returns:
ActionScreenshotResponse: The response containing the screenshot data.
- Examples:
Take a screenshot and return base64 data: >>> response = action_operator.screenshot()
Take a screenshot and save to file: >>> response = action_operator.screenshot({“path”: “/path/to/screenshot.png”})
Take a screenshot with specific format: >>> response = action_operator.screenshot({“output_format”: “base64”})
- scroll(body)¶
Perform a scroll action on the box.
- Return type:
- Args:
body (ActionScrollParams): Parameters for the scroll action.
- Returns:
ActionScrollResponse: The response from the scroll action.
- swipe(body)¶
Perform a swipe action on the box.
- Return type:
- Args:
body (ActionSwipeParams): Parameters for the swipe action.
- Returns:
ActionSwipeResponse: The response from the swipe action.
- touch(body)¶
Simulate a touch action on the box.
- Return type:
- Args:
body (ActionTouchParams): Parameters for the touch action.
- Returns:
ActionTouchResponse: The response from the touch action.
- type(body)¶
Simulate typing text on the box.
- Return type:
- Args:
body (ActionTypeParams): Parameters for the type action.
- Returns:
ActionTypeResponse: The response from the type action.
- class gbox_sdk.wrapper.box.ActionScreenshot¶
Bases:
ActionScreenshotParams
Extends ActionScreenshotParams to optionally include a file path for saving the screenshot.
- Attributes:
path (Optional[str]): The file path where the screenshot will be saved.
-
output_format:
Annotated
[Literal
['base64'
,'storageKey'
]]¶
-
path:
Optional
[str
]¶
- class gbox_sdk.wrapper.box.AndroidAppOperator(client, box, data)¶
Bases:
object
Operator class for managing a specific Android app within a box.
Provides methods to open, restart, close, list activities, and backup the app.
- Attributes:
client (GboxClient): The API client used for communication. box (AndroidBox): The Android box data object. data (AndroidApp): The app data object.
- backup()¶
Backup the app.
- Return type:
BinaryAPIResponse
- Returns:
BinaryAPIResponse: The backup response containing binary data.
- close()¶
Close the app.
- Return type:
None
- list_activities()¶
List all activities of the app.
- Return type:
- Returns:
AndroidListActivitiesResponse: The response containing the list of activities.
- open(activity_name=None)¶
Open the app, optionally specifying an activity name.
- Return type:
None
- Args:
activity_name (str, optional): The activity name to open. Defaults to None.
- restart(activity_name=None)¶
Restart the app, optionally specifying an activity name.
- Return type:
None
- Args:
activity_name (str, optional): The activity name to restart. Defaults to None.
- class gbox_sdk.wrapper.box.AndroidBoxOperator(client, data)¶
Bases:
BaseBox
Operator class for managing Android boxes, providing access to app and package management functionalities.
- Attributes:
app (AndroidAppManager): Manager for Android app operations. pkg (AndroidPkgManager): Manager for Android package operations.
- class gbox_sdk.wrapper.box.AndroidPkgOperator(client, box, data)¶
Bases:
object
Operator class for managing a specific Android package within a box.
Provides methods to open, close, restart, list activities, and backup the package.
- Attributes:
client (GboxClient): The API client used for communication. box (AndroidBox): The Android box data object. data (AndroidGetResponse): The package data object.
- backup()¶
Backup the package.
- Return type:
BinaryAPIResponse
- Returns:
BinaryAPIResponse: The backup response containing binary data.
- close()¶
Close the package.
- Return type:
None
- list_activities()¶
List all activities of the package.
- Return type:
- Returns:
AndroidListActivitiesResponse: The response containing the list of activities.
- open(activity_name=None)¶
Open the package, optionally specifying an activity name.
- Return type:
None
- Args:
activity_name (str, optional): The activity name to open. Defaults to None.
- restart(activity_name=None)¶
Restart the package, optionally specifying an activity name.
- Return type:
None
- Args:
activity_name (str, optional): The activity name to restart. Defaults to None.
- class gbox_sdk.wrapper.box.BaseBox(client, data)¶
Bases:
object
Base class for box operations, providing common interfaces for box lifecycle and actions.
- Attributes:
client (GboxClient): The Gbox client instance used for API calls. data (Union[LinuxBox, AndroidBox]): The box data object. action (ActionOperator): Operator for box actions. fs (FileSystemOperator): Operator for file system actions. browser (BrowserOperator): Operator for browser actions.
- command(body)¶
Execute shell commands in the box.
- Return type:
- Args:
body (Union[BoxExecuteCommandsParams, str, List[str]]): The commands to execute or parameters object.
- Returns:
BoxExecuteCommandsResponse: The response containing the command execution result.
- live_view(body=None)¶
Get the live view URL for the box.
- Return type:
- Args:
body (BoxLiveViewURLParams): Parameters for live view URL.
- Returns:
BoxLiveViewURLResponse: The response containing the live view URL.
- run_code(body)¶
Run code in the box.
- Return type:
- Args:
body (Union[BoxRunCodeParams, str]): The code to run or parameters object.
- Returns:
BoxRunCodeResponse: The response containing the code execution result.
- start(body=None)¶
Start the box.
- Return type:
Self
- Args:
body (Optional[BoxStartParams]): Parameters for starting the box.
- Returns:
Self: The updated box instance for method chaining.
- stop(body=None)¶
Stop the box.
- Return type:
Self
- Args:
body (Optional[BoxStopParams]): Parameters for stopping the box.
- Returns:
Self: The updated box instance for method chaining.
- terminate(body=None)¶
Terminate the box.
- Return type:
Self
- Args:
body (Optional[BoxTerminateParams]): Parameters for terminating the box.
- Returns:
Self: The updated box instance for method chaining.
- web_terminal(body=None)¶
Get the web terminal URL for the box.
- Return type:
- Args:
body (BoxWebTerminalURLParams): Parameters for web terminal URL.
- Returns:
BoxWebTerminalURLResponse: The response containing the web terminal URL.
- class gbox_sdk.wrapper.box.BrowserOperator(client, box_id)¶
Bases:
object
Provides operations related to browser management for a specific box.
- Args:
client (GboxClient): The GboxClient instance used to interact with the API. box_id (str): The unique identifier of the box.
- cdp_url()¶
Get the Chrome DevTools Protocol (CDP) URL for the browser in the specified box.
- Return type:
str
- Returns:
str: The CDP URL for the browser.
- class gbox_sdk.wrapper.box.DirectoryOperator(client, box_id, data)¶
Bases:
object
Operator for directory operations within a box.
Provides methods to list and rename a directory.
- Args:
client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on. data (DataDir): The directory data.
- list(body=None)¶
List files and directories in this directory, returning operator objects.
- Return type:
List
[Union
[FileOperator
,DirectoryOperator
]]
- Args:
body (Optional[FListParams]): Parameters for listing. If None, uses the directory’s path.
- Returns:
List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.
- list_info(body=None)¶
Get detailed information about files and directories in this directory.
- Return type:
- Args:
body (Optional[FListParams]): Parameters for listing. If None, uses the directory’s path.
- Returns:
FListResponse: The response containing file/directory information.
- class gbox_sdk.wrapper.box.FileOperator(client, box_id, data)¶
Bases:
object
Operator for file operations within a box.
Provides methods to read, write, and rename a file.
- Args:
client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on. data (DataFile): The file data.
- read(body=None)¶
Read the content of this file.
- Return type:
- Args:
body (Optional[FReadParams]): Parameters for reading the file. If None, uses the file’s path.
- Returns:
FReadResponse: The response containing file content.
- rename(body)¶
Rename this file.
- Args:
body (FRenameParams): Parameters for renaming the file.
- Returns:
FRenameResponse: The response after renaming.
- write(body)¶
Write content to this file (text or binary).
- Return type:
- Args:
- body (Union[WriteFile, WriteFileByBinary]): Parameters for writing to the file.
Can be either WriteFile (for text content) or WriteFileByBinary (for binary content).
- Returns:
FWriteResponse: The response after writing.
- class gbox_sdk.wrapper.box.FileSystemOperator(client, box_id)¶
Bases:
object
Operator for file system operations within a box.
Provides methods to list, read, write, remove, check existence, rename, and retrieve file or directory information in a box.
- Args:
client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on.
- data_to_operator(data)¶
Convert a Data object to the corresponding operator.
- Return type:
Union
[FileOperator
,DirectoryOperator
]
- Args:
data (Optional[Data]): The data object to convert.
- Returns:
Union[FileOperator, DirectoryOperator]: The corresponding operator object.
- Raises:
ValueError: If data is None.
- exists(body)¶
Check if a file or directory exists.
- Return type:
Union
[ExistsFileResult
,NotExistsFileResult
]
- Args:
body (FExistsParams): Parameters for checking existence.
- Returns:
FExistsResponse: The response indicating existence.
- get(body)¶
Get an operator for a file or directory by its information.
- Return type:
Union
[FileOperator
,DirectoryOperator
]
- Args:
body (FInfoParams): Parameters for retrieving file or directory info.
- Returns:
Union[FileOperator, DirectoryOperator]: The corresponding operator object.
- list(body)¶
List files and directories at a given path or with given parameters, returning operator objects.
- Return type:
List
[Union
[FileOperator
,DirectoryOperator
]]
- Args:
body (Union[FListParams, str]): Path as a string or FListParams object.
- Returns:
List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.
- list_info(body)¶
Get detailed information about files and directories at a given path or with given parameters.
- Return type:
- Args:
body (Union[FListParams, str]): Path as a string or FListParams object.
- Returns:
FListResponse: The response containing file/directory information.
- read(body)¶
Read the content of a file.
- Return type:
- Args:
body (FReadParams): Parameters for reading the file.
- Returns:
FReadResponse: The response containing file content.
- remove(body)¶
Remove a file or directory.
- Return type:
- Args:
body (FRemoveParams): Parameters for removing the file or directory.
- Returns:
None
- rename(body)¶
Rename a file or directory.
- Args:
body (FRenameParams): Parameters for renaming.
- Returns:
FRenameResponse: The response after renaming.
- write(body)¶
Write content to a file (text or binary).
- Return type:
- Args:
- body (Union[WriteFile, WriteFileByBinary]): Parameters for writing to the file.
Can be either WriteFile (for text content) or WriteFileByBinary (for binary content).
- Returns:
FileOperator: The file operator for the written file.