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/models.py CHANGED
@@ -1,182 +1,182 @@
1
- """
2
- Pydantic models for the Xenfra SDK, representing API request and response data structures.
3
- These models are used for data validation, serialization, and providing clear schemas
4
- for external tools like OpenAI function calling.
5
- """
6
-
7
- from datetime import datetime
8
- from enum import Enum
9
-
10
- from pydantic import BaseModel, Field
11
-
12
-
13
- class DeploymentStatus(str, Enum):
14
- """
15
- Represents the possible statuses of a deployment.
16
- """
17
-
18
- PENDING = "pending"
19
- IN_PROGRESS = "in_progress"
20
- SUCCESS = "success"
21
- FAILED = "failed"
22
-
23
-
24
- class SourceType(str, Enum):
25
- """
26
- Represents the source type of a deployment.
27
- """
28
-
29
- LOCAL = "local"
30
- GIT = "git"
31
-
32
-
33
- class Deployment(BaseModel):
34
- """
35
- Represents a single deployment instance.
36
- """
37
-
38
- id: str = Field(..., description="Unique identifier for the deployment")
39
- projectId: str = Field(..., description="Identifier of the project being deployed")
40
- status: DeploymentStatus = Field(..., description="Current status of the deployment")
41
- source: str = Field(..., description="Source of the deployment (e.g., 'cli', 'api')")
42
- created_at: datetime = Field(..., description="Timestamp when the deployment was created")
43
- finished_at: datetime | None = Field(None, description="Timestamp when the deployment finished")
44
-
45
-
46
- class DeploymentRecord(BaseModel):
47
- """
48
- Represents a record of a completed deployment.
49
- """
50
-
51
- deployment_id: str = Field(..., description="Unique identifier for this deployment instance.")
52
- timestamp: datetime = Field(..., description="Timestamp of when the deployment succeeded.")
53
- source_type: SourceType = Field(..., description="The type of the source code (local or git).")
54
- source_identifier: str = Field(
55
- ...,
56
- description="The identifier for the source (commit SHA for git, archive path for local).",
57
- )
58
-
59
-
60
- class BalanceRead(BaseModel):
61
- """
62
- Represents a snapshot of the user's account balance and usage.
63
- """
64
-
65
- month_to_date_balance: str = Field(
66
- ..., description="The account balance in USD at the beginning of the month."
67
- )
68
- account_balance: str = Field(..., description="The current total account balance in USD.")
69
- month_to_date_usage: str = Field(
70
- ..., description="The total usage in USD for the current month."
71
- )
72
- generated_at: str = Field(
73
- ..., description="The timestamp when this balance report was generated."
74
- )
75
- error: str | None = Field(
76
- None, description="Any error message associated with fetching the balance."
77
- )
78
-
79
-
80
- class DropletCostRead(BaseModel):
81
- """
82
- Represents the cost information for a single DigitalOcean Droplet.
83
- """
84
-
85
- id: int = Field(..., description="The unique identifier for the Droplet.")
86
- name: str = Field(..., description="The user-given name of the Droplet.")
87
- ip_address: str = Field(..., description="The public IP address of the Droplet.")
88
- status: str = Field(
89
- ..., description="The current status of the Droplet (e.g., 'active', 'off')."
90
- )
91
- size_slug: str = Field(
92
- ..., description="The size slug representing the Droplet's resources (e.g., 's-1vcpu-1gb')."
93
- )
94
- monthly_price: float = Field(..., description="The monthly cost of this Droplet in USD.")
95
-
96
-
97
- class ProjectRead(BaseModel):
98
- """
99
- Represents a project, including its deployment status and estimated costs.
100
- """
101
-
102
- id: int = Field(..., description="The unique identifier for the project.")
103
- name: str = Field(..., description="The user-given name of the project.")
104
- ip_address: str | None = Field(
105
- None, description="The public IP address of the server running the project."
106
- )
107
- status: str = Field(
108
- ..., description="The current status of the project (e.g., 'LIVE', 'FAILED')."
109
- )
110
- region: str = Field(
111
- ..., description="The geographical region where the project is deployed (e.g., 'nyc3')."
112
- )
113
- size_slug: str = Field(..., description="The size slug of the server running the project.")
114
- estimated_monthly_cost: float | None = Field(
115
- None, description="The estimated monthly cost of the project's infrastructure in USD."
116
- )
117
- created_at: datetime = Field(..., description="The timestamp when the project was created.")
118
-
119
-
120
- # Intelligence Service Models
121
-
122
-
123
- class PatchObject(BaseModel):
124
- """
125
- Represents a structured patch for a configuration file.
126
- """
127
-
128
- file: str | None = Field(
129
- None, description="The name of the file to be patched (e.g., 'requirements.txt')"
130
- )
131
- operation: str | None = Field(None, description="The patch operation (e.g., 'add', 'replace')")
132
- path: str | None = Field(None, description="A JSON-like path to the field to be changed")
133
- value: str | None = Field(None, description="The new value to apply")
134
-
135
-
136
- class DiagnosisResponse(BaseModel):
137
- """
138
- Response from the AI diagnosis endpoint.
139
- """
140
-
141
- diagnosis: str = Field(..., description="Human-readable explanation of the problem")
142
- suggestion: str = Field(..., description="Recommended course of action")
143
- patch: PatchObject | None = Field(None, description="Optional machine-applicable patch")
144
-
145
-
146
- class PackageManagerOption(BaseModel):
147
- """
148
- Represents a detected package manager option.
149
- """
150
-
151
- manager: str = Field(..., description="Package manager name (uv, pip, poetry, npm, etc.)")
152
- file: str = Field(..., description="Associated dependency file")
153
-
154
-
155
- class CodebaseAnalysisResponse(BaseModel):
156
- """
157
- Response from the codebase analysis endpoint.
158
- """
159
-
160
- framework: str = Field(..., description="Detected framework (fastapi, flask, django)")
161
- port: int = Field(..., description="Detected application port")
162
- database: str = Field(..., description="Detected database (postgresql, mysql, sqlite, none)")
163
- cache: str | None = Field(None, description="Detected cache (redis, memcached, none)")
164
- workers: list[str] | None = Field(None, description="Detected background workers (celery, rq)")
165
- env_vars: list[str] | None = Field(None, description="Required environment variables")
166
- package_manager: str = Field(
167
- ..., description="Detected package manager (uv, pip, poetry, npm, pnpm, yarn, go, bundler)"
168
- )
169
- dependency_file: str = Field(
170
- ...,
171
- description="Dependency manifest file (pyproject.toml, requirements.txt, package.json, go.mod, Gemfile)",
172
- )
173
- has_conflict: bool = Field(False, description="True if multiple package managers detected")
174
- detected_package_managers: list[PackageManagerOption] | None = Field(
175
- None, description="All detected package managers (if conflict)"
176
- )
177
- instance_size: str = Field(
178
- ..., description="Recommended instance size (basic, standard, premium)"
179
- )
180
- estimated_cost_monthly: float = Field(..., description="Estimated monthly cost in USD")
181
- confidence: float = Field(..., description="Confidence score (0.0-1.0)")
182
- notes: str | None = Field(None, description="Additional observations")
1
+ """
2
+ Pydantic models for the Xenfra SDK, representing API request and response data structures.
3
+ These models are used for data validation, serialization, and providing clear schemas
4
+ for external tools like OpenAI function calling.
5
+ """
6
+
7
+ from datetime import datetime
8
+ from enum import Enum
9
+
10
+ from pydantic import BaseModel, Field
11
+
12
+
13
+ class DeploymentStatus(str, Enum):
14
+ """
15
+ Represents the possible statuses of a deployment.
16
+ """
17
+
18
+ PENDING = "pending"
19
+ IN_PROGRESS = "in_progress"
20
+ SUCCESS = "success"
21
+ FAILED = "failed"
22
+
23
+
24
+ class SourceType(str, Enum):
25
+ """
26
+ Represents the source type of a deployment.
27
+ """
28
+
29
+ LOCAL = "local"
30
+ GIT = "git"
31
+
32
+
33
+ class Deployment(BaseModel):
34
+ """
35
+ Represents a single deployment instance.
36
+ """
37
+
38
+ id: str = Field(..., description="Unique identifier for the deployment")
39
+ projectId: str = Field(..., description="Identifier of the project being deployed")
40
+ status: DeploymentStatus = Field(..., description="Current status of the deployment")
41
+ source: str = Field(..., description="Source of the deployment (e.g., 'cli', 'api')")
42
+ created_at: datetime = Field(..., description="Timestamp when the deployment was created")
43
+ finished_at: datetime | None = Field(None, description="Timestamp when the deployment finished")
44
+
45
+
46
+ class DeploymentRecord(BaseModel):
47
+ """
48
+ Represents a record of a completed deployment.
49
+ """
50
+
51
+ deployment_id: str = Field(..., description="Unique identifier for this deployment instance.")
52
+ timestamp: datetime = Field(..., description="Timestamp of when the deployment succeeded.")
53
+ source_type: SourceType = Field(..., description="The type of the source code (local or git).")
54
+ source_identifier: str = Field(
55
+ ...,
56
+ description="The identifier for the source (commit SHA for git, archive path for local).",
57
+ )
58
+
59
+
60
+ class BalanceRead(BaseModel):
61
+ """
62
+ Represents a snapshot of the user's account balance and usage.
63
+ """
64
+
65
+ month_to_date_balance: str = Field(
66
+ ..., description="The account balance in USD at the beginning of the month."
67
+ )
68
+ account_balance: str = Field(..., description="The current total account balance in USD.")
69
+ month_to_date_usage: str = Field(
70
+ ..., description="The total usage in USD for the current month."
71
+ )
72
+ generated_at: str = Field(
73
+ ..., description="The timestamp when this balance report was generated."
74
+ )
75
+ error: str | None = Field(
76
+ None, description="Any error message associated with fetching the balance."
77
+ )
78
+
79
+
80
+ class DropletCostRead(BaseModel):
81
+ """
82
+ Represents the cost information for a single DigitalOcean Droplet.
83
+ """
84
+
85
+ id: int = Field(..., description="The unique identifier for the Droplet.")
86
+ name: str = Field(..., description="The user-given name of the Droplet.")
87
+ ip_address: str = Field(..., description="The public IP address of the Droplet.")
88
+ status: str = Field(
89
+ ..., description="The current status of the Droplet (e.g., 'active', 'off')."
90
+ )
91
+ size_slug: str = Field(
92
+ ..., description="The size slug representing the Droplet's resources (e.g., 's-1vcpu-1gb')."
93
+ )
94
+ monthly_price: float = Field(..., description="The monthly cost of this Droplet in USD.")
95
+
96
+
97
+ class ProjectRead(BaseModel):
98
+ """
99
+ Represents a project, including its deployment status and estimated costs.
100
+ """
101
+
102
+ id: int = Field(..., description="The unique identifier for the project.")
103
+ name: str = Field(..., description="The user-given name of the project.")
104
+ ip_address: str | None = Field(
105
+ None, description="The public IP address of the server running the project."
106
+ )
107
+ status: str = Field(
108
+ ..., description="The current status of the project (e.g., 'LIVE', 'FAILED')."
109
+ )
110
+ region: str = Field(
111
+ ..., description="The geographical region where the project is deployed (e.g., 'nyc3')."
112
+ )
113
+ size_slug: str = Field(..., description="The size slug of the server running the project.")
114
+ estimated_monthly_cost: float | None = Field(
115
+ None, description="The estimated monthly cost of the project's infrastructure in USD."
116
+ )
117
+ created_at: datetime = Field(..., description="The timestamp when the project was created.")
118
+
119
+
120
+ # Intelligence Service Models
121
+
122
+
123
+ class PatchObject(BaseModel):
124
+ """
125
+ Represents a structured patch for a configuration file.
126
+ """
127
+
128
+ file: str | None = Field(
129
+ None, description="The name of the file to be patched (e.g., 'requirements.txt')"
130
+ )
131
+ operation: str | None = Field(None, description="The patch operation (e.g., 'add', 'replace')")
132
+ path: str | None = Field(None, description="A JSON-like path to the field to be changed")
133
+ value: str | None = Field(None, description="The new value to apply")
134
+
135
+
136
+ class DiagnosisResponse(BaseModel):
137
+ """
138
+ Response from the AI diagnosis endpoint.
139
+ """
140
+
141
+ diagnosis: str = Field(..., description="Human-readable explanation of the problem")
142
+ suggestion: str = Field(..., description="Recommended course of action")
143
+ patch: PatchObject | None = Field(None, description="Optional machine-applicable patch")
144
+
145
+
146
+ class PackageManagerOption(BaseModel):
147
+ """
148
+ Represents a detected package manager option.
149
+ """
150
+
151
+ manager: str = Field(..., description="Package manager name (uv, pip, poetry, npm, etc.)")
152
+ file: str = Field(..., description="Associated dependency file")
153
+
154
+
155
+ class CodebaseAnalysisResponse(BaseModel):
156
+ """
157
+ Response from the codebase analysis endpoint.
158
+ """
159
+
160
+ framework: str = Field(..., description="Detected framework (fastapi, flask, django)")
161
+ port: int = Field(..., description="Detected application port")
162
+ database: str = Field(..., description="Detected database (postgresql, mysql, sqlite, none)")
163
+ cache: str | None = Field(None, description="Detected cache (redis, memcached, none)")
164
+ workers: list[str] | None = Field(None, description="Detected background workers (celery, rq)")
165
+ env_vars: list[str] | None = Field(None, description="Required environment variables")
166
+ package_manager: str = Field(
167
+ ..., description="Detected package manager (uv, pip, poetry, npm, pnpm, yarn, go, bundler)"
168
+ )
169
+ dependency_file: str = Field(
170
+ ...,
171
+ description="Dependency manifest file (pyproject.toml, requirements.txt, package.json, go.mod, Gemfile)",
172
+ )
173
+ has_conflict: bool = Field(False, description="True if multiple package managers detected")
174
+ detected_package_managers: list[PackageManagerOption] | None = Field(
175
+ None, description="All detected package managers (if conflict)"
176
+ )
177
+ instance_size: str = Field(
178
+ ..., description="Recommended instance size (basic, standard, premium)"
179
+ )
180
+ estimated_cost_monthly: float = Field(..., description="Estimated monthly cost in USD")
181
+ confidence: float = Field(..., description="Confidence score (0.0-1.0)")
182
+ notes: str | None = Field(None, description="Additional observations")
xenfra_sdk/patterns.json CHANGED
@@ -1,14 +1,14 @@
1
- {
2
- "redaction_patterns": [
3
- "dop_v1_[a-f0-9]{64}",
4
- "[sp]k_live_[a-zA-Z0-9]{24,}",
5
- "[sp]k_test_[a-zA-Z0-9]{24,}",
6
- "(https?://)[^\\s:]+:[^\\s@]+",
7
- "Bearer\\s[a-zA-Z0-9\\._\\-]{20,}",
8
- "(password|pwd|pass)=([^\\s&]+)",
9
- "AKIA[0-9A-Z]{16}",
10
- "[0-9a-zA-Z/+]{40}",
11
- "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b",
12
- "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
13
- ]
1
+ {
2
+ "redaction_patterns": [
3
+ "dop_v1_[a-f0-9]{64}",
4
+ "[sp]k_live_[a-zA-Z0-9]{24,}",
5
+ "[sp]k_test_[a-zA-Z0-9]{24,}",
6
+ "(https?://)[^\\s:]+:[^\\s@]+",
7
+ "Bearer\\s[a-zA-Z0-9\\._\\-]{20,}",
8
+ "(password|pwd|pass)=([^\\s&]+)",
9
+ "AKIA[0-9A-Z]{16}",
10
+ "[0-9a-zA-Z/+]{40}",
11
+ "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b",
12
+ "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
13
+ ]
14
14
  }