xenfra-sdk 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl
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.
- xenfra_sdk/__init__.py +21 -21
- xenfra_sdk/cli/main.py +226 -226
- xenfra_sdk/config.py +26 -26
- xenfra_sdk/db/models.py +24 -28
- xenfra_sdk/db/session.py +30 -30
- xenfra_sdk/dependencies.py +39 -39
- xenfra_sdk/dockerizer.py +87 -87
- xenfra_sdk/engine.py +411 -388
- xenfra_sdk/exceptions.py +19 -19
- xenfra_sdk/mcp_client.py +154 -154
- xenfra_sdk/models.py +182 -182
- xenfra_sdk/patterns.json +13 -13
- xenfra_sdk/privacy.py +153 -153
- xenfra_sdk/recipes.py +25 -25
- xenfra_sdk/resources/base.py +3 -3
- xenfra_sdk/resources/deployments.py +89 -89
- xenfra_sdk/resources/intelligence.py +95 -95
- xenfra_sdk/security.py +41 -41
- xenfra_sdk/templates/Dockerfile.j2 +25 -25
- xenfra_sdk/templates/cloud-init.sh.j2 +68 -68
- xenfra_sdk/templates/docker-compose.yml.j2 +33 -33
- {xenfra_sdk-0.1.2.dist-info → xenfra_sdk-0.1.3.dist-info}/METADATA +92 -92
- xenfra_sdk-0.1.3.dist-info/RECORD +31 -0
- {xenfra_sdk-0.1.2.dist-info → xenfra_sdk-0.1.3.dist-info}/WHEEL +1 -1
- xenfra_sdk-0.1.2.dist-info/RECORD +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: xenfra-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Xenfra SDK: Core engine and utilities for the Xenfra platform.
|
|
5
5
|
Author: xenfra-cloud
|
|
6
6
|
Author-email: xenfra-cloud <xenfracloud@gmail.com>
|
|
@@ -25,94 +25,94 @@ Requires-Dist: cryptography>=41.0.0
|
|
|
25
25
|
Requires-Python: >=3.13
|
|
26
26
|
Description-Content-Type: text/markdown
|
|
27
27
|
|
|
28
|
-
# Xenfra Python SDK
|
|
29
|
-
|
|
30
|
-
The official, open-source Python SDK for interacting with the Xenfra API.
|
|
31
|
-
|
|
32
|
-
This SDK provides a simple and Pythonic interface for developers and AI Agents to programmatically manage infrastructure, deployments, and other platform resources.
|
|
33
|
-
|
|
34
|
-
## Installation
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
pip install xenfra-sdk
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Basic Usage
|
|
41
|
-
|
|
42
|
-
Initialize the client with your API token (or ensure the `XENFRA_TOKEN` environment variable is set).
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
import os
|
|
46
|
-
from xenfra_sdk import XenfraClient
|
|
47
|
-
from xenfra_sdk.exceptions import XenfraAPIError
|
|
48
|
-
|
|
49
|
-
client = XenfraClient(token=os.getenv("XENFRA_TOKEN"))
|
|
50
|
-
|
|
51
|
-
try:
|
|
52
|
-
projects = client.projects.list()
|
|
53
|
-
for p in projects:
|
|
54
|
-
print(f"Found project: {p.name} (Status: {p.status})")
|
|
55
|
-
except XenfraAPIError as e:
|
|
56
|
-
print(f"API Error: {e.detail}")
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Usage for Agentic Workflows
|
|
60
|
-
|
|
61
|
-
The Xenfra SDK is designed to be used as a "tool" by AI Agents (e.g., OpenAI Assistants). The Pydantic models are compatible with function-calling schemas, allowing an agent to easily call these methods.
|
|
62
|
-
|
|
63
|
-
Here is a conceptual example of how an agent might use the SDK to fulfill a user's request.
|
|
64
|
-
|
|
65
|
-
```python
|
|
66
|
-
# This is a conceptual representation of an agent's internal logic.
|
|
67
|
-
# The agent would be configured with functions that call these SDK methods.
|
|
68
|
-
|
|
69
|
-
def list_all_projects():
|
|
70
|
-
"""Lists all available projects in the Xenfra account."""
|
|
71
|
-
return client.projects.list()
|
|
72
|
-
|
|
73
|
-
def create_new_deployment(project_name: str, git_repo: str, branch: str = "main"):
|
|
74
|
-
"""
|
|
75
|
-
Creates a new deployment for a project.
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
project_name: The name for the new deployment.
|
|
79
|
-
git_repo: The URL of the git repository to deploy.
|
|
80
|
-
branch: The branch to deploy (defaults to 'main').
|
|
81
|
-
"""
|
|
82
|
-
return client.deployments.create(
|
|
83
|
-
project_name=project_name,
|
|
84
|
-
git_repo=git_repo,
|
|
85
|
-
branch=branch,
|
|
86
|
-
framework="fastapi" # Framework detection would be part of a more complex agent
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
# --- Agent Execution Flow ---
|
|
90
|
-
|
|
91
|
-
# User prompt: "Deploy my new app from github.com/user/my-app"
|
|
92
|
-
|
|
93
|
-
# 1. Agent decides which tool to use: `create_new_deployment`
|
|
94
|
-
# 2. Agent extracts parameters:
|
|
95
|
-
# - project_name = "my-app" (inferred)
|
|
96
|
-
# - git_repo = "https://github.com/user/my-app"
|
|
97
|
-
# 3. Agent calls the tool:
|
|
98
|
-
# create_new_deployment(
|
|
99
|
-
# project_name="my-app",
|
|
100
|
-
# git_repo="https://github.com/user/my-app"
|
|
101
|
-
# )
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Error Handling
|
|
105
|
-
|
|
106
|
-
The SDK uses custom exceptions for clear error handling. All API-related errors will raise a `XenfraAPIError`, which contains the `status_code` and a `detail` message from the API response.
|
|
107
|
-
|
|
108
|
-
```python
|
|
109
|
-
from xenfra_sdk.exceptions import XenfraAPIError, AuthenticationError
|
|
110
|
-
|
|
111
|
-
try:
|
|
112
|
-
# Make an API call
|
|
113
|
-
...
|
|
114
|
-
except AuthenticationError as e:
|
|
115
|
-
print("Authentication failed. Please check your token.")
|
|
116
|
-
except XenfraAPIError as e:
|
|
117
|
-
print(f"An API error occurred with status {e.status_code}: {e.detail}")
|
|
118
|
-
```
|
|
28
|
+
# Xenfra Python SDK
|
|
29
|
+
|
|
30
|
+
The official, open-source Python SDK for interacting with the Xenfra API.
|
|
31
|
+
|
|
32
|
+
This SDK provides a simple and Pythonic interface for developers and AI Agents to programmatically manage infrastructure, deployments, and other platform resources.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install xenfra-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Basic Usage
|
|
41
|
+
|
|
42
|
+
Initialize the client with your API token (or ensure the `XENFRA_TOKEN` environment variable is set).
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import os
|
|
46
|
+
from xenfra_sdk import XenfraClient
|
|
47
|
+
from xenfra_sdk.exceptions import XenfraAPIError
|
|
48
|
+
|
|
49
|
+
client = XenfraClient(token=os.getenv("XENFRA_TOKEN"))
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
projects = client.projects.list()
|
|
53
|
+
for p in projects:
|
|
54
|
+
print(f"Found project: {p.name} (Status: {p.status})")
|
|
55
|
+
except XenfraAPIError as e:
|
|
56
|
+
print(f"API Error: {e.detail}")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage for Agentic Workflows
|
|
60
|
+
|
|
61
|
+
The Xenfra SDK is designed to be used as a "tool" by AI Agents (e.g., OpenAI Assistants). The Pydantic models are compatible with function-calling schemas, allowing an agent to easily call these methods.
|
|
62
|
+
|
|
63
|
+
Here is a conceptual example of how an agent might use the SDK to fulfill a user's request.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# This is a conceptual representation of an agent's internal logic.
|
|
67
|
+
# The agent would be configured with functions that call these SDK methods.
|
|
68
|
+
|
|
69
|
+
def list_all_projects():
|
|
70
|
+
"""Lists all available projects in the Xenfra account."""
|
|
71
|
+
return client.projects.list()
|
|
72
|
+
|
|
73
|
+
def create_new_deployment(project_name: str, git_repo: str, branch: str = "main"):
|
|
74
|
+
"""
|
|
75
|
+
Creates a new deployment for a project.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
project_name: The name for the new deployment.
|
|
79
|
+
git_repo: The URL of the git repository to deploy.
|
|
80
|
+
branch: The branch to deploy (defaults to 'main').
|
|
81
|
+
"""
|
|
82
|
+
return client.deployments.create(
|
|
83
|
+
project_name=project_name,
|
|
84
|
+
git_repo=git_repo,
|
|
85
|
+
branch=branch,
|
|
86
|
+
framework="fastapi" # Framework detection would be part of a more complex agent
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# --- Agent Execution Flow ---
|
|
90
|
+
|
|
91
|
+
# User prompt: "Deploy my new app from github.com/user/my-app"
|
|
92
|
+
|
|
93
|
+
# 1. Agent decides which tool to use: `create_new_deployment`
|
|
94
|
+
# 2. Agent extracts parameters:
|
|
95
|
+
# - project_name = "my-app" (inferred)
|
|
96
|
+
# - git_repo = "https://github.com/user/my-app"
|
|
97
|
+
# 3. Agent calls the tool:
|
|
98
|
+
# create_new_deployment(
|
|
99
|
+
# project_name="my-app",
|
|
100
|
+
# git_repo="https://github.com/user/my-app"
|
|
101
|
+
# )
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Error Handling
|
|
105
|
+
|
|
106
|
+
The SDK uses custom exceptions for clear error handling. All API-related errors will raise a `XenfraAPIError`, which contains the `status_code` and a `detail` message from the API response.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from xenfra_sdk.exceptions import XenfraAPIError, AuthenticationError
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
# Make an API call
|
|
113
|
+
...
|
|
114
|
+
except AuthenticationError as e:
|
|
115
|
+
print("Authentication failed. Please check your token.")
|
|
116
|
+
except XenfraAPIError as e:
|
|
117
|
+
print(f"An API error occurred with status {e.status_code}: {e.detail}")
|
|
118
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
xenfra_sdk/__init__.py,sha256=ILBGPKNWJjEwvLWxYD2ulOYLD43nf3-Xu71FwcraH5c,488
|
|
2
|
+
xenfra_sdk/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
xenfra_sdk/cli/main.py,sha256=9uQja07LxLfBCHeCRlDCStK1X248h9kMRPep6iFShyk,8184
|
|
4
|
+
xenfra_sdk/client.py,sha256=ufxjjVY3UG1roR0q8LYBmCHOJ13uRQuycqTqYuHgqTs,3514
|
|
5
|
+
xenfra_sdk/client_with_hooks.py,sha256=iN-xTGdeSPizktM6UG-aZEsuwQc5OgosNYUf1_Tq4Dc,10046
|
|
6
|
+
xenfra_sdk/config.py,sha256=omb3SQMAk5NXOuCrLZe4bp_bX7F0SXA1ERJ5PdDaxMU,614
|
|
7
|
+
xenfra_sdk/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
xenfra_sdk/db/models.py,sha256=oNT9UhYzr_SgzDJdPu5fF6IiiztWjm2tHZzpIAYVJ4Y,706
|
|
9
|
+
xenfra_sdk/db/session.py,sha256=ul6tFBBDKU8UErJsZ-g7b8cryLr9-yA6jGY3d8fD15Q,853
|
|
10
|
+
xenfra_sdk/dependencies.py,sha256=k7tiy_5dayr_iQx_i2klGeNjGWhxfivGVC38SpvQvzE,1250
|
|
11
|
+
xenfra_sdk/dockerizer.py,sha256=hOXy6dKl3QGFamRN2WZ0rAh6Vguykhkdyal3grhGAOI,3146
|
|
12
|
+
xenfra_sdk/engine.py,sha256=-EyDw5BrsyjgaH8NgYYi-UFWMRvPMm2UAou_TxRvRvY,17055
|
|
13
|
+
xenfra_sdk/exceptions.py,sha256=FaKctVJNMFIw09G8Lm2yd_DHhSngGcyh2j_BTgXMM60,496
|
|
14
|
+
xenfra_sdk/mcp_client.py,sha256=GPsVJtWT87G7k_GxePATLfCqFkYFFNIbpW5AsZi4Bhk,5931
|
|
15
|
+
xenfra_sdk/models.py,sha256=VDd41JxqyzrsNZugXe5IP9OKkNuGVRFSnoTrHBOSKjk,7185
|
|
16
|
+
xenfra_sdk/patterns.json,sha256=RBuQdU59UEXF5pxUvcWq_ZegsK0iUfh4wusWaY77qxo,459
|
|
17
|
+
xenfra_sdk/privacy.py,sha256=ksGf5L9PVtRP-xZS3T-Gj7MKfexTqIMgbFLoYkIESOE,5662
|
|
18
|
+
xenfra_sdk/recipes.py,sha256=g_UKQIcdSokYh7zn186mzDTr08P034-KZ1iiDNELyP4,877
|
|
19
|
+
xenfra_sdk/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
xenfra_sdk/resources/base.py,sha256=C6BuZfhR-oU5ecHSfkGG6ZLU6MHGXUyCWoy1F-yTIf8,84
|
|
21
|
+
xenfra_sdk/resources/deployments.py,sha256=JwlsCUKQUyvUF0lYUv6A3n1EkglXoYsICNVssx8E6ec,3428
|
|
22
|
+
xenfra_sdk/resources/intelligence.py,sha256=Y11K6_iXfm2QKTbH1vUmt45MifLoVtZtlHEkqbzmTzs,3418
|
|
23
|
+
xenfra_sdk/resources/projects.py,sha256=EsCVXmqkhWl_Guz_8WDQDi3kAm1Wyg1rjXcyAigPD6E,3712
|
|
24
|
+
xenfra_sdk/security.py,sha256=Px887RRb1BUDXaPUrxmQITJ1mHyOyupCJqEDZ78F7Tk,1240
|
|
25
|
+
xenfra_sdk/templates/Dockerfile.j2,sha256=GXc0JiaF-HsxTQS15Gs2fcvsIhA1EHnwapdFVitUWS0,689
|
|
26
|
+
xenfra_sdk/templates/cloud-init.sh.j2,sha256=NKIwtL9OgnlK2NnYRZI3gWC9aYl6wNPsS6r14g8eHQQ,2290
|
|
27
|
+
xenfra_sdk/templates/docker-compose.yml.j2,sha256=qMHiatuZlxiYZ1pE_g2ag1M798MvQbeq0cVTVK07jkM,893
|
|
28
|
+
xenfra_sdk/utils.py,sha256=d8eCjjV32QwqoJa759CEcETnnsjG5qVKDLQ84yYtlus,3898
|
|
29
|
+
xenfra_sdk-0.1.3.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
|
|
30
|
+
xenfra_sdk-0.1.3.dist-info/METADATA,sha256=0uvLdk5kr1Zts-HDNDqOTPNHJ0R2DkRFjG0Q64l4T0Q,3980
|
|
31
|
+
xenfra_sdk-0.1.3.dist-info/RECORD,,
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
xenfra_sdk/__init__.py,sha256=lk9xo2msYvs_JgBePTIuxRb2sBW-egJS_EAOq4w4xQo,467
|
|
2
|
-
xenfra_sdk/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
xenfra_sdk/cli/main.py,sha256=541nlIUYFFeu4h1sCXivaHMC7SqpskazI0YocM8ylh4,7958
|
|
4
|
-
xenfra_sdk/client.py,sha256=ufxjjVY3UG1roR0q8LYBmCHOJ13uRQuycqTqYuHgqTs,3514
|
|
5
|
-
xenfra_sdk/client_with_hooks.py,sha256=iN-xTGdeSPizktM6UG-aZEsuwQc5OgosNYUf1_Tq4Dc,10046
|
|
6
|
-
xenfra_sdk/config.py,sha256=gaT4k5iJgW9guNVmlnYkCFGDSU1_er4LRZA2CgfKmJ0,588
|
|
7
|
-
xenfra_sdk/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
xenfra_sdk/db/models.py,sha256=LqnpUbtSZ21jdPVzdyFyxpYqOXUkBVl5JGXq85ASI7g,875
|
|
9
|
-
xenfra_sdk/db/session.py,sha256=LoTKFO3FTsx5AtZ-0ZsplxXjAdzOgcr3Yk-dkeJsz5U,823
|
|
10
|
-
xenfra_sdk/dependencies.py,sha256=WHGfIrEYkss5yuBd_uOFrB6lPBWM2X0mEuG26ILAjXI,1211
|
|
11
|
-
xenfra_sdk/dockerizer.py,sha256=73CFwztKogBmlX00tek0M8evncnZRDThQKmg7auw6mc,3059
|
|
12
|
-
xenfra_sdk/engine.py,sha256=5qrtDc8qXC9xuZGPUwcUeGEtVuVksWY64sCxh-Wqa7o,15517
|
|
13
|
-
xenfra_sdk/exceptions.py,sha256=aMVtDVlzG7-FT2G_b-pJSuuey22B4YvC-b-L37GaImM,477
|
|
14
|
-
xenfra_sdk/mcp_client.py,sha256=NZtQz_qK_8i504rVPXlE1vPdzt75hg8Lkp4d8BA8dk0,5777
|
|
15
|
-
xenfra_sdk/models.py,sha256=o03GUy4qcgAJa9KzR9UXWKLPWTR5gvE8GF6KSAj80eM,7003
|
|
16
|
-
xenfra_sdk/patterns.json,sha256=xHxbc0ogHDwysMczi30_hW1Ylfdsf-nsQdAom7RZ4KI,446
|
|
17
|
-
xenfra_sdk/privacy.py,sha256=Bscv7bopCQTeJhvU8Z2jxdBfc5tCZDY5kuODonTcgSk,5509
|
|
18
|
-
xenfra_sdk/recipes.py,sha256=J6-7tDWVXv8IelkdBta5pDRhD0o5VgAM_jWDKvPvm5g,852
|
|
19
|
-
xenfra_sdk/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
xenfra_sdk/resources/base.py,sha256=5n-HTKAnIX2lTgXwio0xtwoaBn-nksjdm8qRTpe3iDk,81
|
|
21
|
-
xenfra_sdk/resources/deployments.py,sha256=QIOd-9L1m-FW5I6eXZEtQSteg_gkIzk2nnqr_hQs5gc,3339
|
|
22
|
-
xenfra_sdk/resources/intelligence.py,sha256=ihkhv8jj4FDB4pbSezAnUL-5syZ77lLXPI6X38THcnQ,3323
|
|
23
|
-
xenfra_sdk/resources/projects.py,sha256=EsCVXmqkhWl_Guz_8WDQDi3kAm1Wyg1rjXcyAigPD6E,3712
|
|
24
|
-
xenfra_sdk/security.py,sha256=6vMZpbglhkRGBVVj4RCTu45-MCnQ15wt94-996zmaT8,1199
|
|
25
|
-
xenfra_sdk/templates/Dockerfile.j2,sha256=apWts895OOoUYwj_fOa6OiylFB5m8zFEYvJ1Nki32YM,664
|
|
26
|
-
xenfra_sdk/templates/cloud-init.sh.j2,sha256=QCWG8hL1V05bAQ7BQ70QfuhIvS4tnsL8ZTCVtyi9F0A,2222
|
|
27
|
-
xenfra_sdk/templates/docker-compose.yml.j2,sha256=zKUT2cd_FrxXvRxE-vAAjuQk3-nLNQjRe-StkhAWRQA,860
|
|
28
|
-
xenfra_sdk/utils.py,sha256=d8eCjjV32QwqoJa759CEcETnnsjG5qVKDLQ84yYtlus,3898
|
|
29
|
-
xenfra_sdk-0.1.2.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
|
|
30
|
-
xenfra_sdk-0.1.2.dist-info/METADATA,sha256=sFTH52KuMEL0mWE3gFhKAYoOE_rS6iX_FOFJp19bhtU,3889
|
|
31
|
-
xenfra_sdk-0.1.2.dist-info/RECORD,,
|