gbox_sdk package

Subpackages

Module contents

exception gbox_sdk.APIConnectionError(*, message='Connection error.', request)

Bases: APIError

exception gbox_sdk.APIError(message, request, *, body)

Bases: GboxClientError

body: object | None
message: str
request: httpx.Request
exception gbox_sdk.APIResponseValidationError(response, body, *, message=None)

Bases: APIError

response: httpx.Response
status_code: int
exception gbox_sdk.APIStatusError(message, *, response, body)

Bases: APIError

Raised when an API response has a status code of 4xx or 5xx.

response: httpx.Response
status_code: int
exception gbox_sdk.APITimeoutError(request)

Bases: APIConnectionError

class gbox_sdk.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(instruction, *, background=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN, settings=NOT_GIVEN, on_action_start=None, on_action_end=None)

Perform an AI-powered action on the box.

Return type:

Union[AIActionScreenshotResult, AIActionResult]

Args:
instruction: Direct instruction of the UI action to perform (e.g., ‘click the login button’,

‘input username in the email field’, ‘scroll down’, ‘swipe left’)

background: The background of the UI action to perform. The purpose of background is to let

the action executor to understand the context of why the instruction is given including important previous actions and observations

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

settings: AI action settings

on_action_start: Callback function called when action starts on_action_end: Callback function called when action ends

Returns:

ActionAIResponse: The response from the AI action.

Example:
>>> response = myBox.action.ai("Click on the login button")
>>> response = myBox.action.ai(
...     instruction="Click on the login button",
...     background="The background of the action",
...     include_screenshot=True,
...     output_format="base64",
...     screenshot_delay="500ms",
...     settings={"disableActions": ["click"], "systemPrompt": "You are a helpful assistant"},
... )
ai_stream(instruction, *, background=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN, settings=NOT_GIVEN, on_action_start=None, on_action_end=None)

Perform an AI-powered action on the box with streaming support.

Return type:

Union[AIActionScreenshotResult, AIActionResult]

Args:
instruction: Direct instruction of the UI action to perform (e.g., ‘click the login button’,

‘input username in the email field’, ‘scroll down’, ‘swipe left’)

background: The background of the UI action to perform. The purpose of background is to let

the action executor to understand the context of why the instruction is given including important previous actions and observations

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

settings: AI action settings

on_action_start: Callback function called when action starts on_action_end: Callback function called when action ends

Returns:

ActionAIResponse: The response from the AI action.

Example:
>>> response = myBox.action.ai_stream(
...     instruction="Click on the login button",
...     on_action_start=lambda: print("Action started"),
...     on_action_end=lambda: print("Action ended"),
... )
click(*, x, y, button=NOT_GIVEN, double=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a click action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the click

y: Y coordinate of the click

button: Mouse button to click

double: Whether to perform a double click

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionClickResponse: The response from the click action.

Example:
>>> response = myBox.action.click(x=100, y=100)
drag(*, path=NOT_GIVEN, start=NOT_GIVEN, end=NOT_GIVEN, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a drag action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

path: Path of the drag action as a series of coordinates

end: Single point in a drag path

start: Single point in a drag path

duration: Duration to complete the movement from start to end coordinates

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionDragResponse: The response from the drag action.

Examples:

Simple drag from start to end: >>> response = myBox.action.drag(start={“x”: 100, “y”: 100}, end={“x”: 200, “y”: 200})

Advanced drag with path: >>> response = myBox.action.drag( … path=[ … {“x”: 100, “y”: 100}, … {“x”: 150, “y”: 150}, … {“x”: 200, “y”: 200}, … ] … )

extract(*, instruction, schema=NOT_GIVEN)

Extract data from the UI interface using a JSON schema.

Return type:

ActionExtractResponse

Args:

instruction: The instruction of the action to extract data from the UI interface

schema: JSON Schema defining the structure of data to extract. Supports object, array,

string, number, boolean types with validation rules.

Common use cases:

  • Extract text content: { “type”: “string” }

  • Extract structured data: { “type”: “object”, “properties”: {…} }

  • Extract lists: { “type”: “array”, “items”: {…} }

  • Extract with validation: Add constraints like “required”, “enum”, “pattern”, etc.

Returns:

ActionExtractResponse: The response containing the extracted data.

Example:
>>> response = myBox.action.extract(
...     instruction="Extract the user name from the profile",
...     schema={"type": "string"},
... )
long_press(*, x, y, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a long press action at specified coordinates for a specified duration. Useful for triggering context menus, drag operations, or other long-press interactions.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the long press

y: Y coordinate of the long press

duration: Duration to hold the press (e.g. ‘1s’, ‘500ms’)

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 1s

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

move(*, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Move an element or pointer on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate to move to

y: Y coordinate to move to

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionMoveResponse: The response from the move action.

Example:
>>> response = myBox.action.move(x=200, y=300)
press_button(*, buttons, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a button press on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

buttons: Button to press

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionPressButtonResponse: The response from the button press action.

Example:
>>> response = myBox.action.press_button(buttons=["power"])
press_key(*, keys, combination=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a key press on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:
keys: This is an array of keyboard keys to press. Supports cross-platform

compatibility.

combination: Whether to press keys as combination (simultaneously) or sequentially. When

true, all keys are pressed together as a shortcut (e.g., Ctrl+C). When false, keys are pressed one by one in sequence.

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionPressKeyResponse: The response from the key press action.

Example:
>>> response = myBox.action.press_key(keys=["enter"])
>>> response = myBox.action.press_key(keys=["control", "c"], combination=True)
screen_layout()

Get the current structured screen layout information.

Return type:

ActionScreenLayoutResponse

Returns:

ActionScreenLayoutResponse: The response containing the screen layout data.

Example:
>>> response = myBox.action.screen_layout()
screen_recording_start(duration)

Start recording the box screen.

Only one recording can be active at a time. If a recording is already in progress, starting a new recording will stop the previous one and keep only the latest recording.

Return type:

None

Args:
duration: Duration of the recording. Default is 30m, max is 30m. The recording will

automatically stop when the duration time is reached.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Maximum allowed: 30m

Example:
>>> response = myBox.action.screen_recording_start(duration="30m")
screen_recording_stop()

Stop recording the screen.

Return type:

ActionRecordingStopResponse

Returns:

ActionRecordingStopResponse: The response from the screen recording stop action.

Example:
>>> response = myBox.action.screen_recording_stop()
screen_rotation(orientation, *, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Rotate the screen orientation.

Note that even after rotating the screen, applications or system layouts may not automatically adapt to the gravity sensor changes, so visual changes may not always occur.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

orientation: Target screen orientation

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionScreenRotationResponse: The response from the screen rotation action.

Example:
>>> response = myBox.action.screen_rotation("landscapeLeft")
>>> response = myBox.action.screen_rotation(
...     orientation="landscapeLeft",
...     include_screenshot=True,
...     output_format="storageKey",
...     presigned_expires_in="30m",
...     screenshot_delay="500ms",
... )
screenshot(*, path=NOT_GIVEN, clip=NOT_GIVEN, output_format=NOT_GIVEN)

Take a screenshot of the box.

Return type:

ActionScreenshotResponse

Args:

path: The path to save the screenshot to.

clip: Clipping region for screenshot capture

output_format: Type of the URI. default is base64.

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(*, scroll_x, scroll_y, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a scroll action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

scroll_x: Horizontal scroll amount

scroll_y: Vertical scroll amount

x: X coordinate of the scroll position

y: Y coordinate of the scroll position

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionScrollResponse: The response from the scroll action.

Example:
>>> response = myBox.action.scroll(scroll_x=0, scroll_y=100, x=100, y=100)
swipe(*, direction=NOT_GIVEN, distance=NOT_GIVEN, start=NOT_GIVEN, end=NOT_GIVEN, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a swipe action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:
direction: Direction to swipe. The gesture will be performed from the center of the screen

towards this direction.

distance: Distance of the swipe in pixels. If not provided, the swipe will be performed

from the center of the screen to the screen edge

duration: Duration of the swipe

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionSwipeResponse: The response from the swipe action.

Example:
>>> response = myBox.action.swipe({"direction": "up"})
tap(*, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Tap action for Android devices using ADB input tap command

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the tap

y: Y coordinate of the tap

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

touch(*, points, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a touch action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

points: Array of touch points and their actions

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionTouchResponse: The response from the touch action.

Example:
>>> response = myBox.action.touch(points=[{"start": {"x": 0, "y": 0}}])
type(*, text, include_screenshot=NOT_GIVEN, mode=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate typing text on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

text: Text to type

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

mode: Text input mode: ‘append’ to add text to existing content, ‘replace’ to replace

all existing text

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionTypeResponse: The response from the type action.

Example:
>>> response = myBox.action.type(text="Hello, World!")
class gbox_sdk.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.

clip: Clip
output_format: Annotated[Literal['base64', 'storageKey']]
path: Optional[str]
class gbox_sdk.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.

Examples:
>>> box.app.backup()
close()

Close the app.

Return type:

None

Examples:
>>> box.app.close()
list_activities()

List all activities of the app.

Return type:

AndroidListActivitiesResponse

Returns:

AndroidListActivitiesResponse: The response containing the list of activities.

Examples:
>>> box.app.list_activities()
open(activity_name=NOT_GIVEN)

Open the app, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.app.open()
>>> box.app.open("com.example.app.MainActivity")
restart(activity_name=NOT_GIVEN)

Restart the app, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.app.restart()
>>> box.app.restart("com.example.app.MainActivity")
class gbox_sdk.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.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.

Examples:
>>> box.pkg.backup()
close()

Close the package.

Return type:

None

list_activities()

List all activities of the package.

Return type:

AndroidListActivitiesResponse

Returns:

AndroidListActivitiesResponse: The response containing the list of activities.

Examples:
>>> box.pkg.list_activities()
open(activity_name=None)

Open the package, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.pkg.open()
>>> box.pkg.open("com.example.app.MainActivity")
restart(activity_name=None)

Restart the package, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.pkg.restart()
>>> box.pkg.restart("com.example.app.MainActivity")
gbox_sdk.AsyncClient

alias of AsyncGboxClient

class gbox_sdk.AsyncGboxClient(*, api_key=None, environment=NOT_GIVEN, base_url=NOT_GIVEN, timeout=NOT_GIVEN, max_retries=0, default_headers=None, default_query=None, http_client=None, _strict_response_validation=False)

Bases: AsyncAPIClient

api_key: str
property auth_headers: dict[str, str]
copy(*, api_key=None, environment=None, base_url=None, timeout=NOT_GIVEN, http_client=None, max_retries=NOT_GIVEN, default_headers=None, set_default_headers=None, default_query=None, set_default_query=None, _extra_kwargs={})

Create a new client instance re-using the same options given to the current client with optional overriding.

Return type:

Self

property default_headers: dict[str, str | Omit]
property qs: Querystring
v1: v1.AsyncV1Resource
with_options(*, api_key=None, environment=None, base_url=None, timeout=NOT_GIVEN, http_client=None, max_retries=NOT_GIVEN, default_headers=None, set_default_headers=None, default_query=None, set_default_query=None, _extra_kwargs={})

Create a new client instance re-using the same options given to the current client with optional overriding.

Return type:

Self

with_raw_response: AsyncGboxClientWithRawResponse
with_streaming_response: AsyncGboxClientWithStreamedResponse
class gbox_sdk.AsyncStream(*, cast_to, response, client)

Bases: Generic[_T]

Provides the core interface to iterate over an asynchronous stream response.

async close()

Close the response and release the connection.

Automatically called if the response body is read to completion.

Return type:

None

response: httpx.Response
exception gbox_sdk.AuthenticationError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[401] = 401
exception gbox_sdk.BadRequestError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[400] = 400
class gbox_sdk.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(commands, on_stdout=None, on_stderr=None, envs=NOT_GIVEN, api_timeout=NOT_GIVEN, working_dir=NOT_GIVEN)

Execute shell commands in the box.

Return type:

Union[BoxExecuteCommandsResponse, WebSocketResult]

Args:

commands: The command to run. Can be a single string or an array of strings

envs: The environment variables to run the command

api_timeout: The timeout of the command. If the command times out, the exit code will be 124.

For example: ‘timeout 5s sleep 10s’ will result in exit code 124.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30s

working_dir: The working directory of the command. It not provided, the command will be run

in the box.config.workingDir directory.

on_stdout: Callback for stdout.

on_stderr: Callback for stderr.

Returns:

Union[BoxExecuteCommandsResponse, WebSocketResult]: The response containing the command execution result.

Example:
>>> box.command(commands=["ls", "-l"], on_stdout=lambda x: print(x), on_stderr=lambda x: print(x))
display()

Retrieve the current display properties for a running box.

This endpoint provides details about the box’s screen resolution, orientation, and other visual properties

Return type:

BoxDisplayResponse

Returns:

BoxDisplayResponse: The response containing the display properties.

Example:
>>> box.display()
live_view(*, expires_in=NOT_GIVEN)

Get the live view URL for the box.

Return type:

BoxLiveViewURLResponse

Args:

expires_in: The duration for the live view URL to be valid.

Returns:

BoxLiveViewURLResponse: The response containing the live view URL.

run_code(code, argv=NOT_GIVEN, envs=NOT_GIVEN, language=NOT_GIVEN, api_timeout=NOT_GIVEN, working_dir=NOT_GIVEN, on_stdout=None, on_stderr=None)

Run code in the box.

Return type:

Union[BoxRunCodeResponse, WebSocketResult]

Args:

code: The code to run

argv: The arguments to run the code. For example, if you want to run “python index.py

–help”, you should pass [”–help”] as arguments.

envs: The environment variables to run the code

language: The language of the code.

api_timeout: The timeout of the code execution. If the code execution times out, the exit

code will be 124.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30s

working_dir: The working directory of the code. It not provided, the code will be run in the

box.config.workingDir directory.

on_stdout: Callback for stdout.

on_stderr: Callback for stderr.

Returns:

Union[BoxRunCodeResponse, WebSocketResult]: The response containing the code execution result.

Example:
>>> box.run_code(
...     code="print('Hello, World!')",
...     language="python",
...     on_stdout=lambda x: print(x),
...     on_stderr=lambda x: print(x),
... )
start(*, wait=NOT_GIVEN)

Start the box.

Return type:

Self

Args:

wait: Whether to wait for the box to start.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.start()
>>> box.start(wait=True)
stop(*, wait=NOT_GIVEN)

Stop the box.

Return type:

Self

Args:

wait: Whether to wait for the box to stop.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.stop()
>>> box.stop(wait=True)
terminate(*, wait=NOT_GIVEN)

Terminate the box.

Return type:

Self

Args:

wait: Whether to wait for the box to terminate.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.terminate()
>>> box.terminate(wait=True)
web_terminal(*, expires_in=NOT_GIVEN)

Get the web terminal URL for the box.

Return type:

BoxWebTerminalURLResponse

Args:

body (BoxWebTerminalURLParams): Parameters for web terminal URL.

Returns:

BoxWebTerminalURLResponse: The response containing the web terminal URL.

class gbox_sdk.BaseModel(**data)

Bases: BaseModel

classmethod construct(_fields_set=None, **values)
Return type:

TypeVar(ModelT, bound= BaseModel)

model_config: ClassVar[ConfigDict] = {'defer_build': True, 'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod model_construct(_fields_set=None, **values)

Creates a new instance of the Model class with validated data.

Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.

Return type:

TypeVar(ModelT, bound= BaseModel)

!!! note

model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.

Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,

this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.

values: Trusted or pre-validated data dictionary.

Returns:

A new instance of the Model class with validated data.

to_dict(*, mode='python', use_api_names=True, exclude_unset=True, exclude_defaults=False, exclude_none=False, warnings=True)

Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

By default, fields that were not set by the API will not be included, and keys will match the API response, not the property names from the model.

For example, if the API responds with “fooBar”: true but we’ve defined a foo_bar: bool property, the output will use the “fooBar” key (unless use_api_names=False is passed).

Return type:

dict[str, object]

Args:
mode:

If mode is ‘json’, the dictionary will only contain JSON serializable types. e.g. datetime will be turned into a string, “2024-3-22T18:11:19.117000Z”. If mode is ‘python’, the dictionary may contain any Python objects. e.g. datetime(2024, 3, 22)

use_api_names: Whether to use the key that the API responded with or the property name. Defaults to True. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value from the output. exclude_none: Whether to exclude fields that have a value of None from the output. warnings: Whether to log warnings when invalid fields are encountered. This is only supported in Pydantic v2.

to_json(*, indent=2, use_api_names=True, exclude_unset=True, exclude_defaults=False, exclude_none=False, warnings=True)

Generates a JSON string representing this model as it would be received from or sent to the API (but with indentation).

By default, fields that were not set by the API will not be included, and keys will match the API response, not the property names from the model.

For example, if the API responds with “fooBar”: true but we’ve defined a foo_bar: bool property, the output will use the “fooBar” key (unless use_api_names=False is passed).

Return type:

str

Args:

indent: Indentation to use in the JSON output. If None is passed, the output will be compact. Defaults to 2 use_api_names: Whether to use the key that the API responded with or the property name. Defaults to True. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that have the default value. exclude_none: Whether to exclude fields that have a value of None. warnings: Whether to show any warnings that occurred during serialization. This is only supported in Pydantic v2.

class gbox_sdk.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.

Example:
>>> box.browser.cdp_url()
close_tab(tab_id)

Close a specific browser tab identified by its id.

This endpoint will permanently close the tab and free up the associated resources. After closing a tab, the ids of subsequent tabs may change.

Return type:

BrowserCloseTabResponse

Args:

tab_id: The tab id

Example:
>>> box.browser.close_tab("1")
list_tab()

Retrieve a comprehensive list of all currently open browser tabs in the specified box. This endpoint returns detailed information about each tab including its id, title, current URL, and favicon. The returned id can be used for subsequent operations like navigation, closing, or updating tabs. This is essential for managing multiple browser sessions and understanding the current state of the browser environment.

Return type:

List[BrowserTabOperator]

Returns:

list: A list of tab objects. BrowserTabOperator

Example:
>>> box.browser.list_tab()
list_tab_info()

Retrieve a comprehensive list of all currently open browser tabs in the specified box. This endpoint returns detailed information about each tab including its id, title, current URL, and favicon. The returned id can be used for subsequent operations like navigation, closing, or updating tabs. This is essential for managing multiple browser sessions and understanding the current state of the browser environment.

Return type:

BrowserGetTabsResponse

Returns:

BrowserGetTabsResponse: The list of tab information.

Example:
>>> box.browser.list_tab_info()
open_tab(url)

Create and open a new browser tab with the specified URL.

This endpoint will navigate to the provided URL and return the new tab’s information including its assigned id, loaded title, final URL (after any redirects), and favicon. The returned tab id can be used for future operations on this specific tab. The browser will attempt to load the page and will wait for the DOM content to be loaded before returning the response. If the URL is invalid or unreachable, an error will be returned.

Return type:

BrowserOpenTabResponse

Args:

url: The tab url

Example:
>>> box.browser.open_tab("https://www.google.com")
switch_tab(tab_id)

Switch to a specific browser tab by bringing it to the foreground (making it the active/frontmost tab). This operation sets the specified tab as the currently active tab without changing its URL or content. The tab will receive focus and become visible to the user. This is useful for managing multiple browser sessions and controlling which tab is currently in focus.

Return type:

BrowserSwitchTabResponse

Args:

tab_id: The tab id

Example:
>>> box.browser.switch_tab("1")
update_tab(*, tab_id, url)

Navigate an existing browser tab to a new URL.

This endpoint updates the specified tab by navigating it to the provided URL and returns the updated tab information. The browser will wait for the DOM content to be loaded before returning the response. If the navigation fails due to an invalid URL or network issues, an error will be returned. The updated tab information will include the new title, final URL (after any redirects), and favicon from the new page.

Return type:

BrowserUpdateTabResponse

Args:

tab_id: The tab id url: The tab new url

Example:
>>> box.browser.update_tab(tab_id="1", url="https://www.google.com")
gbox_sdk.Client

alias of GboxClient

exception gbox_sdk.ConflictError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[409] = 409
gbox_sdk.DefaultAioHttpClient

alias of _DefaultAioHttpClient

gbox_sdk.DefaultAsyncHttpxClient

alias of _DefaultAsyncHttpxClient

gbox_sdk.DefaultHttpxClient

alias of _DefaultHttpxClient

class gbox_sdk.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(*, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

List files and directories in this directory, returning operator objects.

Return type:

List[Union[FileOperator, DirectoryOperator]]

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.

Example:
>>> box.file_system.list(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list("/path/to/directory")
list_info(*, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

Get detailed information about files and directories in this directory.

Return type:

FListResponse

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FListResponse: The response containing file/directory information.

Example:
>>> box.file_system.list_info(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list_info("/path/to/directory")
rename(*, new_path, working_dir=NOT_GIVEN)

Rename this directory.

Return type:

Union[File, Dir]

Args:
new_path: New path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the newPath already exists, the rename will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(
...     old_path="/path/to/old/file", new_path="/path/to/new/file", working_dir="/path/to/working_dir"
... )
>>> box.file_system.rename("/path/to/old/file", "/path/to/new/file")
class gbox_sdk.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(*, working_dir=NOT_GIVEN)

Read the content of this file.

Return type:

FReadResponse

Args:

working_dir: The working directory to read the file from.

Returns:

FReadResponse: The response containing file content.

Example:
>>> box.file_system.read(working_dir="/path/to/working_dir")
>>> box.file_system.read()
rename(new_path, *, working_dir=NOT_GIVEN)

Rename this file.

Return type:

Union[File, Dir]

Args:

new_path: The new path of the file. working_dir: The working directory to rename the file in.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(new_path="/path/to/new/file", working_dir="/path/to/working_dir")
write(content, *, working_dir=NOT_GIVEN)

Write content to this file (text or binary).

Return type:

FWriteResponse

Args:

content: The content to write to the file. working_dir: The working directory to write the file to.

Returns:

FWriteResponse: The response after writing.

Example:
>>> box.file_system.write(content="Hello, World!", path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.write("Hello, World!")
class gbox_sdk.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.

exists(path, *, working_dir=NOT_GIVEN)

Check if a file or directory exists.

Return type:

Union[ExistsFileResult, NotExistsFileResult]

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FExistsResponse: The response indicating existence.

Example:
>>> box.file_system.exists(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.exists("/path/to/file")
get(path, *, working_dir=NOT_GIVEN)

Get an operator for a file or directory by its information.

Return type:

Union[FileOperator, DirectoryOperator]

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

Union[FileOperator, DirectoryOperator]: The corresponding operator object.

Example:
>>> box.file_system.get(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.get("/path/to/file")
list(path, *, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

List files and directories at a given path or with given parameters, returning operator objects.

Return type:

List[Union[FileOperator, DirectoryOperator]]

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.

Example:
>>> box.file_system.list(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list("/path/to/directory")
list_info(path, *, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

Get detailed information about files and directories at a given path or with given parameters.

Return type:

FListResponse

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FListResponse: The response containing file/directory information.

Example:
>>> box.file_system.list_info(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list_info("/path/to/directory")
read(path, *, working_dir=NOT_GIVEN)

Read the content of a file.

Return type:

FReadResponse

Args:
path: Target path in the box. If the path does not start with ‘/’, the file will be

read from the working directory.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FReadResponse: The response containing file content.

Example:
>>> box.file_system.read(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.read("/path/to/file")
remove(path, *, working_dir=NOT_GIVEN)

Remove a file or directory.

Return type:

FRemoveResponse

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRemoveResponse: The response after removing the file or directory.

Example:
>>> box.file_system.remove(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.remove("/path/to/file")
rename(*, old_path, new_path, working_dir=NOT_GIVEN)

Rename a file or directory.

Return type:

Union[File, Dir]

Args:
new_path: New path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the newPath already exists, the rename will fail.

old_path: Old path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the oldPath does not exist, the rename will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(
...     old_path="/path/to/old/file", new_path="/path/to/new/file", working_dir="/path/to/working_dir"
... )
write(*, content, path, working_dir=NOT_GIVEN)

Write content to a file (text or binary).

Return type:

FileOperator

Args:

content: Content of the file (Max size: 512MB)

path: Target path in the box. If the path does not start with ‘/’, the file will be

written relative to the working directory. Creates necessary directories in the path if they don’t exist. If the target path already exists, the write will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FileOperator: The file operator for the written file.

Example:
>>> box.file_system.write(content="Hello, World!", path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.write(content="Hello, World!", path="/path/to/file")
class gbox_sdk.GboxClient(*, api_key=None, environment=NOT_GIVEN, base_url=NOT_GIVEN, timeout=NOT_GIVEN, max_retries=0, default_headers=None, default_query=None, http_client=None, _strict_response_validation=False)

Bases: SyncAPIClient

api_key: str
property auth_headers: dict[str, str]
copy(*, api_key=None, environment=None, base_url=None, timeout=NOT_GIVEN, http_client=None, max_retries=NOT_GIVEN, default_headers=None, set_default_headers=None, default_query=None, set_default_query=None, _extra_kwargs={})

Create a new client instance re-using the same options given to the current client with optional overriding.

Return type:

Self

property default_headers: dict[str, str | Omit]
property qs: Querystring
v1: v1.V1Resource
with_options(*, api_key=None, environment=None, base_url=None, timeout=NOT_GIVEN, http_client=None, max_retries=NOT_GIVEN, default_headers=None, set_default_headers=None, default_query=None, set_default_query=None, _extra_kwargs={})

Create a new client instance re-using the same options given to the current client with optional overriding.

Return type:

Self

with_raw_response: GboxClientWithRawResponse
with_streaming_response: GboxClientWithStreamedResponse
exception gbox_sdk.GboxClientError

Bases: Exception

class gbox_sdk.GboxSDK(*, api_key=None, base_url=None, timeout=NOT_GIVEN, max_retries=None, default_headers=None, default_query=None, http_client=None, _strict_response_validation=None)

Bases: object

GboxSDK provides a high-level interface for managing and operating Gbox containers (boxes).

This SDK allows users to create, list, retrieve, and terminate both Android and Linux boxes, and provides operator objects for further box-specific operations. It wraps the lower-level GboxClient and exposes convenient methods for common workflows.

Attributes:

client (GboxClient): The underlying client used for API communication.

Examples:

Initialize the SDK: ```python from gbox_sdk.wrapper import GboxSDK

# Initialize the SDK sdk = GboxSDK(api_key=”your-api-key”) ```

Create boxes using the unified create method: ```python # Create an Android box android_box = sdk.create(type=”android”, config={“labels”: {“env”: “test”}})

# Create a Linux box linux_box = sdk.create(type=”linux”, config={“envs”: {“PYTHON_VERSION”: “3.9”}}) ```

List and manage boxes: ```python # List all boxes boxes = sdk.list()

# Get a specific box box = sdk.get(box_id=”box_id”)

# Terminate a box sdk.terminate(box_id=”box_id”) ```

create(*, type, config=NOT_GIVEN, wait=NOT_GIVEN, timeout=NOT_GIVEN)

Create a new box and return its operator.

This method provides a unified interface for creating both Android and Linux boxes. The box type is determined by the ‘type’ parameter.

Return type:

Union[AndroidBoxOperator, LinuxBoxOperator]

Args:

type: The type of box to create, either ‘android’ or ‘linux’. config: Configuration for the box (optional). wait: Whether to wait for the box operation to complete (optional). timeout: Timeout for the box operation (optional).

Returns:

BoxOperator: Operator for the created box (AndroidBoxOperator or LinuxBoxOperator).

Raises:

ValueError: If an unsupported box type is provided.

Examples:

Create an Android box: `python android_box = sdk.create(type="android", config={"labels": {"env": "test"}}) `

Create a Linux box: `python linux_box = sdk.create(type="linux", config={"envs": {"PYTHON_VERSION": "3.9"}}) `

get(box_id)

Retrieve a specific box and return its operator object.

Return type:

Union[AndroidBoxOperator, LinuxBoxOperator]

Args:

box_id (str): The ID of the box to retrieve.

Returns:

BoxOperator: Operator object for the specified box.

Example:

`python box = sdk.get("975fed9f-bb28-4718-a2c5-e01f72864bd1") box = sdk.get(box_id="975fed9f-bb28-4718-a2c5-e01f72864bd1") `

get_info(box_id)

Retrieve detailed information for a specific box.

Return type:

Union[LinuxBox, AndroidBox]

Args:

box_id (str): The ID of the box to retrieve.

Returns:

BoxRetrieveResponse: Detailed information about the box.

Example:

`python box_info = sdk.get("975fed9f-bb28-4718-a2c5-e01f72864bd1") box_info = sdk.get_info(box_id="975fed9f-bb28-4718-a2c5-e01f72864bd1") `

list(*, device_type=NOT_GIVEN, labels=NOT_GIVEN, page=NOT_GIVEN, page_size=NOT_GIVEN, status=NOT_GIVEN, type=NOT_GIVEN)

List all boxes matching the query and return their operator objects.

Return type:

BoxListOperatorResponse

Args:

device_type: Filter boxes by their device type (virtual, physical) labels: Filter boxes by their labels. page: Page number page_size: Page size status: Filter boxes by their current status (pending, running, stopped, error, terminated, all). Must be an array of statuses. Use ‘all’ to get boxes with any status. type: Filter boxes by their type (linux, android, all). Must be an array of types. Use ‘all’ to get boxes of any type.

Returns:

BoxListOperatorResponse: Response containing operator objects and pagination info.

Examples:

```python # List all boxes boxes = sdk.list()

# List with pagination boxes = sdk.list(page=1, page_size=10) ```

list_info(*, device_type=NOT_GIVEN, labels=NOT_GIVEN, page=NOT_GIVEN, page_size=NOT_GIVEN, status=NOT_GIVEN, type=NOT_GIVEN)

List information of all boxes matching the query.

Return type:

BoxListResponse

Args:

device_type: Filter boxes by their device type (virtual, physical) labels: Filter boxes by their labels. page: Page number page_size: Page size status: Filter boxes by their current status (pending, running, stopped, error, terminated, all). Must be an array of statuses. Use ‘all’ to get boxes with any status. type: Filter boxes by their type (linux, android, all). Must be an array of types. Use ‘all’ to get boxes of any type.

Returns:

BoxListResponse: Response containing box information.

Examples:

```python # List all boxes boxes = sdk.list_info()

# List with pagination boxes = sdk.list_info(page=1, page_size=10) ```

terminate(box_id, *, wait=NOT_GIVEN)

Terminate a specific box.

Return type:

None

Args:

box_id (str): The ID of the box to terminate. wait: Whether to wait for the box operation to complete (optional).

Example:

`python sdk.terminate("975fed9f-bb28-4718-a2c5-e01f72864bd1") sdk.terminate(box_id="975fed9f-bb28-4718-a2c5-e01f72864bd1") `

exception gbox_sdk.InternalServerError(message, *, response, body)

Bases: APIStatusError

class gbox_sdk.LinuxBoxOperator(client, data)

Bases: BaseBox

Operator class for managing Linux boxes via the Gbox SDK. Provides an interface to interact with and control Linux-based boxes.

class gbox_sdk.NoneType

Bases: object

The type of the None singleton.

exception gbox_sdk.NotFoundError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[404] = 404
class gbox_sdk.NotGiven

Bases: object

A sentinel singleton class used to distinguish omitted keyword arguments from those passed in with the value None (which may have different behavior).

For example:

```py def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: …

get(timeout=1) # 1s timeout get(timeout=None) # No timeout get() # Default timeout behavior, which may not be statically known at the method definition. ```

class gbox_sdk.Omit

Bases: object

In certain situations you need to be able to represent a case where a default value has to be explicitly removed and None is not an appropriate substitute, for example:

``py # as the default `Content-Type header is application/json that will be sent client.post(“/upload/files”, files={“file”: b”my raw file content”})

# you can’t explicitly override the header as it has to be dynamically generated # to look something like: ‘multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983’ client.post(…, headers={“Content-Type”: “multipart/form-data”})

# instead you can remove the default application/json header by passing Omit client.post(…, headers={“Content-Type”: Omit()}) ```

exception gbox_sdk.PermissionDeniedError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[403] = 403
exception gbox_sdk.RateLimitError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[429] = 429
class gbox_sdk.RequestOptions

Bases: TypedDict

extra_json: Mapping[str, object]
follow_redirects: bool
headers: Mapping[str, Union[str, Omit]]
idempotency_key: str
max_retries: int
params: Mapping[str, object]
timeout: float | Timeout | None
class gbox_sdk.Stream(*, cast_to, response, client)

Bases: Generic[_T]

Provides the core interface to iterate over a synchronous stream response.

close()

Close the response and release the connection.

Automatically called if the response body is read to completion.

Return type:

None

response: httpx.Response
class gbox_sdk.Timeout(timeout=<httpx._config.UnsetType object>, *, connect=<httpx._config.UnsetType object>, read=<httpx._config.UnsetType object>, write=<httpx._config.UnsetType object>, pool=<httpx._config.UnsetType object>)

Bases: object

Timeout configuration.

Usage:

Timeout(None) # No timeouts. Timeout(5.0) # 5s timeout on all operations. Timeout(None, connect=5.0) # 5s timeout on connect, no other timeouts. Timeout(5.0, connect=10.0) # 10s timeout on connect. 5s timeout elsewhere. Timeout(5.0, pool=None) # No timeout on acquiring connection from pool.

# 5s timeout elsewhere.

as_dict()
Return type:

dict[str, float | None]

gbox_sdk.Transport

alias of BaseTransport

exception gbox_sdk.UnprocessableEntityError(message, *, response, body)

Bases: APIStatusError

status_code: Literal[422] = 422
gbox_sdk.file_from_path(path)
Return type:

Union[IO[bytes], bytes, PathLike, Tuple[Optional[str], Union[IO[bytes], bytes, PathLike]], Tuple[Optional[str], Union[IO[bytes], bytes, PathLike], Optional[str]], Tuple[Optional[str], Union[IO[bytes], bytes, PathLike], Optional[str], Mapping[str, str]]]