daytona-sdk 0.5.0__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.
- daytona_sdk-0.5.0/LICENCE +43 -0
- daytona_sdk-0.5.0/PKG-INFO +193 -0
- daytona_sdk-0.5.0/README.md +167 -0
- daytona_sdk-0.5.0/pyproject.toml +37 -0
- daytona_sdk-0.5.0/setup.cfg +4 -0
- daytona_sdk-0.5.0/setup.py +16 -0
- daytona_sdk-0.5.0/src/api_client/__init__.py +129 -0
- daytona_sdk-0.5.0/src/api_client/api/__init__.py +17 -0
- daytona_sdk-0.5.0/src/api_client/api/api_key_api.py +744 -0
- daytona_sdk-0.5.0/src/api_client/api/build_api.py +1507 -0
- daytona_sdk-0.5.0/src/api_client/api/container_registry_api.py +1022 -0
- daytona_sdk-0.5.0/src/api_client/api/default_api.py +264 -0
- daytona_sdk-0.5.0/src/api_client/api/git_provider_api.py +3413 -0
- daytona_sdk-0.5.0/src/api_client/api/prebuild_api.py +1529 -0
- daytona_sdk-0.5.0/src/api_client/api/profile_api.py +730 -0
- daytona_sdk-0.5.0/src/api_client/api/project_config_api.py +1490 -0
- daytona_sdk-0.5.0/src/api_client/api/provider_api.py +998 -0
- daytona_sdk-0.5.0/src/api_client/api/sample_api.py +264 -0
- daytona_sdk-0.5.0/src/api_client/api/server_api.py +973 -0
- daytona_sdk-0.5.0/src/api_client/api/target_api.py +975 -0
- daytona_sdk-0.5.0/src/api_client/api/workspace_api.py +2280 -0
- daytona_sdk-0.5.0/src/api_client/api/workspace_toolbox_api.py +8106 -0
- daytona_sdk-0.5.0/src/api_client/api_client.py +755 -0
- daytona_sdk-0.5.0/src/api_client/api_response.py +20 -0
- daytona_sdk-0.5.0/src/api_client/configuration.py +608 -0
- daytona_sdk-0.5.0/src/api_client/exceptions.py +199 -0
- daytona_sdk-0.5.0/src/api_client/models/__init__.py +99 -0
- daytona_sdk-0.5.0/src/api_client/models/api_key.py +92 -0
- daytona_sdk-0.5.0/src/api_client/models/apikey_api_key_type.py +36 -0
- daytona_sdk-0.5.0/src/api_client/models/build.py +144 -0
- daytona_sdk-0.5.0/src/api_client/models/build_build_state.py +41 -0
- daytona_sdk-0.5.0/src/api_client/models/build_config.py +105 -0
- daytona_sdk-0.5.0/src/api_client/models/cached_build.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/clone_target.py +35 -0
- daytona_sdk-0.5.0/src/api_client/models/completion_context.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/completion_item.py +107 -0
- daytona_sdk-0.5.0/src/api_client/models/completion_list.py +101 -0
- daytona_sdk-0.5.0/src/api_client/models/container_config.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/container_registry.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/create_build_dto.py +98 -0
- daytona_sdk-0.5.0/src/api_client/models/create_prebuild_dto.py +101 -0
- daytona_sdk-0.5.0/src/api_client/models/create_project_config_dto.py +117 -0
- daytona_sdk-0.5.0/src/api_client/models/create_project_dto.py +125 -0
- daytona_sdk-0.5.0/src/api_client/models/create_project_source_dto.py +95 -0
- daytona_sdk-0.5.0/src/api_client/models/create_provider_target_dto.py +99 -0
- daytona_sdk-0.5.0/src/api_client/models/create_workspace_dto.py +105 -0
- daytona_sdk-0.5.0/src/api_client/models/devcontainer_config.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/execute_request.py +88 -0
- daytona_sdk-0.5.0/src/api_client/models/execute_response.py +86 -0
- daytona_sdk-0.5.0/src/api_client/models/file_info.py +110 -0
- daytona_sdk-0.5.0/src/api_client/models/file_status.py +94 -0
- daytona_sdk-0.5.0/src/api_client/models/frps_config.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/get_repository_context.py +113 -0
- daytona_sdk-0.5.0/src/api_client/models/git_add_request.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/git_branch.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/git_branch_request.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/git_clone_request.py +104 -0
- daytona_sdk-0.5.0/src/api_client/models/git_commit_info.py +101 -0
- daytona_sdk-0.5.0/src/api_client/models/git_commit_request.py +93 -0
- daytona_sdk-0.5.0/src/api_client/models/git_commit_response.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/git_namespace.py +84 -0
- daytona_sdk-0.5.0/src/api_client/models/git_provider.py +111 -0
- daytona_sdk-0.5.0/src/api_client/models/git_pull_request.py +107 -0
- daytona_sdk-0.5.0/src/api_client/models/git_repo_request.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/git_repository.py +117 -0
- daytona_sdk-0.5.0/src/api_client/models/git_status.py +115 -0
- daytona_sdk-0.5.0/src/api_client/models/git_user.py +93 -0
- daytona_sdk-0.5.0/src/api_client/models/install_provider_request.py +86 -0
- daytona_sdk-0.5.0/src/api_client/models/list_branch_response.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/log_file_config.py +104 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_completion_params.py +117 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_document_request.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_location.py +97 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_position.py +86 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_range.py +104 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_server_request.py +89 -0
- daytona_sdk-0.5.0/src/api_client/models/lsp_symbol.py +99 -0
- daytona_sdk-0.5.0/src/api_client/models/match.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/network_key.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/position.py +86 -0
- daytona_sdk-0.5.0/src/api_client/models/prebuild_config.py +101 -0
- daytona_sdk-0.5.0/src/api_client/models/prebuild_dto.py +104 -0
- daytona_sdk-0.5.0/src/api_client/models/profile_data.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/project.py +153 -0
- daytona_sdk-0.5.0/src/api_client/models/project_config.py +135 -0
- daytona_sdk-0.5.0/src/api_client/models/project_dir_response.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/project_info.py +103 -0
- daytona_sdk-0.5.0/src/api_client/models/project_state.py +99 -0
- daytona_sdk-0.5.0/src/api_client/models/provider.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/provider_provider_info.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/provider_provider_target_property.py +126 -0
- daytona_sdk-0.5.0/src/api_client/models/provider_provider_target_property_type.py +39 -0
- daytona_sdk-0.5.0/src/api_client/models/provider_target.py +101 -0
- daytona_sdk-0.5.0/src/api_client/models/replace_request.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/replace_result.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/repository_url.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/sample.py +91 -0
- daytona_sdk-0.5.0/src/api_client/models/search_files_response.py +83 -0
- daytona_sdk-0.5.0/src/api_client/models/server_config.py +157 -0
- daytona_sdk-0.5.0/src/api_client/models/set_git_provider_config.py +111 -0
- daytona_sdk-0.5.0/src/api_client/models/set_project_state.py +97 -0
- daytona_sdk-0.5.0/src/api_client/models/signing_method.py +35 -0
- daytona_sdk-0.5.0/src/api_client/models/status.py +41 -0
- daytona_sdk-0.5.0/src/api_client/models/workspace.py +105 -0
- daytona_sdk-0.5.0/src/api_client/models/workspace_dto.py +115 -0
- daytona_sdk-0.5.0/src/api_client/models/workspace_info.py +105 -0
- daytona_sdk-0.5.0/src/api_client/rest.py +246 -0
- daytona_sdk-0.5.0/src/daytona_sdk/__init__.py +10 -0
- daytona_sdk-0.5.0/src/daytona_sdk/api_client.py +36 -0
- daytona_sdk-0.5.0/src/daytona_sdk/code_toolbox/__init__.py +0 -0
- daytona_sdk-0.5.0/src/daytona_sdk/code_toolbox/workspace_python_code_toolbox.py +16 -0
- daytona_sdk-0.5.0/src/daytona_sdk/code_toolbox/workspace_ts_code_toolbox.py +16 -0
- daytona_sdk-0.5.0/src/daytona_sdk/daytona.py +244 -0
- daytona_sdk-0.5.0/src/daytona_sdk/filesystem.py +184 -0
- daytona_sdk-0.5.0/src/daytona_sdk/git.py +160 -0
- daytona_sdk-0.5.0/src/daytona_sdk/lsp_server.py +174 -0
- daytona_sdk-0.5.0/src/daytona_sdk/process.py +62 -0
- daytona_sdk-0.5.0/src/daytona_sdk/types.py +7 -0
- daytona_sdk-0.5.0/src/daytona_sdk/workspace.py +113 -0
- daytona_sdk-0.5.0/src/daytona_sdk.egg-info/PKG-INFO +193 -0
- daytona_sdk-0.5.0/src/daytona_sdk.egg-info/SOURCES.txt +122 -0
- daytona_sdk-0.5.0/src/daytona_sdk.egg-info/dependency_links.txt +1 -0
- daytona_sdk-0.5.0/src/daytona_sdk.egg-info/requires.txt +10 -0
- daytona_sdk-0.5.0/src/daytona_sdk.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: daytona_sdk
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Python SDK for Daytona
|
|
5
|
+
Author-email: Vedran Jukic <vedran.jukic@gmail.com>
|
|
6
|
+
License: Apache 2.0
|
|
7
|
+
Keywords: daytona,sdk
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Requires-Python: >=3.7
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENCE
|
|
17
|
+
Requires-Dist: environs<10.0.0,>=9.5.0
|
|
18
|
+
Requires-Dist: marshmallow<4.0.0,>=3.19.0
|
|
19
|
+
Requires-Dist: pydantic<3.0.0,>=2.4.2
|
|
20
|
+
Requires-Dist: python-dateutil<3.0.0,>=2.8.2
|
|
21
|
+
Requires-Dist: urllib3<3.0.0,>=2.0.7
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pydoc-markdown>=4.8.2; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
26
|
+
|
|
27
|
+
# Daytona SDK for Python
|
|
28
|
+
|
|
29
|
+
A Python SDK for interacting with Daytona Server API, providing a simple interface for Daytona Workspace management, Git operations, file system operations, and language server protocol support.
|
|
30
|
+
|
|
31
|
+
## Prerequisites
|
|
32
|
+
|
|
33
|
+
Before using the Daytona SDK, you need to have a running Daytona server instance and proper configuration.
|
|
34
|
+
|
|
35
|
+
### Server Installation
|
|
36
|
+
|
|
37
|
+
For detailed instructions on installing and setting up the Daytona server, please refer to the official installation guide at:
|
|
38
|
+
[https://github.com/daytonaio/daytona](https://github.com/daytonaio/daytona)
|
|
39
|
+
|
|
40
|
+
### Configuration
|
|
41
|
+
|
|
42
|
+
To use the SDK, you'll need two essential pieces of information:
|
|
43
|
+
|
|
44
|
+
1. **Server Address**:
|
|
45
|
+
|
|
46
|
+
- Run `daytona server config` to get your server's configuration
|
|
47
|
+
- Look for the `API URL` value in the output
|
|
48
|
+
- For testing and development, you can use the FRP address provided
|
|
49
|
+
- For production environments, it's recommended to use a static address
|
|
50
|
+
|
|
51
|
+
2. **API Key**:
|
|
52
|
+
- Generate a new API key by running:
|
|
53
|
+
```bash
|
|
54
|
+
daytona api-key generate
|
|
55
|
+
```
|
|
56
|
+
- Save this key securely as it will be needed to authenticate with the server
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
You can install the package using pip:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install daytona-sdk
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
Here's a simple example of using the SDK:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from daytona_sdk import Daytona
|
|
72
|
+
|
|
73
|
+
# Initialize the Daytona client
|
|
74
|
+
daytona = Daytona()
|
|
75
|
+
|
|
76
|
+
# Create the workspace instance
|
|
77
|
+
workspace = daytona.create()
|
|
78
|
+
|
|
79
|
+
# Run the code securely inside the workspace
|
|
80
|
+
response = workspace.process.code_run('print("Hello World!")')
|
|
81
|
+
print(response.result)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- **Workspace Management**: Create, manage and remove workspaces
|
|
87
|
+
- **Git Operations**: Clone repositories, manage branches, and more
|
|
88
|
+
- **File System Operations**: Upload, download, search and manipulate files
|
|
89
|
+
- **Language Server Protocol**: Interact with language servers for code intelligence
|
|
90
|
+
- **Process Management**: Execute code and commands in workspaces
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
The SDK can be configured using environment variables or by passing a configuration object:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from daytona_sdk import Daytona, DaytonaConfig
|
|
98
|
+
|
|
99
|
+
config = DaytonaConfig(
|
|
100
|
+
api_key='your-api-key',
|
|
101
|
+
server_url='https://your-daytona-server',
|
|
102
|
+
target='your-target'
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
daytona = Daytona(config)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or using environment variables:
|
|
109
|
+
|
|
110
|
+
- `DAYTONA_API_KEY`: Your Daytona API key
|
|
111
|
+
- `DAYTONA_SERVER_URL`: The Daytona server URL
|
|
112
|
+
- `DAYTONA_TARGET`: Your target environment
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Execute command
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
response = workspace.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))')
|
|
120
|
+
if response.code != 0:
|
|
121
|
+
print(f"Error: {response.code} {response.result}")
|
|
122
|
+
else:
|
|
123
|
+
print(response.result)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### File Operations
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Upload a file
|
|
130
|
+
workspace.fs.upload_file('/path/to/file.txt', b'Hello, World!')
|
|
131
|
+
|
|
132
|
+
# Download a file
|
|
133
|
+
content = workspace.fs.download_file('/path/to/file.txt')
|
|
134
|
+
|
|
135
|
+
# Search for files
|
|
136
|
+
matches = workspace.fs.find_files(root_dir, 'search_pattern')
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Git Operations
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Clone a repository
|
|
143
|
+
workspace.git.clone('https://github.com/example/repo', '/path/to/clone')
|
|
144
|
+
|
|
145
|
+
# List branches
|
|
146
|
+
branches = workspace.git.branches('/path/to/repo')
|
|
147
|
+
|
|
148
|
+
# Add files
|
|
149
|
+
workspace.git.add('/path/to/repo', ['file1.txt', 'file2.txt'])
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Language Server Protocol
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# Create and start a language server
|
|
156
|
+
lsp = workspace.create_lsp_server('typescript', '/path/to/project')
|
|
157
|
+
lsp.start()
|
|
158
|
+
|
|
159
|
+
# Notify the lsp for the file
|
|
160
|
+
lsp.did_open('/path/to/file.ts')
|
|
161
|
+
|
|
162
|
+
# Get document symbols
|
|
163
|
+
symbols = lsp.document_symbols('/path/to/file.ts')
|
|
164
|
+
|
|
165
|
+
# Get completions
|
|
166
|
+
completions = lsp.completions('/path/to/file.ts', {"line": 10, "character": 15})
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Contributing
|
|
170
|
+
|
|
171
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
This project is licensed under the Apache License, Version 2.0 - see below for details:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
Copyright 2024 Daytona
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
For the full license text, please see the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Daytona SDK for Python
|
|
2
|
+
|
|
3
|
+
A Python SDK for interacting with Daytona Server API, providing a simple interface for Daytona Workspace management, Git operations, file system operations, and language server protocol support.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Before using the Daytona SDK, you need to have a running Daytona server instance and proper configuration.
|
|
8
|
+
|
|
9
|
+
### Server Installation
|
|
10
|
+
|
|
11
|
+
For detailed instructions on installing and setting up the Daytona server, please refer to the official installation guide at:
|
|
12
|
+
[https://github.com/daytonaio/daytona](https://github.com/daytonaio/daytona)
|
|
13
|
+
|
|
14
|
+
### Configuration
|
|
15
|
+
|
|
16
|
+
To use the SDK, you'll need two essential pieces of information:
|
|
17
|
+
|
|
18
|
+
1. **Server Address**:
|
|
19
|
+
|
|
20
|
+
- Run `daytona server config` to get your server's configuration
|
|
21
|
+
- Look for the `API URL` value in the output
|
|
22
|
+
- For testing and development, you can use the FRP address provided
|
|
23
|
+
- For production environments, it's recommended to use a static address
|
|
24
|
+
|
|
25
|
+
2. **API Key**:
|
|
26
|
+
- Generate a new API key by running:
|
|
27
|
+
```bash
|
|
28
|
+
daytona api-key generate
|
|
29
|
+
```
|
|
30
|
+
- Save this key securely as it will be needed to authenticate with the server
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
You can install the package using pip:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install daytona-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
Here's a simple example of using the SDK:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from daytona_sdk import Daytona
|
|
46
|
+
|
|
47
|
+
# Initialize the Daytona client
|
|
48
|
+
daytona = Daytona()
|
|
49
|
+
|
|
50
|
+
# Create the workspace instance
|
|
51
|
+
workspace = daytona.create()
|
|
52
|
+
|
|
53
|
+
# Run the code securely inside the workspace
|
|
54
|
+
response = workspace.process.code_run('print("Hello World!")')
|
|
55
|
+
print(response.result)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Workspace Management**: Create, manage and remove workspaces
|
|
61
|
+
- **Git Operations**: Clone repositories, manage branches, and more
|
|
62
|
+
- **File System Operations**: Upload, download, search and manipulate files
|
|
63
|
+
- **Language Server Protocol**: Interact with language servers for code intelligence
|
|
64
|
+
- **Process Management**: Execute code and commands in workspaces
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
The SDK can be configured using environment variables or by passing a configuration object:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from daytona_sdk import Daytona, DaytonaConfig
|
|
72
|
+
|
|
73
|
+
config = DaytonaConfig(
|
|
74
|
+
api_key='your-api-key',
|
|
75
|
+
server_url='https://your-daytona-server',
|
|
76
|
+
target='your-target'
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
daytona = Daytona(config)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or using environment variables:
|
|
83
|
+
|
|
84
|
+
- `DAYTONA_API_KEY`: Your Daytona API key
|
|
85
|
+
- `DAYTONA_SERVER_URL`: The Daytona server URL
|
|
86
|
+
- `DAYTONA_TARGET`: Your target environment
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
### Execute command
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
response = workspace.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))')
|
|
94
|
+
if response.code != 0:
|
|
95
|
+
print(f"Error: {response.code} {response.result}")
|
|
96
|
+
else:
|
|
97
|
+
print(response.result)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### File Operations
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
# Upload a file
|
|
104
|
+
workspace.fs.upload_file('/path/to/file.txt', b'Hello, World!')
|
|
105
|
+
|
|
106
|
+
# Download a file
|
|
107
|
+
content = workspace.fs.download_file('/path/to/file.txt')
|
|
108
|
+
|
|
109
|
+
# Search for files
|
|
110
|
+
matches = workspace.fs.find_files(root_dir, 'search_pattern')
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Git Operations
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# Clone a repository
|
|
117
|
+
workspace.git.clone('https://github.com/example/repo', '/path/to/clone')
|
|
118
|
+
|
|
119
|
+
# List branches
|
|
120
|
+
branches = workspace.git.branches('/path/to/repo')
|
|
121
|
+
|
|
122
|
+
# Add files
|
|
123
|
+
workspace.git.add('/path/to/repo', ['file1.txt', 'file2.txt'])
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Language Server Protocol
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Create and start a language server
|
|
130
|
+
lsp = workspace.create_lsp_server('typescript', '/path/to/project')
|
|
131
|
+
lsp.start()
|
|
132
|
+
|
|
133
|
+
# Notify the lsp for the file
|
|
134
|
+
lsp.did_open('/path/to/file.ts')
|
|
135
|
+
|
|
136
|
+
# Get document symbols
|
|
137
|
+
symbols = lsp.document_symbols('/path/to/file.ts')
|
|
138
|
+
|
|
139
|
+
# Get completions
|
|
140
|
+
completions = lsp.completions('/path/to/file.ts', {"line": 10, "character": 15})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
This project is licensed under the Apache License, Version 2.0 - see below for details:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Copyright 2024 Daytona
|
|
153
|
+
|
|
154
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
155
|
+
you may not use this file except in compliance with the License.
|
|
156
|
+
You may obtain a copy of the License at
|
|
157
|
+
|
|
158
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
159
|
+
|
|
160
|
+
Unless required by applicable law or agreed to in writing, software
|
|
161
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
162
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
163
|
+
See the License for the specific language governing permissions and
|
|
164
|
+
limitations under the License.
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
For the full license text, please see the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "daytona_sdk"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Vedran Jukic", email = "vedran.jukic@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Python SDK for Daytona"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.7"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"environs>=9.5.0,<10.0.0",
|
|
16
|
+
"marshmallow>=3.19.0,<4.0.0",
|
|
17
|
+
"pydantic>=2.4.2,<3.0.0",
|
|
18
|
+
"python-dateutil>=2.8.2,<3.0.0",
|
|
19
|
+
"urllib3>=2.0.7,<3.0.0"
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 3 - Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.7",
|
|
26
|
+
"Programming Language :: Python :: 3.8",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
]
|
|
29
|
+
keywords = ["daytona", "sdk"]
|
|
30
|
+
license = {text = "Apache 2.0"}
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pydoc-markdown>=4.8.2",
|
|
35
|
+
"black>=22.0.0",
|
|
36
|
+
"isort>=5.10.0"
|
|
37
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="daytona_sdk",
|
|
5
|
+
version="0.1.4",
|
|
6
|
+
packages=find_packages(where="src"),
|
|
7
|
+
package_dir={"": "src"},
|
|
8
|
+
install_requires=[
|
|
9
|
+
# Add dependencies here
|
|
10
|
+
],
|
|
11
|
+
# Include both packages
|
|
12
|
+
package_data={
|
|
13
|
+
"daytona_sdk": ["*"],
|
|
14
|
+
"apiclient": ["*"],
|
|
15
|
+
},
|
|
16
|
+
)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Daytona Server API
|
|
7
|
+
|
|
8
|
+
Daytona Server API
|
|
9
|
+
|
|
10
|
+
The version of the OpenAPI document: v0.0.0-dev
|
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
|
+
|
|
13
|
+
Do not edit the class manually.
|
|
14
|
+
""" # noqa: E501
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__version__ = "1.0.0"
|
|
18
|
+
|
|
19
|
+
# import apis into sdk package
|
|
20
|
+
from api_client.api.api_key_api import ApiKeyApi
|
|
21
|
+
from api_client.api.build_api import BuildApi
|
|
22
|
+
from api_client.api.container_registry_api import ContainerRegistryApi
|
|
23
|
+
from api_client.api.default_api import DefaultApi
|
|
24
|
+
from api_client.api.git_provider_api import GitProviderApi
|
|
25
|
+
from api_client.api.prebuild_api import PrebuildApi
|
|
26
|
+
from api_client.api.profile_api import ProfileApi
|
|
27
|
+
from api_client.api.project_config_api import ProjectConfigApi
|
|
28
|
+
from api_client.api.provider_api import ProviderApi
|
|
29
|
+
from api_client.api.sample_api import SampleApi
|
|
30
|
+
from api_client.api.server_api import ServerApi
|
|
31
|
+
from api_client.api.target_api import TargetApi
|
|
32
|
+
from api_client.api.workspace_api import WorkspaceApi
|
|
33
|
+
from api_client.api.workspace_toolbox_api import WorkspaceToolboxApi
|
|
34
|
+
|
|
35
|
+
# import ApiClient
|
|
36
|
+
from api_client.api_response import ApiResponse
|
|
37
|
+
from api_client.api_client import ApiClient
|
|
38
|
+
from api_client.configuration import Configuration
|
|
39
|
+
from api_client.exceptions import OpenApiException
|
|
40
|
+
from api_client.exceptions import ApiTypeError
|
|
41
|
+
from api_client.exceptions import ApiValueError
|
|
42
|
+
from api_client.exceptions import ApiKeyError
|
|
43
|
+
from api_client.exceptions import ApiAttributeError
|
|
44
|
+
from api_client.exceptions import ApiException
|
|
45
|
+
|
|
46
|
+
# import models into sdk package
|
|
47
|
+
from api_client.models.api_key import ApiKey
|
|
48
|
+
from api_client.models.apikey_api_key_type import ApikeyApiKeyType
|
|
49
|
+
from api_client.models.build import Build
|
|
50
|
+
from api_client.models.build_build_state import BuildBuildState
|
|
51
|
+
from api_client.models.build_config import BuildConfig
|
|
52
|
+
from api_client.models.cached_build import CachedBuild
|
|
53
|
+
from api_client.models.clone_target import CloneTarget
|
|
54
|
+
from api_client.models.completion_context import CompletionContext
|
|
55
|
+
from api_client.models.completion_item import CompletionItem
|
|
56
|
+
from api_client.models.completion_list import CompletionList
|
|
57
|
+
from api_client.models.container_config import ContainerConfig
|
|
58
|
+
from api_client.models.container_registry import ContainerRegistry
|
|
59
|
+
from api_client.models.create_build_dto import CreateBuildDTO
|
|
60
|
+
from api_client.models.create_prebuild_dto import CreatePrebuildDTO
|
|
61
|
+
from api_client.models.create_project_config_dto import CreateProjectConfigDTO
|
|
62
|
+
from api_client.models.create_project_dto import CreateProjectDTO
|
|
63
|
+
from api_client.models.create_project_source_dto import CreateProjectSourceDTO
|
|
64
|
+
from api_client.models.create_provider_target_dto import CreateProviderTargetDTO
|
|
65
|
+
from api_client.models.create_workspace_dto import CreateWorkspaceDTO
|
|
66
|
+
from api_client.models.devcontainer_config import DevcontainerConfig
|
|
67
|
+
from api_client.models.execute_request import ExecuteRequest
|
|
68
|
+
from api_client.models.execute_response import ExecuteResponse
|
|
69
|
+
from api_client.models.frps_config import FRPSConfig
|
|
70
|
+
from api_client.models.file_info import FileInfo
|
|
71
|
+
from api_client.models.file_status import FileStatus
|
|
72
|
+
from api_client.models.get_repository_context import GetRepositoryContext
|
|
73
|
+
from api_client.models.git_add_request import GitAddRequest
|
|
74
|
+
from api_client.models.git_branch import GitBranch
|
|
75
|
+
from api_client.models.git_branch_request import GitBranchRequest
|
|
76
|
+
from api_client.models.git_clone_request import GitCloneRequest
|
|
77
|
+
from api_client.models.git_commit_info import GitCommitInfo
|
|
78
|
+
from api_client.models.git_commit_request import GitCommitRequest
|
|
79
|
+
from api_client.models.git_commit_response import GitCommitResponse
|
|
80
|
+
from api_client.models.git_namespace import GitNamespace
|
|
81
|
+
from api_client.models.git_provider import GitProvider
|
|
82
|
+
from api_client.models.git_pull_request import GitPullRequest
|
|
83
|
+
from api_client.models.git_repo_request import GitRepoRequest
|
|
84
|
+
from api_client.models.git_repository import GitRepository
|
|
85
|
+
from api_client.models.git_status import GitStatus
|
|
86
|
+
from api_client.models.git_user import GitUser
|
|
87
|
+
from api_client.models.install_provider_request import InstallProviderRequest
|
|
88
|
+
from api_client.models.list_branch_response import ListBranchResponse
|
|
89
|
+
from api_client.models.log_file_config import LogFileConfig
|
|
90
|
+
from api_client.models.lsp_completion_params import LspCompletionParams
|
|
91
|
+
from api_client.models.lsp_document_request import LspDocumentRequest
|
|
92
|
+
from api_client.models.lsp_location import LspLocation
|
|
93
|
+
from api_client.models.lsp_position import LspPosition
|
|
94
|
+
from api_client.models.lsp_range import LspRange
|
|
95
|
+
from api_client.models.lsp_server_request import LspServerRequest
|
|
96
|
+
from api_client.models.lsp_symbol import LspSymbol
|
|
97
|
+
from api_client.models.match import Match
|
|
98
|
+
from api_client.models.network_key import NetworkKey
|
|
99
|
+
from api_client.models.position import Position
|
|
100
|
+
from api_client.models.prebuild_config import PrebuildConfig
|
|
101
|
+
from api_client.models.prebuild_dto import PrebuildDTO
|
|
102
|
+
from api_client.models.profile_data import ProfileData
|
|
103
|
+
from api_client.models.project import Project
|
|
104
|
+
from api_client.models.project_config import ProjectConfig
|
|
105
|
+
from api_client.models.project_dir_response import ProjectDirResponse
|
|
106
|
+
from api_client.models.project_info import ProjectInfo
|
|
107
|
+
from api_client.models.project_state import ProjectState
|
|
108
|
+
from api_client.models.provider import Provider
|
|
109
|
+
from api_client.models.provider_provider_info import ProviderProviderInfo
|
|
110
|
+
from api_client.models.provider_provider_target_property import (
|
|
111
|
+
ProviderProviderTargetProperty,
|
|
112
|
+
)
|
|
113
|
+
from api_client.models.provider_provider_target_property_type import (
|
|
114
|
+
ProviderProviderTargetPropertyType,
|
|
115
|
+
)
|
|
116
|
+
from api_client.models.provider_target import ProviderTarget
|
|
117
|
+
from api_client.models.replace_request import ReplaceRequest
|
|
118
|
+
from api_client.models.replace_result import ReplaceResult
|
|
119
|
+
from api_client.models.repository_url import RepositoryUrl
|
|
120
|
+
from api_client.models.sample import Sample
|
|
121
|
+
from api_client.models.search_files_response import SearchFilesResponse
|
|
122
|
+
from api_client.models.server_config import ServerConfig
|
|
123
|
+
from api_client.models.set_git_provider_config import SetGitProviderConfig
|
|
124
|
+
from api_client.models.set_project_state import SetProjectState
|
|
125
|
+
from api_client.models.signing_method import SigningMethod
|
|
126
|
+
from api_client.models.status import Status
|
|
127
|
+
from api_client.models.workspace import Workspace
|
|
128
|
+
from api_client.models.workspace_dto import WorkspaceDTO
|
|
129
|
+
from api_client.models.workspace_info import WorkspaceInfo
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
|
|
3
|
+
# import apis into api package
|
|
4
|
+
from api_client.api.api_key_api import ApiKeyApi
|
|
5
|
+
from api_client.api.build_api import BuildApi
|
|
6
|
+
from api_client.api.container_registry_api import ContainerRegistryApi
|
|
7
|
+
from api_client.api.default_api import DefaultApi
|
|
8
|
+
from api_client.api.git_provider_api import GitProviderApi
|
|
9
|
+
from api_client.api.prebuild_api import PrebuildApi
|
|
10
|
+
from api_client.api.profile_api import ProfileApi
|
|
11
|
+
from api_client.api.project_config_api import ProjectConfigApi
|
|
12
|
+
from api_client.api.provider_api import ProviderApi
|
|
13
|
+
from api_client.api.sample_api import SampleApi
|
|
14
|
+
from api_client.api.server_api import ServerApi
|
|
15
|
+
from api_client.api.target_api import TargetApi
|
|
16
|
+
from api_client.api.workspace_api import WorkspaceApi
|
|
17
|
+
from api_client.api.workspace_toolbox_api import WorkspaceToolboxApi
|