py-forge-studio 0.1.0a2__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.
- py_forge_studio-0.1.0a2/.gitignore +216 -0
- py_forge_studio-0.1.0a2/LICENSE +17 -0
- py_forge_studio-0.1.0a2/PKG-INFO +95 -0
- py_forge_studio-0.1.0a2/README.md +61 -0
- py_forge_studio-0.1.0a2/examples/async_usage.py +53 -0
- py_forge_studio-0.1.0a2/examples/branches.py +71 -0
- py_forge_studio-0.1.0a2/examples/merge_and_rebase.py +85 -0
- py_forge_studio-0.1.0a2/examples/nodes.py +106 -0
- py_forge_studio-0.1.0a2/examples/quickstart.py +51 -0
- py_forge_studio-0.1.0a2/examples/repositories.py +50 -0
- py_forge_studio-0.1.0a2/justfile +12 -0
- py_forge_studio-0.1.0a2/pyproject.toml +67 -0
- py_forge_studio-0.1.0a2/src/py_forge/__init__.py +103 -0
- py_forge_studio-0.1.0a2/src/py_forge/_base_client.py +331 -0
- py_forge_studio-0.1.0a2/src/py_forge/_client.py +203 -0
- py_forge_studio-0.1.0a2/src/py_forge/_constants.py +9 -0
- py_forge_studio-0.1.0a2/src/py_forge/_exceptions.py +112 -0
- py_forge_studio-0.1.0a2/src/py_forge/_resource.py +138 -0
- py_forge_studio-0.1.0a2/src/py_forge/_types.py +17 -0
- py_forge_studio-0.1.0a2/src/py_forge/_utils.py +21 -0
- py_forge_studio-0.1.0a2/src/py_forge/_version.py +3 -0
- py_forge_studio-0.1.0a2/src/py_forge/pagination.py +173 -0
- py_forge_studio-0.1.0a2/src/py_forge/py.typed +0 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/__init__.py +34 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/admin.py +45 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/attachments.py +63 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/auth.py +125 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/branches.py +154 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/commits.py +82 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/node_media.py +25 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/nodes.py +228 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/repositories.py +207 -0
- py_forge_studio-0.1.0a2/src/py_forge/resources/schemas.py +114 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/__init__.py +83 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/attachment.py +35 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/auth.py +53 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/auth_params.py +27 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/branch.py +44 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/branch_params.py +16 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/commit.py +51 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/commit_params.py +46 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/merge.py +34 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/node.py +33 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/node_params.py +13 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/repository.py +26 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/repository_params.py +19 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/schema.py +13 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/schema_params.py +9 -0
- py_forge_studio-0.1.0a2/src/py_forge/types/shared.py +15 -0
- py_forge_studio-0.1.0a2/tests/__init__.py +0 -0
- py_forge_studio-0.1.0a2/tests/conftest.py +1 -0
- py_forge_studio-0.1.0a2/tests/integration/__init__.py +0 -0
- py_forge_studio-0.1.0a2/tests/integration/conftest.py +28 -0
- py_forge_studio-0.1.0a2/tests/integration/test_admin_integration.py +23 -0
- py_forge_studio-0.1.0a2/tests/integration/test_api.py +772 -0
- py_forge_studio-0.1.0a2/tests/integration/test_attachments_integration.py +133 -0
- py_forge_studio-0.1.0a2/tests/integration/test_auth_integration.py +172 -0
- py_forge_studio-0.1.0a2/tests/integration/test_branches_integration.py +253 -0
- py_forge_studio-0.1.0a2/tests/integration/test_commits_integration.py +299 -0
- py_forge_studio-0.1.0a2/tests/integration/test_merge_integration.py +264 -0
- py_forge_studio-0.1.0a2/tests/integration/test_nodes_integration.py +269 -0
- py_forge_studio-0.1.0a2/tests/integration/test_repositories_integration.py +161 -0
- py_forge_studio-0.1.0a2/tests/integration/test_schemas_integration.py +205 -0
- py_forge_studio-0.1.0a2/tests/integration/test_smoke.py +92 -0
- py_forge_studio-0.1.0a2/tests/test_auth_unit.py +146 -0
- py_forge_studio-0.1.0a2/tests/test_client.py +123 -0
- py_forge_studio-0.1.0a2/tests/test_error_handling.py +214 -0
- py_forge_studio-0.1.0a2/tests/test_pagination.py +88 -0
- py_forge_studio-0.1.0a2/tests/test_resources_unit.py +392 -0
- py_forge_studio-0.1.0a2/tests/test_retries.py +188 -0
- py_forge_studio-0.1.0a2/tests/test_utils.py +55 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# ralph
|
|
210
|
+
ralph.py
|
|
211
|
+
progress.md
|
|
212
|
+
PRD.md
|
|
213
|
+
openapi.json
|
|
214
|
+
|
|
215
|
+
# others
|
|
216
|
+
uv.lock
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2026 Forge Systems, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and associated documentation files (the "Software") are the
|
|
4
|
+
proprietary property of Forge Systems, Inc. Unauthorized copying, distribution,
|
|
5
|
+
modification, or use of this Software, via any medium, is strictly prohibited.
|
|
6
|
+
|
|
7
|
+
The Software is provided to authorized licensees under the terms of a separate
|
|
8
|
+
license agreement. Use of the Software is subject to the terms and conditions
|
|
9
|
+
of that agreement.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-forge-studio
|
|
3
|
+
Version: 0.1.0a2
|
|
4
|
+
Summary: Python client for the Forge Studio API
|
|
5
|
+
Project-URL: Homepage, https://forge-studio.tech
|
|
6
|
+
Project-URL: Documentation, https://github.com/Forge-Systems/forge-py#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/Forge-Systems/forge-py
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Forge-Systems/forge-py/issues
|
|
9
|
+
Author-email: Forge Systems <support@forge-studio.tech>
|
|
10
|
+
License-Expression: LicenseRef-Proprietary
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: Other/Proprietary License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Requires-Dist: anyio>=4.0
|
|
24
|
+
Requires-Dist: httpx>=0.27
|
|
25
|
+
Requires-Dist: pydantic>=2.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pyright>=1.1; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-timeout>=2.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: respx>=0.20; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# py-forge-studio
|
|
36
|
+
|
|
37
|
+
Python client for the Forge Studio API.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install py-forge-studio
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick start
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from py_forge import Client
|
|
49
|
+
|
|
50
|
+
client = Client() # uses FORGE_API_KEY env var
|
|
51
|
+
|
|
52
|
+
repo = client.repositories.create(name="my-repo", repo_type_key="TST")
|
|
53
|
+
branch = client.branches.create(repo.id, name="main-work")
|
|
54
|
+
node = client.nodes.create(repo.id, branch.id, node_data={
|
|
55
|
+
"@type": "Folder",
|
|
56
|
+
"@id": "Folder_1",
|
|
57
|
+
"doc_string": "My first node",
|
|
58
|
+
})
|
|
59
|
+
print(f"Created node {node.id} on branch {branch.id}")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Authentication
|
|
63
|
+
|
|
64
|
+
Set `FORGE_API_KEY` and `FORGE_BASE_URL` as environment variables:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
export FORGE_API_KEY="your-api-key"
|
|
68
|
+
export FORGE_BASE_URL="https://your-instance.forge-studio.tech/api"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or pass them directly:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
client = Client(
|
|
75
|
+
api_key="your-api-key",
|
|
76
|
+
base_url="https://your-instance.forge-studio.tech/api",
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Each Forge instance has its own URL in the form `https://<instance>.forge-studio.tech/api`. Contact your Forge account team if you don't know your instance name.
|
|
81
|
+
|
|
82
|
+
## Usage highlights
|
|
83
|
+
|
|
84
|
+
| Topic | Example |
|
|
85
|
+
|---|---|
|
|
86
|
+
| Quick start | [`examples/quickstart.py`](examples/quickstart.py) |
|
|
87
|
+
| Repositories | [`examples/repositories.py`](examples/repositories.py) |
|
|
88
|
+
| Branches | [`examples/branches.py`](examples/branches.py) |
|
|
89
|
+
| Nodes | [`examples/nodes.py`](examples/nodes.py) |
|
|
90
|
+
| Merge & rebase | [`examples/merge_and_rebase.py`](examples/merge_and_rebase.py) |
|
|
91
|
+
| Async usage | [`examples/async_usage.py`](examples/async_usage.py) |
|
|
92
|
+
|
|
93
|
+
## Requirements
|
|
94
|
+
|
|
95
|
+
Python >= 3.9
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# py-forge-studio
|
|
2
|
+
|
|
3
|
+
Python client for the Forge Studio API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install py-forge-studio
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from py_forge import Client
|
|
15
|
+
|
|
16
|
+
client = Client() # uses FORGE_API_KEY env var
|
|
17
|
+
|
|
18
|
+
repo = client.repositories.create(name="my-repo", repo_type_key="TST")
|
|
19
|
+
branch = client.branches.create(repo.id, name="main-work")
|
|
20
|
+
node = client.nodes.create(repo.id, branch.id, node_data={
|
|
21
|
+
"@type": "Folder",
|
|
22
|
+
"@id": "Folder_1",
|
|
23
|
+
"doc_string": "My first node",
|
|
24
|
+
})
|
|
25
|
+
print(f"Created node {node.id} on branch {branch.id}")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Authentication
|
|
29
|
+
|
|
30
|
+
Set `FORGE_API_KEY` and `FORGE_BASE_URL` as environment variables:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
export FORGE_API_KEY="your-api-key"
|
|
34
|
+
export FORGE_BASE_URL="https://your-instance.forge-studio.tech/api"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or pass them directly:
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
client = Client(
|
|
41
|
+
api_key="your-api-key",
|
|
42
|
+
base_url="https://your-instance.forge-studio.tech/api",
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Each Forge instance has its own URL in the form `https://<instance>.forge-studio.tech/api`. Contact your Forge account team if you don't know your instance name.
|
|
47
|
+
|
|
48
|
+
## Usage highlights
|
|
49
|
+
|
|
50
|
+
| Topic | Example |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Quick start | [`examples/quickstart.py`](examples/quickstart.py) |
|
|
53
|
+
| Repositories | [`examples/repositories.py`](examples/repositories.py) |
|
|
54
|
+
| Branches | [`examples/branches.py`](examples/branches.py) |
|
|
55
|
+
| Nodes | [`examples/nodes.py`](examples/nodes.py) |
|
|
56
|
+
| Merge & rebase | [`examples/merge_and_rebase.py`](examples/merge_and_rebase.py) |
|
|
57
|
+
| Async usage | [`examples/async_usage.py`](examples/async_usage.py) |
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
Python >= 3.9
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Async usage — async mirror of the quickstart example.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
export FORGE_API_KEY="your-api-key"
|
|
6
|
+
python examples/async_usage.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
from py_forge import AsyncClient
|
|
11
|
+
|
|
12
|
+
async def main():
|
|
13
|
+
client = AsyncClient()
|
|
14
|
+
repo = None
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
# Create a repository
|
|
18
|
+
repo = await client.repositories.create(
|
|
19
|
+
name="async-example-repo",
|
|
20
|
+
repo_type_key="TST",
|
|
21
|
+
description="Created by async example",
|
|
22
|
+
)
|
|
23
|
+
print(f"Repository: {repo.id} ({repo.name})")
|
|
24
|
+
|
|
25
|
+
# Create a branch
|
|
26
|
+
branch = await client.branches.create(repo.id, name="async-branch")
|
|
27
|
+
print(f"Branch: {branch.id} ({branch.name})")
|
|
28
|
+
|
|
29
|
+
# Create a node
|
|
30
|
+
node = await client.nodes.create(
|
|
31
|
+
repo.id,
|
|
32
|
+
branch.id,
|
|
33
|
+
node_data={
|
|
34
|
+
"@type": "Folder",
|
|
35
|
+
"@id": "Folder_async",
|
|
36
|
+
"doc_string": "Created asynchronously",
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
print(f"Node: {node.id}")
|
|
40
|
+
|
|
41
|
+
# List nodes with async pagination
|
|
42
|
+
page = await client.nodes.list(repo.id, branch.id)
|
|
43
|
+
async for n in page:
|
|
44
|
+
print(f" - {n.id}")
|
|
45
|
+
|
|
46
|
+
finally:
|
|
47
|
+
if repo:
|
|
48
|
+
await client.repositories.delete(repo.id)
|
|
49
|
+
print("Cleaned up repository")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Branches — CRUD operations and diff.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
export FORGE_API_KEY="your-api-key"
|
|
6
|
+
python examples/branches.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from py_forge import Client
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
client = Client()
|
|
13
|
+
repo = None
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
repo = client.repositories.create(
|
|
17
|
+
name="branches-example",
|
|
18
|
+
repo_type_key="TST",
|
|
19
|
+
)
|
|
20
|
+
print(f"Repository: {repo.id}")
|
|
21
|
+
|
|
22
|
+
# Create two branches
|
|
23
|
+
branch_a = client.branches.create(repo.id, name="branch-a", description="First branch")
|
|
24
|
+
branch_b = client.branches.create(repo.id, name="branch-b", description="Second branch")
|
|
25
|
+
print(f"Created: {branch_a.name}, {branch_b.name}")
|
|
26
|
+
|
|
27
|
+
# Get a single branch
|
|
28
|
+
fetched = client.branches.get(repo.id, branch_a.id)
|
|
29
|
+
print(f"Fetched: {fetched.name} (is_default: {fetched.is_default})")
|
|
30
|
+
|
|
31
|
+
# Update
|
|
32
|
+
updated = client.branches.update(
|
|
33
|
+
repo.id, branch_a.id, description="Updated description"
|
|
34
|
+
)
|
|
35
|
+
print(f"Updated: {updated.name} — {updated.description}")
|
|
36
|
+
|
|
37
|
+
# List all branches
|
|
38
|
+
page = client.branches.list(repo.id)
|
|
39
|
+
print(f"Total branches: {page.total_count}")
|
|
40
|
+
for b in page.data:
|
|
41
|
+
print(f" - {b.name} ({b.id})")
|
|
42
|
+
|
|
43
|
+
# Get branch head
|
|
44
|
+
head = client.branches.get_head(repo.id, branch_a.id)
|
|
45
|
+
print(f"Branch head: {head}")
|
|
46
|
+
|
|
47
|
+
# Add a node to branch_a so there's something to diff
|
|
48
|
+
client.nodes.create(
|
|
49
|
+
repo.id,
|
|
50
|
+
branch_a.id,
|
|
51
|
+
node_data={"@type": "Folder", "@id": "Folder_diff", "doc_string": "For diff"},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Diff between branches
|
|
55
|
+
diff = client.branches.diff(
|
|
56
|
+
repo.id, branch_a.id, target_branch_id=branch_b.id
|
|
57
|
+
)
|
|
58
|
+
print(f"Diff: {diff}")
|
|
59
|
+
|
|
60
|
+
# Delete a branch
|
|
61
|
+
client.branches.delete(repo.id, branch_b.id)
|
|
62
|
+
print(f"Deleted {branch_b.name}")
|
|
63
|
+
|
|
64
|
+
finally:
|
|
65
|
+
if repo:
|
|
66
|
+
client.repositories.delete(repo.id)
|
|
67
|
+
print("Cleaned up repository")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
main()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Merge and rebase — diff branches, then merge or rebase.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
export FORGE_API_KEY="your-api-key"
|
|
6
|
+
python examples/merge_and_rebase.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from py_forge import Client
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
client = Client()
|
|
13
|
+
repo = None
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
repo = client.repositories.create(
|
|
17
|
+
name="merge-rebase-example",
|
|
18
|
+
repo_type_key="TST",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Set up two branches with diverging content
|
|
22
|
+
main_branch = client.branches.create(repo.id, name="main-line")
|
|
23
|
+
feature = client.branches.create(
|
|
24
|
+
repo.id, name="feature", source_branch_id=main_branch.id
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Add a node to the feature branch
|
|
28
|
+
client.nodes.create(
|
|
29
|
+
repo.id,
|
|
30
|
+
feature.id,
|
|
31
|
+
node_data={
|
|
32
|
+
"@type": "Folder",
|
|
33
|
+
"@id": "Folder_feature",
|
|
34
|
+
"doc_string": "Feature work",
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Diff before merging
|
|
39
|
+
diff = client.branches.diff(
|
|
40
|
+
repo.id, feature.id, target_branch_id=main_branch.id
|
|
41
|
+
)
|
|
42
|
+
print(f"Diff (feature → main): {diff}")
|
|
43
|
+
|
|
44
|
+
# Merge feature into main
|
|
45
|
+
merge_result = client.repositories.merge(
|
|
46
|
+
repo.id,
|
|
47
|
+
source_branch_id=feature.id,
|
|
48
|
+
target_branch_id=main_branch.id,
|
|
49
|
+
message="Merge feature into main",
|
|
50
|
+
)
|
|
51
|
+
print(f"Merge result: {merge_result}")
|
|
52
|
+
|
|
53
|
+
# --- Rebase example ---
|
|
54
|
+
|
|
55
|
+
rebase_branch = client.branches.create(
|
|
56
|
+
repo.id, name="rebase-me", source_branch_id=main_branch.id
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
client.nodes.create(
|
|
60
|
+
repo.id,
|
|
61
|
+
rebase_branch.id,
|
|
62
|
+
node_data={
|
|
63
|
+
"@type": "Folder",
|
|
64
|
+
"@id": "Folder_rebase",
|
|
65
|
+
"doc_string": "Will be rebased",
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Rebase onto main
|
|
70
|
+
rebase_result = client.repositories.rebase(
|
|
71
|
+
repo.id,
|
|
72
|
+
source_branch=rebase_branch.id,
|
|
73
|
+
onto_branch=main_branch.id,
|
|
74
|
+
message="Rebase onto main",
|
|
75
|
+
)
|
|
76
|
+
print(f"Rebase result: {rebase_result}")
|
|
77
|
+
|
|
78
|
+
finally:
|
|
79
|
+
if repo:
|
|
80
|
+
client.repositories.delete(repo.id)
|
|
81
|
+
print("Cleaned up repository")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
main()
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Nodes — CRUD, history, and commit with batched operations.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
export FORGE_API_KEY="your-api-key"
|
|
6
|
+
python examples/nodes.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from py_forge import Client
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
client = Client()
|
|
13
|
+
repo = None
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
repo = client.repositories.create(
|
|
17
|
+
name="nodes-example",
|
|
18
|
+
repo_type_key="TST",
|
|
19
|
+
)
|
|
20
|
+
branch = client.branches.create(repo.id, name="work")
|
|
21
|
+
print(f"Repository: {repo.id}, Branch: {branch.id}")
|
|
22
|
+
|
|
23
|
+
# Create a node directly
|
|
24
|
+
node = client.nodes.create(
|
|
25
|
+
repo.id,
|
|
26
|
+
branch.id,
|
|
27
|
+
node_data={
|
|
28
|
+
"@type": "Folder",
|
|
29
|
+
"@id": "Folder_1",
|
|
30
|
+
"doc_string": "First folder",
|
|
31
|
+
},
|
|
32
|
+
)
|
|
33
|
+
print(f"Created node: {node.id}")
|
|
34
|
+
|
|
35
|
+
# Read it back
|
|
36
|
+
fetched = client.nodes.get(repo.id, branch.id, node.id)
|
|
37
|
+
print(f"Fetched: {fetched.node}")
|
|
38
|
+
|
|
39
|
+
# Update the node
|
|
40
|
+
updated = client.nodes.update(
|
|
41
|
+
repo.id,
|
|
42
|
+
branch.id,
|
|
43
|
+
node.id,
|
|
44
|
+
node_data={
|
|
45
|
+
"@type": "Folder",
|
|
46
|
+
"@id": "Folder_1",
|
|
47
|
+
"doc_string": "Updated folder",
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
print(f"Updated: {updated.node}")
|
|
51
|
+
|
|
52
|
+
# List nodes
|
|
53
|
+
page = client.nodes.list(repo.id, branch.id)
|
|
54
|
+
print(f"Total nodes: {page.total_count}")
|
|
55
|
+
for n in page.data:
|
|
56
|
+
print(f" - {n.id}")
|
|
57
|
+
|
|
58
|
+
# Node history
|
|
59
|
+
history = client.nodes.get_history(repo.id, branch.id, node.id)
|
|
60
|
+
print(f"History: {history}")
|
|
61
|
+
|
|
62
|
+
# Single commit with multiple operations (create, update, delete)
|
|
63
|
+
commit = client.commits.create(
|
|
64
|
+
repo.id,
|
|
65
|
+
branch.id,
|
|
66
|
+
message="Batch: create, update, and delete nodes",
|
|
67
|
+
operations=[
|
|
68
|
+
{
|
|
69
|
+
"type": "node_create",
|
|
70
|
+
"data": {
|
|
71
|
+
"node_data": {
|
|
72
|
+
"@type": "Folder",
|
|
73
|
+
"@id": "Folder_batch_1",
|
|
74
|
+
"doc_string": "Created in batch",
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "node_update",
|
|
80
|
+
"data": {
|
|
81
|
+
"node_id": node.id,
|
|
82
|
+
"node_data": {
|
|
83
|
+
"@type": "Folder",
|
|
84
|
+
"@id": "Folder_1",
|
|
85
|
+
"doc_string": "Updated in batch",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"type": "node_delete",
|
|
91
|
+
"data": {
|
|
92
|
+
"node_id": node.id,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
)
|
|
97
|
+
print(f"Commit: {commit.id} — {commit.message}")
|
|
98
|
+
|
|
99
|
+
finally:
|
|
100
|
+
if repo:
|
|
101
|
+
client.repositories.delete(repo.id)
|
|
102
|
+
print("Cleaned up repository")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
main()
|