cyberdesk 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cyberdesk might be problematic. Click here for more details.
- cyberdesk-0.2.1/LICENSE +21 -0
- cyberdesk-0.2.1/PKG-INFO +137 -0
- cyberdesk-0.2.1/README.md +122 -0
- cyberdesk-0.2.1/cyberdesk/__init__.py +1 -0
- cyberdesk-0.2.1/cyberdesk/client.py +108 -0
- cyberdesk-0.2.1/cyberdesk.egg-info/PKG-INFO +137 -0
- cyberdesk-0.2.1/cyberdesk.egg-info/SOURCES.txt +10 -0
- cyberdesk-0.2.1/cyberdesk.egg-info/dependency_links.txt +1 -0
- cyberdesk-0.2.1/cyberdesk.egg-info/requires.txt +6 -0
- cyberdesk-0.2.1/cyberdesk.egg-info/top_level.txt +1 -0
- cyberdesk-0.2.1/pyproject.toml +24 -0
- cyberdesk-0.2.1/setup.cfg +4 -0
cyberdesk-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cyberdesk Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
cyberdesk-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cyberdesk
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: The official Python SDK for Cyberdesk
|
|
5
|
+
Author-email: Cyberdesk Team <dev@cyberdesk.io>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: openapi-python-client; extra == "dev"
|
|
12
|
+
Requires-Dist: build; extra == "dev"
|
|
13
|
+
Requires-Dist: twine; extra == "dev"
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# cyberdesk
|
|
17
|
+
|
|
18
|
+
[](https://badge.fury.io/py/cyberdesk)
|
|
19
|
+
|
|
20
|
+
The official Python SDK for Cyberdesk.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install cyberdesk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
First, create a Cyberdesk client instance with your API key:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from cyberdesk import CyberdeskClient
|
|
34
|
+
|
|
35
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Launch a Desktop
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
|
|
44
|
+
|
|
45
|
+
# Error handling example
|
|
46
|
+
if hasattr(result, 'error') and result.error:
|
|
47
|
+
raise Exception('Failed to launch desktop: ' + str(result.error))
|
|
48
|
+
|
|
49
|
+
# Success
|
|
50
|
+
if hasattr(result, 'id'):
|
|
51
|
+
desktop_id = result.id
|
|
52
|
+
print('Launched desktop with ID:', desktop_id)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Get Desktop Info
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
info = client.get_desktop("your-desktop-id")
|
|
61
|
+
|
|
62
|
+
if hasattr(info, 'error') and info.error:
|
|
63
|
+
raise Exception('Failed to get desktop info: ' + str(info.error))
|
|
64
|
+
|
|
65
|
+
print('Desktop info:', info)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Perform a Computer Action (e.g., Mouse Click)
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
action_result = client.execute_computer_action(
|
|
74
|
+
"your-desktop-id",
|
|
75
|
+
{
|
|
76
|
+
"type": "click_mouse",
|
|
77
|
+
"x": 100,
|
|
78
|
+
"y": 150
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if hasattr(action_result, 'error') and action_result.error:
|
|
83
|
+
raise Exception('Action failed: ' + str(action_result.error))
|
|
84
|
+
|
|
85
|
+
print('Action result:', action_result)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### Run a Bash Command
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
bash_result = client.execute_bash_action(
|
|
94
|
+
"your-desktop-id",
|
|
95
|
+
"echo Hello, world!"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if hasattr(bash_result, 'error') and bash_result.error:
|
|
99
|
+
raise Exception('Bash command failed: ' + str(bash_result.error))
|
|
100
|
+
|
|
101
|
+
print('Bash output:', getattr(bash_result, 'output', bash_result))
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Async Usage
|
|
107
|
+
|
|
108
|
+
All methods are also available as async variants (prefixed with `async_`). Example:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import asyncio
|
|
112
|
+
from cyberdesk import CyberdeskClient
|
|
113
|
+
|
|
114
|
+
async def main():
|
|
115
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
116
|
+
result = await client.async_launch_desktop(timeout_ms=10000)
|
|
117
|
+
print(result)
|
|
118
|
+
# ... use other async_ methods as needed
|
|
119
|
+
|
|
120
|
+
asyncio.run(main())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Type Hints and Models
|
|
126
|
+
|
|
127
|
+
All request/response types are available from the generated models:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# cyberdesk
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/cyberdesk)
|
|
4
|
+
|
|
5
|
+
The official Python SDK for Cyberdesk.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install cyberdesk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
First, create a Cyberdesk client instance with your API key:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from cyberdesk import CyberdeskClient
|
|
19
|
+
|
|
20
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### Launch a Desktop
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
|
|
29
|
+
|
|
30
|
+
# Error handling example
|
|
31
|
+
if hasattr(result, 'error') and result.error:
|
|
32
|
+
raise Exception('Failed to launch desktop: ' + str(result.error))
|
|
33
|
+
|
|
34
|
+
# Success
|
|
35
|
+
if hasattr(result, 'id'):
|
|
36
|
+
desktop_id = result.id
|
|
37
|
+
print('Launched desktop with ID:', desktop_id)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### Get Desktop Info
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
info = client.get_desktop("your-desktop-id")
|
|
46
|
+
|
|
47
|
+
if hasattr(info, 'error') and info.error:
|
|
48
|
+
raise Exception('Failed to get desktop info: ' + str(info.error))
|
|
49
|
+
|
|
50
|
+
print('Desktop info:', info)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### Perform a Computer Action (e.g., Mouse Click)
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
action_result = client.execute_computer_action(
|
|
59
|
+
"your-desktop-id",
|
|
60
|
+
{
|
|
61
|
+
"type": "click_mouse",
|
|
62
|
+
"x": 100,
|
|
63
|
+
"y": 150
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
if hasattr(action_result, 'error') and action_result.error:
|
|
68
|
+
raise Exception('Action failed: ' + str(action_result.error))
|
|
69
|
+
|
|
70
|
+
print('Action result:', action_result)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Run a Bash Command
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
bash_result = client.execute_bash_action(
|
|
79
|
+
"your-desktop-id",
|
|
80
|
+
"echo Hello, world!"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
if hasattr(bash_result, 'error') and bash_result.error:
|
|
84
|
+
raise Exception('Bash command failed: ' + str(bash_result.error))
|
|
85
|
+
|
|
86
|
+
print('Bash output:', getattr(bash_result, 'output', bash_result))
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Async Usage
|
|
92
|
+
|
|
93
|
+
All methods are also available as async variants (prefixed with `async_`). Example:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import asyncio
|
|
97
|
+
from cyberdesk import CyberdeskClient
|
|
98
|
+
|
|
99
|
+
async def main():
|
|
100
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
101
|
+
result = await client.async_launch_desktop(timeout_ms=10000)
|
|
102
|
+
print(result)
|
|
103
|
+
# ... use other async_ methods as needed
|
|
104
|
+
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Type Hints and Models
|
|
111
|
+
|
|
112
|
+
All request/response types are available from the generated models:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .client import CyberdeskClient
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cyberdesk Python SDK wrapper client.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from openapi_client.api_reference_client.client import Client
|
|
6
|
+
from openapi_client.api_reference_client.api.desktop import (
|
|
7
|
+
get_v1_desktop_id,
|
|
8
|
+
post_v1_desktop,
|
|
9
|
+
post_v1_desktop_id_stop,
|
|
10
|
+
post_v1_desktop_id_computer_action,
|
|
11
|
+
post_v1_desktop_id_bash_action,
|
|
12
|
+
)
|
|
13
|
+
from openapi_client.api_reference_client.models import (
|
|
14
|
+
PostV1DesktopBody,
|
|
15
|
+
PostV1DesktopIdBashActionBody,
|
|
16
|
+
PostV1DesktopIdComputerActionClickMouseAction,
|
|
17
|
+
PostV1DesktopIdComputerActionDragMouseAction,
|
|
18
|
+
PostV1DesktopIdComputerActionGetCursorPositionAction,
|
|
19
|
+
PostV1DesktopIdComputerActionMoveMouseAction,
|
|
20
|
+
PostV1DesktopIdComputerActionPressKeysAction,
|
|
21
|
+
PostV1DesktopIdComputerActionScreenshotAction,
|
|
22
|
+
PostV1DesktopIdComputerActionScrollAction,
|
|
23
|
+
PostV1DesktopIdComputerActionTypeTextAction,
|
|
24
|
+
PostV1DesktopIdComputerActionWaitAction,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
class CyberdeskClient:
|
|
28
|
+
"""
|
|
29
|
+
Wrapper client for the Cyberdesk API.
|
|
30
|
+
Provides both synchronous and asynchronous methods.
|
|
31
|
+
"""
|
|
32
|
+
def __init__(self, api_key: str, base_url: str = "https://api.cyberdesk.io"):
|
|
33
|
+
self.api_key = api_key
|
|
34
|
+
self.client = Client(base_url=base_url, headers={"x-api-key": api_key})
|
|
35
|
+
|
|
36
|
+
def get_desktop(self, id: str):
|
|
37
|
+
"""Synchronous: Get details of a specific desktop instance."""
|
|
38
|
+
return get_v1_desktop_id.sync(id=id, client=self.client, x_api_key=self.api_key)
|
|
39
|
+
|
|
40
|
+
async def async_get_desktop(self, id: str):
|
|
41
|
+
"""Async: Get details of a specific desktop instance. Use with 'await'."""
|
|
42
|
+
return await get_v1_desktop_id.asyncio(id=id, client=self.client, x_api_key=self.api_key)
|
|
43
|
+
|
|
44
|
+
def launch_desktop(self, timeout_ms: int = None):
|
|
45
|
+
"""Synchronous: Create a new virtual desktop instance."""
|
|
46
|
+
body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
|
|
47
|
+
return post_v1_desktop.sync(client=self.client, body=body, x_api_key=self.api_key)
|
|
48
|
+
|
|
49
|
+
async def async_launch_desktop(self, timeout_ms: int = None):
|
|
50
|
+
"""Async: Create a new virtual desktop instance. Use with 'await'."""
|
|
51
|
+
body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
|
|
52
|
+
return await post_v1_desktop.asyncio(client=self.client, body=body, x_api_key=self.api_key)
|
|
53
|
+
|
|
54
|
+
def terminate_desktop(self, id: str):
|
|
55
|
+
"""Synchronous: Stop a running desktop instance."""
|
|
56
|
+
return post_v1_desktop_id_stop.sync(id=id, client=self.client, x_api_key=self.api_key)
|
|
57
|
+
|
|
58
|
+
async def async_terminate_desktop(self, id: str):
|
|
59
|
+
"""Async: Stop a running desktop instance. Use with 'await'."""
|
|
60
|
+
return await post_v1_desktop_id_stop.asyncio(id=id, client=self.client, x_api_key=self.api_key)
|
|
61
|
+
|
|
62
|
+
def execute_computer_action(self, id: str, action: dict):
|
|
63
|
+
"""Synchronous: Perform an action on the desktop (mouse, keyboard, etc)."""
|
|
64
|
+
action_type = action.get("type")
|
|
65
|
+
model_cls = {
|
|
66
|
+
"click_mouse": PostV1DesktopIdComputerActionClickMouseAction,
|
|
67
|
+
"scroll": PostV1DesktopIdComputerActionScrollAction,
|
|
68
|
+
"move_mouse": PostV1DesktopIdComputerActionMoveMouseAction,
|
|
69
|
+
"drag_mouse": PostV1DesktopIdComputerActionDragMouseAction,
|
|
70
|
+
"type": PostV1DesktopIdComputerActionTypeTextAction,
|
|
71
|
+
"press_keys": PostV1DesktopIdComputerActionPressKeysAction,
|
|
72
|
+
"wait": PostV1DesktopIdComputerActionWaitAction,
|
|
73
|
+
"screenshot": PostV1DesktopIdComputerActionScreenshotAction,
|
|
74
|
+
"get_cursor_position": PostV1DesktopIdComputerActionGetCursorPositionAction,
|
|
75
|
+
}.get(action_type)
|
|
76
|
+
if model_cls is None:
|
|
77
|
+
raise ValueError(f"Unknown computer action type: {action_type}")
|
|
78
|
+
model = model_cls.from_dict(action)
|
|
79
|
+
return post_v1_desktop_id_computer_action.sync(id=id, client=self.client, body=model, x_api_key=self.api_key)
|
|
80
|
+
|
|
81
|
+
async def async_execute_computer_action(self, id: str, action: dict):
|
|
82
|
+
"""Async: Perform an action on the desktop (mouse, keyboard, etc). Use with 'await'."""
|
|
83
|
+
action_type = action.get("type")
|
|
84
|
+
model_cls = {
|
|
85
|
+
"click_mouse": PostV1DesktopIdComputerActionClickMouseAction,
|
|
86
|
+
"scroll": PostV1DesktopIdComputerActionScrollAction,
|
|
87
|
+
"move_mouse": PostV1DesktopIdComputerActionMoveMouseAction,
|
|
88
|
+
"drag_mouse": PostV1DesktopIdComputerActionDragMouseAction,
|
|
89
|
+
"type": PostV1DesktopIdComputerActionTypeTextAction,
|
|
90
|
+
"press_keys": PostV1DesktopIdComputerActionPressKeysAction,
|
|
91
|
+
"wait": PostV1DesktopIdComputerActionWaitAction,
|
|
92
|
+
"screenshot": PostV1DesktopIdComputerActionScreenshotAction,
|
|
93
|
+
"get_cursor_position": PostV1DesktopIdComputerActionGetCursorPositionAction,
|
|
94
|
+
}.get(action_type)
|
|
95
|
+
if model_cls is None:
|
|
96
|
+
raise ValueError(f"Unknown computer action type: {action_type}")
|
|
97
|
+
model = model_cls.from_dict(action)
|
|
98
|
+
return await post_v1_desktop_id_computer_action.asyncio(id=id, client=self.client, body=model, x_api_key=self.api_key)
|
|
99
|
+
|
|
100
|
+
def execute_bash_action(self, id: str, command: str):
|
|
101
|
+
"""Synchronous: Execute a bash command on the desktop."""
|
|
102
|
+
body = PostV1DesktopIdBashActionBody(command=command)
|
|
103
|
+
return post_v1_desktop_id_bash_action.sync(id=id, client=self.client, body=body, x_api_key=self.api_key)
|
|
104
|
+
|
|
105
|
+
async def async_execute_bash_action(self, id: str, command: str):
|
|
106
|
+
"""Async: Execute a bash command on the desktop. Use with 'await'."""
|
|
107
|
+
body = PostV1DesktopIdBashActionBody(command=command)
|
|
108
|
+
return await post_v1_desktop_id_bash_action.asyncio(id=id, client=self.client, body=body, x_api_key=self.api_key)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cyberdesk
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: The official Python SDK for Cyberdesk
|
|
5
|
+
Author-email: Cyberdesk Team <dev@cyberdesk.io>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: openapi-python-client; extra == "dev"
|
|
12
|
+
Requires-Dist: build; extra == "dev"
|
|
13
|
+
Requires-Dist: twine; extra == "dev"
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# cyberdesk
|
|
17
|
+
|
|
18
|
+
[](https://badge.fury.io/py/cyberdesk)
|
|
19
|
+
|
|
20
|
+
The official Python SDK for Cyberdesk.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install cyberdesk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
First, create a Cyberdesk client instance with your API key:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from cyberdesk import CyberdeskClient
|
|
34
|
+
|
|
35
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Launch a Desktop
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
|
|
44
|
+
|
|
45
|
+
# Error handling example
|
|
46
|
+
if hasattr(result, 'error') and result.error:
|
|
47
|
+
raise Exception('Failed to launch desktop: ' + str(result.error))
|
|
48
|
+
|
|
49
|
+
# Success
|
|
50
|
+
if hasattr(result, 'id'):
|
|
51
|
+
desktop_id = result.id
|
|
52
|
+
print('Launched desktop with ID:', desktop_id)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Get Desktop Info
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
info = client.get_desktop("your-desktop-id")
|
|
61
|
+
|
|
62
|
+
if hasattr(info, 'error') and info.error:
|
|
63
|
+
raise Exception('Failed to get desktop info: ' + str(info.error))
|
|
64
|
+
|
|
65
|
+
print('Desktop info:', info)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Perform a Computer Action (e.g., Mouse Click)
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
action_result = client.execute_computer_action(
|
|
74
|
+
"your-desktop-id",
|
|
75
|
+
{
|
|
76
|
+
"type": "click_mouse",
|
|
77
|
+
"x": 100,
|
|
78
|
+
"y": 150
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if hasattr(action_result, 'error') and action_result.error:
|
|
83
|
+
raise Exception('Action failed: ' + str(action_result.error))
|
|
84
|
+
|
|
85
|
+
print('Action result:', action_result)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### Run a Bash Command
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
bash_result = client.execute_bash_action(
|
|
94
|
+
"your-desktop-id",
|
|
95
|
+
"echo Hello, world!"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if hasattr(bash_result, 'error') and bash_result.error:
|
|
99
|
+
raise Exception('Bash command failed: ' + str(bash_result.error))
|
|
100
|
+
|
|
101
|
+
print('Bash output:', getattr(bash_result, 'output', bash_result))
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Async Usage
|
|
107
|
+
|
|
108
|
+
All methods are also available as async variants (prefixed with `async_`). Example:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import asyncio
|
|
112
|
+
from cyberdesk import CyberdeskClient
|
|
113
|
+
|
|
114
|
+
async def main():
|
|
115
|
+
client = CyberdeskClient(api_key="YOUR_API_KEY")
|
|
116
|
+
result = await client.async_launch_desktop(timeout_ms=10000)
|
|
117
|
+
print(result)
|
|
118
|
+
# ... use other async_ methods as needed
|
|
119
|
+
|
|
120
|
+
asyncio.run(main())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Type Hints and Models
|
|
126
|
+
|
|
127
|
+
All request/response types are available from the generated models:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cyberdesk
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "cyberdesk"
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "The official Python SDK for Cyberdesk"
|
|
5
|
+
authors = [{name = "Cyberdesk Team", email = "dev@cyberdesk.io"}]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"httpx"
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["setuptools", "wheel"]
|
|
14
|
+
build-backend = "setuptools.build_meta"
|
|
15
|
+
|
|
16
|
+
[project.optional-dependencies]
|
|
17
|
+
dev = [
|
|
18
|
+
"openapi-python-client",
|
|
19
|
+
"build",
|
|
20
|
+
"twine"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
include = ["cyberdesk*"]
|